Browse Source

----------------------------------------------------------------------

Modified Files:
 	XMLSchema.py -- Modified/Extended some of the element classes.
		For LocalElementDeclaration inheritance was duplicitous,
                and for ElementReference it was wrong.

 ----------------------------------------------------------------------
main
Joshua Boverhof 21 years ago
parent
commit
9e4cfd6932
1 changed files with 37 additions and 8 deletions
  1. +37
    -8
      XMLSchema.py

+ 37
- 8
XMLSchema.py View File

@@ -529,6 +529,9 @@ class MarkerInterface:
def isAttributeGroup(self): def isAttributeGroup(self):
return isinstance(self, AttributeGroupMarker) return isinstance(self, AttributeGroupMarker)


def isElement(self):
return isinstance(self, ElementMarker)

def isReference(self): def isReference(self):
return isinstance(self, ReferenceMarker) return isinstance(self, ReferenceMarker)


@@ -1570,10 +1573,7 @@ class ElementDeclaration(XMLSchemaComponent,\
self.constraints = tuple(constraints) self.constraints = tuple(constraints)




class LocalElementDeclaration(ElementDeclaration,\
MarkerInterface,\
ElementMarker,\
DeclarationMarker):
class LocalElementDeclaration(ElementDeclaration):
"""<element> """<element>
parents: parents:
all, choice, sequence all, choice, sequence
@@ -1607,7 +1607,7 @@ class LocalElementDeclaration(ElementDeclaration,\
'keyref', 'unique']} 'keyref', 'unique']}




class ElementReference(ElementDeclaration,\
class ElementReference(XMLSchemaComponent,\
MarkerInterface,\ MarkerInterface,\
ElementMarker,\ ElementMarker,\
ReferenceMarker): ReferenceMarker):
@@ -1629,11 +1629,24 @@ class ElementReference(ElementDeclaration,\
'maxOccurs':'1'} 'maxOccurs':'1'}
contents = {'xsd':['annotation']} 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,\ class ElementWildCard(LocalElementDeclaration,\
MarkerInterface,\
ElementMarker,\
DeclarationMarker,\
WildCardMarker): WildCardMarker):
"""<any> """<any>
parents: parents:
@@ -1656,6 +1669,22 @@ class ElementWildCard(LocalElementDeclaration,\
'processContents':'strict'} 'processContents':'strict'}
contents = {'xsd':['annotation']} 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 # Model Groups


Loading…
Cancel
Save