From 9e4cfd6932f76b12ce7fc67745eb5d8f090905d1 Mon Sep 17 00:00:00 2001 From: Joshua Boverhof Date: Thu, 7 Aug 2003 04:49:34 +0000 Subject: [PATCH] ---------------------------------------------------------------------- Modified Files: XMLSchema.py -- Modified/Extended some of the element classes. For LocalElementDeclaration inheritance was duplicitous, and for ElementReference it was wrong. ---------------------------------------------------------------------- --- XMLSchema.py | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/XMLSchema.py b/XMLSchema.py index 9494077..b67bb19 100755 --- a/XMLSchema.py +++ b/XMLSchema.py @@ -529,6 +529,9 @@ class MarkerInterface: def isAttributeGroup(self): return isinstance(self, AttributeGroupMarker) + def isElement(self): + return isinstance(self, ElementMarker) + def isReference(self): return isinstance(self, ReferenceMarker) @@ -1570,10 +1573,7 @@ class ElementDeclaration(XMLSchemaComponent,\ self.constraints = tuple(constraints) -class LocalElementDeclaration(ElementDeclaration,\ - MarkerInterface,\ - ElementMarker,\ - DeclarationMarker): +class LocalElementDeclaration(ElementDeclaration): """ parents: all, choice, sequence @@ -1607,7 +1607,7 @@ class LocalElementDeclaration(ElementDeclaration,\ 'keyref', 'unique']} -class ElementReference(ElementDeclaration,\ +class ElementReference(XMLSchemaComponent,\ MarkerInterface,\ ElementMarker,\ ReferenceMarker): @@ -1629,11 +1629,24 @@ class ElementReference(ElementDeclaration,\ 'maxOccurs':'1'} contents = {'xsd':['annotation']} + def __init__(self, parent): + XMLSchemaComponent.__init__(self, parent) + self.annotation = None + def fromDom(self, node): + self.annotation = None + self.setAttributes(node) + for i in self.getContents(node): + component = SplitQName(i.getTagName())[1] + if component in self.__class__.contents['xsd']: + if component == 'annotation' and not self.annotation: + self.annotation = Annotation(self) + self.annotation.fromDom(i) + else: + raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) + + class ElementWildCard(LocalElementDeclaration,\ - MarkerInterface,\ - ElementMarker,\ - DeclarationMarker,\ WildCardMarker): """ parents: @@ -1656,6 +1669,22 @@ class ElementWildCard(LocalElementDeclaration,\ 'processContents':'strict'} contents = {'xsd':['annotation']} + def __init__(self, parent): + XMLSchemaComponent.__init__(self, parent) + self.annotation = None + + def fromDom(self, node): + self.annotation = None + self.setAttributes(node) + for i in self.getContents(node): + component = SplitQName(i.getTagName())[1] + if component in self.__class__.contents['xsd']: + if component == 'annotation' and not self.annotation: + self.annotation = Annotation(self) + self.annotation.fromDom(i) + else: + raise SchemaError, 'Unknown component (%s)' %(i.getTagName()) + ###################################################### # Model Groups