| @@ -1270,91 +1270,91 @@ if 1: | |||||
| if 1: | if 1: | ||||
| def _clone_node(node, deep, newOwnerDocument): | def _clone_node(node, deep, newOwnerDocument): | ||||
| """ | |||||
| Clone a node and give it the new owner document. | |||||
| Called by Node.cloneNode and Document.importNode | |||||
| """ | |||||
| if node.ownerDocument.isSameNode(newOwnerDocument): | |||||
| operation = xml.dom.UserDataHandler.NODE_CLONED | |||||
| else: | |||||
| operation = xml.dom.UserDataHandler.NODE_IMPORTED | |||||
| if node.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: | |||||
| clone = newOwnerDocument.createElementNS(node.namespaceURI, | |||||
| node.nodeName) | |||||
| for attr in node.attributes.values(): | |||||
| clone.setAttributeNS(attr.namespaceURI, attr.nodeName, attr.value) | |||||
| prefix, tag = xml.dom.minidom._nssplit(attr.nodeName) | |||||
| if prefix == 'xmlns': | |||||
| a = clone.getAttributeNodeNS(attr.namespaceURI, tag) | |||||
| elif prefix: | |||||
| a = clone.getAttributeNodeNS(attr.namespaceURI, tag) | |||||
| else: | |||||
| a = clone.getAttributeNodeNS(attr.namespaceURI, attr.nodeName) | |||||
| a.specified = attr.specified | |||||
| if deep: | |||||
| for child in node.childNodes: | |||||
| c = xml.dom.minidom._clone_node(child, deep, newOwnerDocument) | |||||
| clone.appendChild(c) | |||||
| elif node.nodeType == xml.dom.minidom.Node.DOCUMENT_FRAGMENT_NODE: | |||||
| clone = newOwnerDocument.createDocumentFragment() | |||||
| if deep: | |||||
| for child in node.childNodes: | |||||
| c = xml.dom.minidom._clone_node(child, deep, newOwnerDocument) | |||||
| clone.appendChild(c) | |||||
| elif node.nodeType == xml.dom.minidom.Node.TEXT_NODE: | |||||
| clone = newOwnerDocument.createTextNode(node.data) | |||||
| elif node.nodeType == xml.dom.minidom.Node.CDATA_SECTION_NODE: | |||||
| clone = newOwnerDocument.createCDATASection(node.data) | |||||
| elif node.nodeType == xml.dom.minidom.Node.PROCESSING_INSTRUCTION_NODE: | |||||
| clone = newOwnerDocument.createProcessingInstruction(node.target, | |||||
| node.data) | |||||
| elif node.nodeType == xml.dom.minidom.Node.COMMENT_NODE: | |||||
| clone = newOwnerDocument.createComment(node.data) | |||||
| elif node.nodeType == xml.dom.minidom.Node.ATTRIBUTE_NODE: | |||||
| clone = newOwnerDocument.createAttributeNS(node.namespaceURI, | |||||
| node.nodeName) | |||||
| clone.specified = True | |||||
| clone.value = node.value | |||||
| elif node.nodeType == xml.dom.minidom.Node.DOCUMENT_TYPE_NODE: | |||||
| assert node.ownerDocument is not newOwnerDocument | |||||
| operation = xml.dom.UserDataHandler.NODE_IMPORTED | |||||
| clone = newOwnerDocument.implementation.createDocumentType( | |||||
| node.name, node.publicId, node.systemId) | |||||
| clone.ownerDocument = newOwnerDocument | |||||
| if deep: | |||||
| clone.entities._seq = [] | |||||
| clone.notations._seq = [] | |||||
| for n in node.notations._seq: | |||||
| notation = xml.dom.minidom.Notation(n.nodeName, n.publicId, n.systemId) | |||||
| notation.ownerDocument = newOwnerDocument | |||||
| clone.notations._seq.append(notation) | |||||
| if hasattr(n, '_call_user_data_handler'): | |||||
| n._call_user_data_handler(operation, n, notation) | |||||
| for e in node.entities._seq: | |||||
| entity = xml.dom.minidom.Entity(e.nodeName, e.publicId, e.systemId, | |||||
| e.notationName) | |||||
| entity.actualEncoding = e.actualEncoding | |||||
| entity.encoding = e.encoding | |||||
| entity.version = e.version | |||||
| entity.ownerDocument = newOwnerDocument | |||||
| clone.entities._seq.append(entity) | |||||
| if hasattr(e, '_call_user_data_handler'): | |||||
| e._call_user_data_handler(operation, n, entity) | |||||
| else: | |||||
| # Note the cloning of Document and DocumentType nodes is | |||||
| # implemenetation specific. minidom handles those cases | |||||
| # directly in the cloneNode() methods. | |||||
| raise xml.dom.NotSupportedErr("Cannot clone node %s" % repr(node)) | |||||
| # Check for _call_user_data_handler() since this could conceivably | |||||
| # used with other DOM implementations (one of the FourThought | |||||
| # DOMs, perhaps?). | |||||
| if hasattr(node, '_call_user_data_handler'): | |||||
| node._call_user_data_handler(operation, node, clone) | |||||
| return clone | |||||
| """ | |||||
| Clone a node and give it the new owner document. | |||||
| Called by Node.cloneNode and Document.importNode | |||||
| """ | |||||
| if node.ownerDocument.isSameNode(newOwnerDocument): | |||||
| operation = xml.dom.UserDataHandler.NODE_CLONED | |||||
| else: | |||||
| operation = xml.dom.UserDataHandler.NODE_IMPORTED | |||||
| if node.nodeType == xml.dom.minidom.Node.ELEMENT_NODE: | |||||
| clone = newOwnerDocument.createElementNS(node.namespaceURI, | |||||
| node.nodeName) | |||||
| for attr in node.attributes.values(): | |||||
| clone.setAttributeNS(attr.namespaceURI, attr.nodeName, attr.value) | |||||
| prefix, tag = xml.dom.minidom._nssplit(attr.nodeName) | |||||
| if prefix == 'xmlns': | |||||
| a = clone.getAttributeNodeNS(attr.namespaceURI, tag) | |||||
| elif prefix: | |||||
| a = clone.getAttributeNodeNS(attr.namespaceURI, tag) | |||||
| else: | |||||
| a = clone.getAttributeNodeNS(attr.namespaceURI, attr.nodeName) | |||||
| a.specified = attr.specified | |||||
| if deep: | |||||
| for child in node.childNodes: | |||||
| c = xml.dom.minidom._clone_node(child, deep, newOwnerDocument) | |||||
| clone.appendChild(c) | |||||
| elif node.nodeType == xml.dom.minidom.Node.DOCUMENT_FRAGMENT_NODE: | |||||
| clone = newOwnerDocument.createDocumentFragment() | |||||
| if deep: | |||||
| for child in node.childNodes: | |||||
| c = xml.dom.minidom._clone_node(child, deep, newOwnerDocument) | |||||
| clone.appendChild(c) | |||||
| elif node.nodeType == xml.dom.minidom.Node.TEXT_NODE: | |||||
| clone = newOwnerDocument.createTextNode(node.data) | |||||
| elif node.nodeType == xml.dom.minidom.Node.CDATA_SECTION_NODE: | |||||
| clone = newOwnerDocument.createCDATASection(node.data) | |||||
| elif node.nodeType == xml.dom.minidom.Node.PROCESSING_INSTRUCTION_NODE: | |||||
| clone = newOwnerDocument.createProcessingInstruction(node.target, | |||||
| node.data) | |||||
| elif node.nodeType == xml.dom.minidom.Node.COMMENT_NODE: | |||||
| clone = newOwnerDocument.createComment(node.data) | |||||
| elif node.nodeType == xml.dom.minidom.Node.ATTRIBUTE_NODE: | |||||
| clone = newOwnerDocument.createAttributeNS(node.namespaceURI, | |||||
| node.nodeName) | |||||
| clone.specified = True | |||||
| clone.value = node.value | |||||
| elif node.nodeType == xml.dom.minidom.Node.DOCUMENT_TYPE_NODE: | |||||
| assert node.ownerDocument is not newOwnerDocument | |||||
| operation = xml.dom.UserDataHandler.NODE_IMPORTED | |||||
| clone = newOwnerDocument.implementation.createDocumentType( | |||||
| node.name, node.publicId, node.systemId) | |||||
| clone.ownerDocument = newOwnerDocument | |||||
| if deep: | |||||
| clone.entities._seq = [] | |||||
| clone.notations._seq = [] | |||||
| for n in node.notations._seq: | |||||
| notation = xml.dom.minidom.Notation(n.nodeName, n.publicId, n.systemId) | |||||
| notation.ownerDocument = newOwnerDocument | |||||
| clone.notations._seq.append(notation) | |||||
| if hasattr(n, '_call_user_data_handler'): | |||||
| n._call_user_data_handler(operation, n, notation) | |||||
| for e in node.entities._seq: | |||||
| entity = xml.dom.minidom.Entity(e.nodeName, e.publicId, e.systemId, | |||||
| e.notationName) | |||||
| entity.actualEncoding = e.actualEncoding | |||||
| entity.encoding = e.encoding | |||||
| entity.version = e.version | |||||
| entity.ownerDocument = newOwnerDocument | |||||
| clone.entities._seq.append(entity) | |||||
| if hasattr(e, '_call_user_data_handler'): | |||||
| e._call_user_data_handler(operation, n, entity) | |||||
| else: | |||||
| # Note the cloning of Document and DocumentType nodes is | |||||
| # implemenetation specific. minidom handles those cases | |||||
| # directly in the cloneNode() methods. | |||||
| raise xml.dom.NotSupportedErr("Cannot clone node %s" % repr(node)) | |||||
| # Check for _call_user_data_handler() since this could conceivably | |||||
| # used with other DOM implementations (one of the FourThought | |||||
| # DOMs, perhaps?). | |||||
| if hasattr(node, '_call_user_data_handler'): | |||||
| node._call_user_data_handler(operation, node, clone) | |||||
| return clone | |||||
| xml.dom.minidom._clone_node = _clone_node | xml.dom.minidom._clone_node = _clone_node | ||||
| @@ -1823,24 +1823,24 @@ If attribute is None, "type" is assumed, return the corresponding | |||||
| self.annotation = Annotation(self) | self.annotation = Annotation(self) | ||||
| self.annotation.fromDom(i) | self.annotation.fromDom(i) | ||||
| elif component == 'simpleType' and not self.content: | elif component == 'simpleType' and not self.content: | ||||
| self.content = AnonymousSimpleType(self) | |||||
| self.content = AnonymousSimpleType(self) | |||||
| self.content.fromDom(i) | self.content.fromDom(i) | ||||
| elif component == 'complexType' and not self.content: | elif component == 'complexType' and not self.content: | ||||
| self.content = LocalComplexType(self) | |||||
| self.content = LocalComplexType(self) | |||||
| self.content.fromDom(i) | self.content.fromDom(i) | ||||
| elif component == 'key': | elif component == 'key': | ||||
| constraints.append(Key(self)) | |||||
| constraints[-1].fromDom(i) | |||||
| constraints.append(Key(self)) | |||||
| constraints[-1].fromDom(i) | |||||
| elif component == 'keyref': | elif component == 'keyref': | ||||
| constraints.append(KeyRef(self)) | |||||
| constraints[-1].fromDom(i) | |||||
| constraints.append(KeyRef(self)) | |||||
| constraints[-1].fromDom(i) | |||||
| elif component == 'unique': | elif component == 'unique': | ||||
| constraints.append(Unique(self)) | |||||
| constraints[-1].fromDom(i) | |||||
| constraints.append(Unique(self)) | |||||
| constraints[-1].fromDom(i) | |||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| self.constraints = constraints | self.constraints = constraints | ||||
| @@ -1890,7 +1890,7 @@ Local elements can be qualified or unqualifed according | |||||
| return True | return True | ||||
| if form == 'unqualified': | if form == 'unqualified': | ||||
| return False | return False | ||||
| raise SchemaError, 'Bad form (%s) for element: %s' %(form, self.getItemTrace()) | |||||
| raise SchemaError, 'Bad form (%s) for element: %s' %(form, self.getItemTrace()) | |||||
| class ElementReference(XMLSchemaComponent,\ | class ElementReference(XMLSchemaComponent,\ | ||||
| @@ -1938,7 +1938,7 @@ class ElementReference(XMLSchemaComponent,\ | |||||
| self.annotation = Annotation(self) | self.annotation = Annotation(self) | ||||
| self.annotation.fromDom(i) | self.annotation.fromDom(i) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| class ElementWildCard(LocalElementDeclaration, WildCardMarker): | class ElementWildCard(LocalElementDeclaration, WildCardMarker): | ||||
| @@ -1988,7 +1988,7 @@ class ElementWildCard(LocalElementDeclaration, WildCardMarker): | |||||
| self.annotation = Annotation(self) | self.annotation = Annotation(self) | ||||
| self.annotation.fromDom(i) | self.annotation.fromDom(i) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| ###################################################### | ###################################################### | ||||
| @@ -2033,22 +2033,22 @@ class Sequence(XMLSchemaComponent,\ | |||||
| continue | continue | ||||
| elif component == 'element': | elif component == 'element': | ||||
| if i.hasattr('ref'): | if i.hasattr('ref'): | ||||
| content.append(ElementReference(self)) | |||||
| content.append(ElementReference(self)) | |||||
| else: | else: | ||||
| content.append(LocalElementDeclaration(self)) | |||||
| content.append(LocalElementDeclaration(self)) | |||||
| elif component == 'group': | elif component == 'group': | ||||
| content.append(ModelGroupReference(self)) | |||||
| content.append(ModelGroupReference(self)) | |||||
| elif component == 'choice': | elif component == 'choice': | ||||
| content.append(Choice(self)) | |||||
| content.append(Choice(self)) | |||||
| elif component == 'sequence': | elif component == 'sequence': | ||||
| content.append(Sequence(self)) | |||||
| content.append(Sequence(self)) | |||||
| elif component == 'any': | elif component == 'any': | ||||
| content.append(ElementWildCard(self)) | |||||
| content.append(ElementWildCard(self)) | |||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| content[-1].fromDom(i) | content[-1].fromDom(i) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| self.content = tuple(content) | self.content = tuple(content) | ||||
| @@ -2090,14 +2090,14 @@ class All(XMLSchemaComponent,\ | |||||
| continue | continue | ||||
| elif component == 'element': | elif component == 'element': | ||||
| if i.hasattr('ref'): | if i.hasattr('ref'): | ||||
| content.append(ElementReference(self)) | |||||
| content.append(ElementReference(self)) | |||||
| else: | else: | ||||
| content.append(LocalElementDeclaration(self)) | |||||
| content.append(LocalElementDeclaration(self)) | |||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| content[-1].fromDom(i) | content[-1].fromDom(i) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| self.content = tuple(content) | self.content = tuple(content) | ||||
| @@ -2140,22 +2140,22 @@ class Choice(XMLSchemaComponent,\ | |||||
| continue | continue | ||||
| elif component == 'element': | elif component == 'element': | ||||
| if i.hasattr('ref'): | if i.hasattr('ref'): | ||||
| content.append(ElementReference(self)) | |||||
| content.append(ElementReference(self)) | |||||
| else: | else: | ||||
| content.append(LocalElementDeclaration(self)) | |||||
| content.append(LocalElementDeclaration(self)) | |||||
| elif component == 'group': | elif component == 'group': | ||||
| content.append(ModelGroupReference(self)) | |||||
| content.append(ModelGroupReference(self)) | |||||
| elif component == 'choice': | elif component == 'choice': | ||||
| content.append(Choice(self)) | |||||
| content.append(Choice(self)) | |||||
| elif component == 'sequence': | elif component == 'sequence': | ||||
| content.append(Sequence(self)) | |||||
| content.append(Sequence(self)) | |||||
| elif component == 'any': | elif component == 'any': | ||||
| content.append(ElementWildCard(self)) | |||||
| content.append(ElementWildCard(self)) | |||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| content[-1].fromDom(i) | content[-1].fromDom(i) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| self.content = tuple(content) | self.content = tuple(content) | ||||
| @@ -2201,10 +2201,10 @@ class ModelGroupDefinition(XMLSchemaComponent,\ | |||||
| elif component == 'sequence' and not self.content: | elif component == 'sequence' and not self.content: | ||||
| self.content = Sequence(self) | self.content = Sequence(self) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| self.content.fromDom(i) | self.content.fromDom(i) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| class ModelGroupReference(XMLSchemaComponent,\ | class ModelGroupReference(XMLSchemaComponent,\ | ||||
| @@ -2248,9 +2248,9 @@ class ModelGroupReference(XMLSchemaComponent,\ | |||||
| self.annotation = Annotation(self) | self.annotation = Annotation(self) | ||||
| self.annotation.fromDom(i) | self.annotation.fromDom(i) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| @@ -2364,13 +2364,13 @@ class ComplexType(XMLSchemaComponent,\ | |||||
| elif component == 'anyAttribute': | elif component == 'anyAttribute': | ||||
| self.attr_content.append(AttributeWildCard(self)) | self.attr_content.append(AttributeWildCard(self)) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s): %s' \ | |||||
| raise SchemaError, 'Unknown component (%s): %s' \ | |||||
| %(contents[indx].getTagName(),self.getItemTrace()) | %(contents[indx].getTagName(),self.getItemTrace()) | ||||
| self.attr_content[-1].fromDom(contents[indx]) | self.attr_content[-1].fromDom(contents[indx]) | ||||
| indx += 1 | indx += 1 | ||||
| class _DerivedType(XMLSchemaComponent): | class _DerivedType(XMLSchemaComponent): | ||||
| def __init__(self, parent): | |||||
| def __init__(self, parent): | |||||
| XMLSchemaComponent.__init__(self, parent) | XMLSchemaComponent.__init__(self, parent) | ||||
| self.annotation = None | self.annotation = None | ||||
| # XXX remove attribute derivation, inconsistent | # XXX remove attribute derivation, inconsistent | ||||
| @@ -2393,9 +2393,9 @@ class ComplexType(XMLSchemaComponent,\ | |||||
| elif component == 'extension' and not self.derivation: | elif component == 'extension' and not self.derivation: | ||||
| self.derivation = self.__class__.Extension(self) | self.derivation = self.__class__.Extension(self) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) | |||||
| self.derivation.fromDom(i) | self.derivation.fromDom(i) | ||||
| self.content = self.derivation | self.content = self.derivation | ||||
| @@ -2488,7 +2488,7 @@ class ComplexType(XMLSchemaComponent,\ | |||||
| self.content.fromDom(contents[indx]) | self.content.fromDom(contents[indx]) | ||||
| indx += 1 | indx += 1 | ||||
| else: | else: | ||||
| self.content = None | |||||
| self.content = None | |||||
| self.attr_content = [] | self.attr_content = [] | ||||
| while indx < num: | while indx < num: | ||||
| @@ -2506,7 +2506,7 @@ class ComplexType(XMLSchemaComponent,\ | |||||
| elif component == 'anyAttribute': | elif component == 'anyAttribute': | ||||
| self.attr_content.append(AttributeWildCard(self)) | self.attr_content.append(AttributeWildCard(self)) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)' %(contents[indx].getTagName()) | |||||
| raise SchemaError, 'Unknown component (%s)' %(contents[indx].getTagName()) | |||||
| self.attr_content[-1].fromDom(contents[indx]) | self.attr_content[-1].fromDom(contents[indx]) | ||||
| indx += 1 | indx += 1 | ||||
| @@ -2575,7 +2575,7 @@ class ComplexType(XMLSchemaComponent,\ | |||||
| 'anyAttribute']} | 'anyAttribute']} | ||||
| tag = 'extension' | tag = 'extension' | ||||
| def __init__(self, parent): | |||||
| def __init__(self, parent): | |||||
| XMLSchemaComponent.__init__(self, parent) | XMLSchemaComponent.__init__(self, parent) | ||||
| self.annotation = None | self.annotation = None | ||||
| self.attr_content = None | self.attr_content = None | ||||
| @@ -2611,7 +2611,7 @@ class ComplexType(XMLSchemaComponent,\ | |||||
| elif component == 'anyAttribute': | elif component == 'anyAttribute': | ||||
| content.append(AttributeWildCard(self)) | content.append(AttributeWildCard(self)) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)'\ | |||||
| raise SchemaError, 'Unknown component (%s)'\ | |||||
| %(contents[indx].getTagName()) | %(contents[indx].getTagName()) | ||||
| content[-1].fromDom(contents[indx]) | content[-1].fromDom(contents[indx]) | ||||
| indx += 1 | indx += 1 | ||||
| @@ -2641,7 +2641,7 @@ class ComplexType(XMLSchemaComponent,\ | |||||
| 'attributeGroup', 'anyAttribute'] + RestrictionMarker.facets} | 'attributeGroup', 'anyAttribute'] + RestrictionMarker.facets} | ||||
| tag = 'restriction' | tag = 'restriction' | ||||
| def __init__(self, parent): | |||||
| def __init__(self, parent): | |||||
| XMLSchemaComponent.__init__(self, parent) | XMLSchemaComponent.__init__(self, parent) | ||||
| self.annotation = None | self.annotation = None | ||||
| self.content = None | self.content = None | ||||
| @@ -2680,7 +2680,7 @@ class ComplexType(XMLSchemaComponent,\ | |||||
| self.content.append(AnonymousSimpleType(self)) | self.content.append(AnonymousSimpleType(self)) | ||||
| self.content[-1].fromDom(contents[indx]) | self.content[-1].fromDom(contents[indx]) | ||||
| else: | else: | ||||
| raise SchemaError, 'Unknown component (%s)'\ | |||||
| raise SchemaError, 'Unknown component (%s)'\ | |||||
| %(contents[indx].getTagName()) | %(contents[indx].getTagName()) | ||||
| content[-1].fromDom(contents[indx]) | content[-1].fromDom(contents[indx]) | ||||
| indx += 1 | indx += 1 | ||||
| @@ -2968,3 +2968,4 @@ class TypeDescriptionComponent(tupleClass): | |||||
| def getName(self): | def getName(self): | ||||
| return self[1] | return self[1] | ||||
| @@ -80,7 +80,7 @@ else: | |||||
| # xml_attrs -- Attributes in XML namespace from parent | # xml_attrs -- Attributes in XML namespace from parent | ||||
| # xml_attrs_local -- Local attributes in XML namespace. | # xml_attrs_local -- Local attributes in XML namespace. | ||||
| ns_parent, ns_rendered, xml_attrs = \ | ns_parent, ns_rendered, xml_attrs = \ | ||||
| self.state[0], self.state[1].copy(), self.state[2].copy() #0422 | |||||
| self.state[0], self.state[1].copy(), self.state[2].copy() #0422 | |||||
| ns_local = ns_parent.copy() | ns_local = ns_parent.copy() | ||||
| xml_attrs_local = {} | xml_attrs_local = {} | ||||
| @@ -94,50 +94,50 @@ else: | |||||
| sort_these_attrs +=c14n._attrs(node) | sort_these_attrs +=c14n._attrs(node) | ||||
| for a in sort_these_attrs: | for a in sort_these_attrs: | ||||
| if a.namespaceURI == c14n.XMLNS.BASE: | |||||
| n = a.nodeName | |||||
| if n == "xmlns:": n = "xmlns" # DOM bug workaround | |||||
| ns_local[n] = a.nodeValue | |||||
| elif a.namespaceURI == c14n.XMLNS.XML: | |||||
| if c14n._inclusive(self) or (in_subset and c14n._in_subset(self.subset, a)): #020925 Test to see if attribute node in subset | |||||
| xml_attrs_local[a.nodeName] = a #0426 | |||||
| else: | |||||
| if c14n._in_subset(self.subset, a): #020925 Test to see if attribute node in subset | |||||
| other_attrs.append(a) | |||||
| #add local xml:foo attributes to ancestor's xml:foo attributes | |||||
| xml_attrs.update(xml_attrs_local) | |||||
| if a.namespaceURI == c14n.XMLNS.BASE: | |||||
| n = a.nodeName | |||||
| if n == "xmlns:": n = "xmlns" # DOM bug workaround | |||||
| ns_local[n] = a.nodeValue | |||||
| elif a.namespaceURI == c14n.XMLNS.XML: | |||||
| if c14n._inclusive(self) or (in_subset and c14n._in_subset(self.subset, a)): #020925 Test to see if attribute node in subset | |||||
| xml_attrs_local[a.nodeName] = a #0426 | |||||
| else: | |||||
| if c14n._in_subset(self.subset, a): #020925 Test to see if attribute node in subset | |||||
| other_attrs.append(a) | |||||
| #add local xml:foo attributes to ancestor's xml:foo attributes | |||||
| xml_attrs.update(xml_attrs_local) | |||||
| # Render the node | # Render the node | ||||
| W, name = self.write, None | W, name = self.write, None | ||||
| if in_subset: | if in_subset: | ||||
| name = node.nodeName | |||||
| W('<') | |||||
| W(name) | |||||
| # Create list of NS attributes to render. | |||||
| ns_to_render = [] | |||||
| for n,v in ns_local.items(): | |||||
| # If default namespace is XMLNS.BASE or empty, | |||||
| # and if an ancestor was the same | |||||
| if n == "xmlns" and v in [ c14n.XMLNS.BASE, '' ] \ | |||||
| and ns_rendered.get('xmlns') in [ c14n.XMLNS.BASE, '', None ]: | |||||
| continue | |||||
| # "omit namespace node with local name xml, which defines | |||||
| # the xml prefix, if its string value is | |||||
| # http://www.w3.org/XML/1998/namespace." | |||||
| if n in ["xmlns:xml", "xml"] \ | |||||
| and v in [ 'http://www.w3.org/XML/1998/namespace' ]: | |||||
| continue | |||||
| # If not previously rendered | |||||
| # and it's inclusive or utilized | |||||
| if (n,v) not in ns_rendered.items() \ | |||||
| and (c14n._inclusive(self) or \ | |||||
| c14n._utilized(n, node, other_attrs, self.unsuppressedPrefixes)): | |||||
| ns_to_render.append((n, v)) | |||||
| name = node.nodeName | |||||
| W('<') | |||||
| W(name) | |||||
| # Create list of NS attributes to render. | |||||
| ns_to_render = [] | |||||
| for n,v in ns_local.items(): | |||||
| # If default namespace is XMLNS.BASE or empty, | |||||
| # and if an ancestor was the same | |||||
| if n == "xmlns" and v in [ c14n.XMLNS.BASE, '' ] \ | |||||
| and ns_rendered.get('xmlns') in [ c14n.XMLNS.BASE, '', None ]: | |||||
| continue | |||||
| # "omit namespace node with local name xml, which defines | |||||
| # the xml prefix, if its string value is | |||||
| # http://www.w3.org/XML/1998/namespace." | |||||
| if n in ["xmlns:xml", "xml"] \ | |||||
| and v in [ 'http://www.w3.org/XML/1998/namespace' ]: | |||||
| continue | |||||
| # If not previously rendered | |||||
| # and it's inclusive or utilized | |||||
| if (n,v) not in ns_rendered.items() \ | |||||
| and (c14n._inclusive(self) or \ | |||||
| c14n._utilized(n, node, other_attrs, self.unsuppressedPrefixes)): | |||||
| ns_to_render.append((n, v)) | |||||
| ##################################### | ##################################### | ||||
| # JRB | # JRB | ||||
| @@ -191,34 +191,34 @@ else: | |||||
| # Sort and render the ns, marking what was rendered. | |||||
| ns_to_render.sort(c14n._sorter_ns) | |||||
| for n,v in ns_to_render: | |||||
| #XXX JRB, getting 'xmlns,None' here when xmlns='' | |||||
| if v: self._do_attr(n, v) | |||||
| else: | |||||
| v = '' | |||||
| self._do_attr(n, v) | |||||
| ns_rendered[n]=v #0417 | |||||
| # If exclusive or the parent is in the subset, add the local xml attributes | |||||
| # Else, add all local and ancestor xml attributes | |||||
| # Sort and render the attributes. | |||||
| if not c14n._inclusive(self) or c14n._in_subset(self.subset,node.parentNode): #0426 | |||||
| other_attrs.extend(xml_attrs_local.values()) | |||||
| else: | |||||
| other_attrs.extend(xml_attrs.values()) | |||||
| # Sort and render the ns, marking what was rendered. | |||||
| ns_to_render.sort(c14n._sorter_ns) | |||||
| for n,v in ns_to_render: | |||||
| #XXX JRB, getting 'xmlns,None' here when xmlns='' | |||||
| if v: self._do_attr(n, v) | |||||
| else: | |||||
| v = '' | |||||
| self._do_attr(n, v) | |||||
| ns_rendered[n]=v #0417 | |||||
| # If exclusive or the parent is in the subset, add the local xml attributes | |||||
| # Else, add all local and ancestor xml attributes | |||||
| # Sort and render the attributes. | |||||
| if not c14n._inclusive(self) or c14n._in_subset(self.subset,node.parentNode): #0426 | |||||
| other_attrs.extend(xml_attrs_local.values()) | |||||
| else: | |||||
| other_attrs.extend(xml_attrs.values()) | |||||
| #print "OTHER: ", other_attrs | #print "OTHER: ", other_attrs | ||||
| other_attrs.sort(c14n._sorter) | |||||
| for a in other_attrs: | |||||
| self._do_attr(a.nodeName, a.value) | |||||
| other_attrs.sort(c14n._sorter) | |||||
| for a in other_attrs: | |||||
| self._do_attr(a.nodeName, a.value) | |||||
| W('>') | W('>') | ||||
| # Push state, recurse, pop state. | # Push state, recurse, pop state. | ||||
| state, self.state = self.state, (ns_local, ns_rendered, xml_attrs) | state, self.state = self.state, (ns_local, ns_rendered, xml_attrs) | ||||
| for c in c14n._children(node): | for c in c14n._children(node): | ||||
| c14n._implementation.handlers[c.nodeType](self, c) | |||||
| c14n._implementation.handlers[c.nodeType](self, c) | |||||
| self.state = state | self.state = state | ||||
| if name: W('</%s>' % name) | if name: W('</%s>' % name) | ||||