|
@@ -132,7 +132,7 @@ class Value(object):
|
|
logger.error("Expected XML Element, but got junk...")
|
|
logger.error("Expected XML Element, but got junk...")
|
|
return
|
|
return
|
|
|
|
|
|
- def parseXMLEncoding(self, xmlvalue, parentDataTypeNode, parent, namespaceMapping):
|
|
|
|
|
|
+ def parseXMLEncoding(self, xmlvalue, parentDataTypeNode, parent):
|
|
self.checkXML(xmlvalue)
|
|
self.checkXML(xmlvalue)
|
|
if not "value" in xmlvalue.localName.lower():
|
|
if not "value" in xmlvalue.localName.lower():
|
|
logger.error("Expected <Value> , but found " + xmlvalue.localName + \
|
|
logger.error("Expected <Value> , but found " + xmlvalue.localName + \
|
|
@@ -153,15 +153,15 @@ class Value(object):
|
|
for el in xmlvalue.childNodes:
|
|
for el in xmlvalue.childNodes:
|
|
if not el.nodeType == el.ELEMENT_NODE:
|
|
if not el.nodeType == el.ELEMENT_NODE:
|
|
continue
|
|
continue
|
|
- val = self.__parseXMLSingleValue(el, parentDataTypeNode, parent, namespaceMapping=namespaceMapping)
|
|
|
|
|
|
+ val = self.__parseXMLSingleValue(el, parentDataTypeNode, parent)
|
|
if val is None:
|
|
if val is None:
|
|
self.value = []
|
|
self.value = []
|
|
return
|
|
return
|
|
self.value.append(val)
|
|
self.value.append(val)
|
|
else:
|
|
else:
|
|
- self.value = [self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent, namespaceMapping=namespaceMapping)]
|
|
|
|
|
|
+ self.value = [self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent)]
|
|
|
|
|
|
- def __parseXMLSingleValue(self, xmlvalue, parentDataTypeNode, parent, namespaceMapping, alias=None, encodingPart=None, valueRank=None):
|
|
|
|
|
|
+ def __parseXMLSingleValue(self, xmlvalue, parentDataTypeNode, parent, alias=None, encodingPart=None, valueRank=None):
|
|
# Parse an encoding list such as enc = [[Int32], ['Duration', ['DateTime']]],
|
|
# Parse an encoding list such as enc = [[Int32], ['Duration', ['DateTime']]],
|
|
# returning a possibly aliased variable or list of variables.
|
|
# returning a possibly aliased variable or list of variables.
|
|
# Keep track of aliases, as ['Duration', ['Hawaii', ['UtcTime', ['DateTime']]]]
|
|
# Keep track of aliases, as ['Duration', ['Hawaii', ['UtcTime', ['DateTime']]]]
|
|
@@ -198,26 +198,25 @@ class Value(object):
|
|
if not el.nodeType == el.ELEMENT_NODE:
|
|
if not el.nodeType == el.ELEMENT_NODE:
|
|
continue
|
|
continue
|
|
val = self.getTypeByString(enc[0], enc)
|
|
val = self.getTypeByString(enc[0], enc)
|
|
- val.parseXML(el, namespaceMapping=namespaceMapping)
|
|
|
|
|
|
+ val.parseXML(el)
|
|
values.append(val)
|
|
values.append(val)
|
|
return values
|
|
return values
|
|
else:
|
|
else:
|
|
if xmlvalue is not None:
|
|
if xmlvalue is not None:
|
|
- t.parseXML(xmlvalue, namespaceMapping=namespaceMapping)
|
|
|
|
|
|
+ t.parseXML(xmlvalue)
|
|
return t
|
|
return t
|
|
else:
|
|
else:
|
|
if not valueIsInternalType(xmlvalue.localName):
|
|
if not valueIsInternalType(xmlvalue.localName):
|
|
logger.error(str(parent.id) + ": Expected XML describing builtin type " + enc[0] + " but found " + xmlvalue.localName + " instead")
|
|
logger.error(str(parent.id) + ": Expected XML describing builtin type " + enc[0] + " but found " + xmlvalue.localName + " instead")
|
|
else:
|
|
else:
|
|
t = self.getTypeByString(enc[0], enc)
|
|
t = self.getTypeByString(enc[0], enc)
|
|
- t.parseXML(xmlvalue, namespaceMapping=namespaceMapping)
|
|
|
|
|
|
+ t.parseXML(xmlvalue)
|
|
t.isInternal = True
|
|
t.isInternal = True
|
|
return t
|
|
return t
|
|
else:
|
|
else:
|
|
# 1: ['Alias', [...], n]
|
|
# 1: ['Alias', [...], n]
|
|
# Let the next elif handle this
|
|
# Let the next elif handle this
|
|
return self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent,
|
|
return self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent,
|
|
- namespaceMapping=namespaceMapping,
|
|
|
|
alias=alias, encodingPart=enc[0], valueRank=enc[2] if len(enc)>2 else None)
|
|
alias=alias, encodingPart=enc[0], valueRank=enc[2] if len(enc)>2 else None)
|
|
elif len(enc) == 3 and isinstance(enc[0], string_types):
|
|
elif len(enc) == 3 and isinstance(enc[0], string_types):
|
|
# [ 'Alias', [...], 0 ] aliased multipart
|
|
# [ 'Alias', [...], 0 ] aliased multipart
|
|
@@ -228,7 +227,6 @@ class Value(object):
|
|
alias = enc[0]
|
|
alias = enc[0]
|
|
# otherwise drop the alias
|
|
# otherwise drop the alias
|
|
return self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent,
|
|
return self.__parseXMLSingleValue(xmlvalue, parentDataTypeNode, parent,
|
|
- namespaceMapping=namespaceMapping,
|
|
|
|
alias=alias, encodingPart=enc[1], valueRank=enc[2] if len(enc)>2 else None)
|
|
alias=alias, encodingPart=enc[1], valueRank=enc[2] if len(enc)>2 else None)
|
|
else:
|
|
else:
|
|
# [ [...], [...], [...]] multifield of unknowns (analyse separately)
|
|
# [ [...], [...], [...]] multifield of unknowns (analyse separately)
|
|
@@ -286,7 +284,8 @@ class Value(object):
|
|
|
|
|
|
extobj.value = []
|
|
extobj.value = []
|
|
for e in enc:
|
|
for e in enc:
|
|
- extobj.value.append(extobj.__parseXMLSingleValue(ebodypart, parentDataTypeNode, parent, namespaceMapping=namespaceMapping, alias=None, encodingPart=e))
|
|
|
|
|
|
+ extobj.value.append(extobj.__parseXMLSingleValue(ebodypart, parentDataTypeNode, parent,
|
|
|
|
+ alias=None, encodingPart=e))
|
|
ebodypart = getNextElementNode(ebodypart)
|
|
ebodypart = getNextElementNode(ebodypart)
|
|
return extobj
|
|
return extobj
|
|
|
|
|
|
@@ -320,7 +319,7 @@ class Boolean(Value):
|
|
if xmlelement:
|
|
if xmlelement:
|
|
self.parseXML(xmlelement)
|
|
self.parseXML(xmlelement)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
# Expect <Boolean>value</Boolean> or
|
|
# Expect <Boolean>value</Boolean> or
|
|
# <Aliasname>value</Aliasname>
|
|
# <Aliasname>value</Aliasname>
|
|
self.checkXML(xmlvalue)
|
|
self.checkXML(xmlvalue)
|
|
@@ -339,7 +338,7 @@ class Number(Value):
|
|
if xmlelement:
|
|
if xmlelement:
|
|
self.parseXML(xmlelement)
|
|
self.parseXML(xmlelement)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
# Expect <Int16>value</Int16> or any other valid number type, or
|
|
# Expect <Int16>value</Int16> or any other valid number type, or
|
|
# <Aliasname>value</Aliasname>
|
|
# <Aliasname>value</Aliasname>
|
|
self.checkXML(xmlvalue)
|
|
self.checkXML(xmlvalue)
|
|
@@ -412,7 +411,7 @@ class Float(Number):
|
|
if xmlelement:
|
|
if xmlelement:
|
|
Float.parseXML(self, xmlelement)
|
|
Float.parseXML(self, xmlelement)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
# Expect <Float>value</Float> or
|
|
# Expect <Float>value</Float> or
|
|
# <Aliasname>value</Aliasname>
|
|
# <Aliasname>value</Aliasname>
|
|
self.checkXML(xmlvalue)
|
|
self.checkXML(xmlvalue)
|
|
@@ -436,7 +435,7 @@ class String(Value):
|
|
bin = bin + str(self.value)
|
|
bin = bin + str(self.value)
|
|
return bin
|
|
return bin
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
# Expect <String>value</String> or
|
|
# Expect <String>value</String> or
|
|
# <Aliasname>value</Aliasname>
|
|
# <Aliasname>value</Aliasname>
|
|
if not isinstance(xmlvalue, dom.Element):
|
|
if not isinstance(xmlvalue, dom.Element):
|
|
@@ -455,7 +454,7 @@ class ByteString(Value):
|
|
def __init__(self, xmlelement=None):
|
|
def __init__(self, xmlelement=None):
|
|
Value.__init__(self)
|
|
Value.__init__(self)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
# Expect <ByteString>value</ByteString>
|
|
# Expect <ByteString>value</ByteString>
|
|
if not isinstance(xmlvalue, dom.Element):
|
|
if not isinstance(xmlvalue, dom.Element):
|
|
self.value = xmlvalue
|
|
self.value = xmlvalue
|
|
@@ -472,7 +471,7 @@ class ExtensionObject(Value):
|
|
if xmlelement:
|
|
if xmlelement:
|
|
self.parseXML(xmlelement)
|
|
self.parseXML(xmlelement)
|
|
|
|
|
|
- def parseXML(self, xmlelement, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlelement):
|
|
pass
|
|
pass
|
|
|
|
|
|
def __str__(self):
|
|
def __str__(self):
|
|
@@ -486,7 +485,7 @@ class LocalizedText(Value):
|
|
if xmlvalue:
|
|
if xmlvalue:
|
|
self.parseXML(xmlvalue)
|
|
self.parseXML(xmlvalue)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
# Expect <LocalizedText> or <AliasName>
|
|
# Expect <LocalizedText> or <AliasName>
|
|
# <Locale>xx_XX</Locale>
|
|
# <Locale>xx_XX</Locale>
|
|
# <Text>TextText</Text>
|
|
# <Text>TextText</Text>
|
|
@@ -553,7 +552,8 @@ class NodeId(Value):
|
|
else:
|
|
else:
|
|
raise Exception("no valid nodeid: " + idstring)
|
|
raise Exception("no valid nodeid: " + idstring)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ # The parsing can be called with an optional namespace mapping dict.
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
# Expect <NodeId> or <Alias>
|
|
# Expect <NodeId> or <Alias>
|
|
# <Identifier> # It is unclear whether or not this is manditory. Identifier tags are used in Namespace 0.
|
|
# <Identifier> # It is unclear whether or not this is manditory. Identifier tags are used in Namespace 0.
|
|
# ns=x;i=y or similar string representation of id()
|
|
# ns=x;i=y or similar string representation of id()
|
|
@@ -573,8 +573,6 @@ class NodeId(Value):
|
|
if len(xmlvalue.getElementsByTagName("Identifier")) != 0:
|
|
if len(xmlvalue.getElementsByTagName("Identifier")) != 0:
|
|
xmlvalue = xmlvalue.getElementsByTagName("Identifier")[0]
|
|
xmlvalue = xmlvalue.getElementsByTagName("Identifier")[0]
|
|
self.setFromIdString(unicode(xmlvalue.firstChild.data))
|
|
self.setFromIdString(unicode(xmlvalue.firstChild.data))
|
|
- if namespaceMapping is not None:
|
|
|
|
- self.ns = namespaceMapping[self.ns]
|
|
|
|
|
|
|
|
def __str__(self):
|
|
def __str__(self):
|
|
s = "ns=" + str(self.ns) + ";"
|
|
s = "ns=" + str(self.ns) + ";"
|
|
@@ -615,7 +613,7 @@ class ExpandedNodeId(Value):
|
|
if xmlelement:
|
|
if xmlelement:
|
|
self.parseXML(xmlelement)
|
|
self.parseXML(xmlelement)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
self.checkXML(xmlvalue)
|
|
self.checkXML(xmlvalue)
|
|
logger.debug("Not implemented", LOG_LEVEL_ERR)
|
|
logger.debug("Not implemented", LOG_LEVEL_ERR)
|
|
|
|
|
|
@@ -625,7 +623,7 @@ class DateTime(Value):
|
|
if xmlelement:
|
|
if xmlelement:
|
|
self.parseXML(xmlelement)
|
|
self.parseXML(xmlelement)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
# Expect <DateTime> or <AliasName>
|
|
# Expect <DateTime> or <AliasName>
|
|
# 2013-08-13T21:00:05.0000L
|
|
# 2013-08-13T21:00:05.0000L
|
|
# </DateTime> or </AliasName>
|
|
# </DateTime> or </AliasName>
|
|
@@ -661,7 +659,7 @@ class QualifiedName(Value):
|
|
if xmlelement:
|
|
if xmlelement:
|
|
self.parseXML(xmlelement)
|
|
self.parseXML(xmlelement)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
# Expect <QualifiedName> or <AliasName>
|
|
# Expect <QualifiedName> or <AliasName>
|
|
# <NamespaceIndex>Int16<NamespaceIndex>
|
|
# <NamespaceIndex>Int16<NamespaceIndex>
|
|
# <Name>SomeString<Name>
|
|
# <Name>SomeString<Name>
|
|
@@ -673,16 +671,12 @@ class QualifiedName(Value):
|
|
else:
|
|
else:
|
|
self.name = xmlvalue[colonindex + 1:]
|
|
self.name = xmlvalue[colonindex + 1:]
|
|
self.ns = int(xmlvalue[:colonindex])
|
|
self.ns = int(xmlvalue[:colonindex])
|
|
- if namespaceMapping is not None:
|
|
|
|
- self.ns = namespaceMapping[self.ns]
|
|
|
|
return
|
|
return
|
|
|
|
|
|
self.checkXML(xmlvalue)
|
|
self.checkXML(xmlvalue)
|
|
# Is a namespace index passed?
|
|
# Is a namespace index passed?
|
|
if len(xmlvalue.getElementsByTagName("NamespaceIndex")) != 0:
|
|
if len(xmlvalue.getElementsByTagName("NamespaceIndex")) != 0:
|
|
self.ns = int(xmlvalue.getElementsByTagName("NamespaceIndex")[0].firstChild.data)
|
|
self.ns = int(xmlvalue.getElementsByTagName("NamespaceIndex")[0].firstChild.data)
|
|
- if namespaceMapping is not None:
|
|
|
|
- self.ns = namespaceMapping[self.ns]
|
|
|
|
if len(xmlvalue.getElementsByTagName("Name")) != 0:
|
|
if len(xmlvalue.getElementsByTagName("Name")) != 0:
|
|
self.name = xmlvalue.getElementsByTagName("Name")[0].firstChild.data
|
|
self.name = xmlvalue.getElementsByTagName("Name")[0].firstChild.data
|
|
|
|
|
|
@@ -703,7 +697,7 @@ class DiagnosticInfo(Value):
|
|
if xmlelement:
|
|
if xmlelement:
|
|
self.parseXML(xmlelement)
|
|
self.parseXML(xmlelement)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
self.checkXML(xmlvalue)
|
|
self.checkXML(xmlvalue)
|
|
logger.warn("Not implemented")
|
|
logger.warn("Not implemented")
|
|
|
|
|
|
@@ -713,7 +707,7 @@ class Guid(Value):
|
|
if xmlelement:
|
|
if xmlelement:
|
|
self.parseXML(xmlelement)
|
|
self.parseXML(xmlelement)
|
|
|
|
|
|
- def parseXML(self, xmlvalue, namespaceMapping=None):
|
|
|
|
|
|
+ def parseXML(self, xmlvalue):
|
|
self.checkXML(xmlvalue)
|
|
self.checkXML(xmlvalue)
|
|
|
|
|
|
val = getXmlTextTrimmed(xmlvalue.firstChild)
|
|
val = getXmlTextTrimmed(xmlvalue.firstChild)
|