Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 from types import TupleType
00042 from ..genxmlif.xmlifApi import XmlElementWrapper
00043
00044
00045 class XsvXmlElementWrapper (XmlElementWrapper):
00046
00047
00048 def __init__(self, element, treeWrapper, curNs=[], initAttrSeq=1):
00049 XmlElementWrapper.__init__(self, element, treeWrapper, curNs, initAttrSeq)
00050 self.schemaRootNode = None
00051 self.xsdNode = None
00052 self.xsdAttrNodes = {}
00053
00054
00055 def cloneNode(self, deep, cloneCallback=None):
00056 return XmlElementWrapper.cloneNode(self, deep, self.cloneCallback)
00057
00058
00059 def cloneCallback(self, nodeCopy):
00060 nodeCopy.schemaRootNode = self.schemaRootNode
00061 nodeCopy.xsdNode = self.xsdNode
00062 nodeCopy.xsdAttrNodes = self.xsdAttrNodes.copy()
00063
00064
00065 def getSchemaRootNode (self):
00066 """Retrieve XML schema root node which this element node belongs to
00067 (e.g. for accessing target namespace attribute).
00068
00069 Returns XML schema root node which this element node belongs to
00070 """
00071 return self.schemaRootNode
00072
00073
00074 def setSchemaRootNode (self, schemaRootNode):
00075 """Store XML schema root node which this element node belongs to.
00076
00077 Input parameter:
00078 schemaRootNode: schema root node which this element node belongs to
00079 """
00080 self.schemaRootNode = schemaRootNode
00081
00082
00083 def getXsdNode (self):
00084 """Retrieve XML schema node responsible for this element node.
00085
00086 Returns XML schema node responsible for this element node.
00087 """
00088 return self.xsdNode
00089
00090
00091 def setXsdNode (self, xsdNode):
00092 """Store XML schema node responsible for this element node.
00093
00094 Input parameter:
00095 xsdNode: responsible XML schema ElementWrapper
00096 """
00097 self.xsdNode = xsdNode
00098
00099
00100 def getXsdAttrNode (self, tupleOrAttrName):
00101 """Retrieve XML schema node responsible for the requested attribute.
00102
00103 Input parameter:
00104 tupleOrAttrName: tuple '(namespace, attributeName)' or 'attributeName' if no namespace is used
00105 Returns XML schema node responsible for the requested attribute.
00106 """
00107 try:
00108 return self.xsdAttrNodes[tupleOrAttrName]
00109 except:
00110 if isinstance(tupleOrAttrName, TupleType):
00111 if tupleOrAttrName[1] == '*' and len(self.xsdAttrNodes) == 1:
00112 return self.xsdAttrNodes.values()[0]
00113 return None
00114
00115
00116 def setXsdAttrNode (self, tupleOrAttrName, xsdAttrNode):
00117 """Store XML schema node responsible for the given attribute.
00118
00119 Input parameter:
00120 tupleOrAttrName: tuple '(namespace, attributeName)' or 'attributeName' if no namespace is used
00121 xsdAttrNode: responsible XML schema ElementWrapper
00122 """
00123 self.xsdAttrNodes[tupleOrAttrName] = xsdAttrNode
00124
00125