Browse Source

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

Modified Files:
 	XMLSchema.py -- added a couple helper methods for discovering
           whether or not an element should be qualified.

 ----------------------------------------------------------------------
main
Joshua Boverhof 20 years ago
parent
commit
d69e383aca
1 changed files with 26 additions and 0 deletions
  1. +26
    -0
      XMLSchema.py

+ 26
- 0
XMLSchema.py View File

@@ -1006,6 +1006,9 @@ class XMLSchema(XMLSchemaComponent):
""" """
return self.attributes.get('elementFormDefault') return self.attributes.get('elementFormDefault')


def isElementFormDefaultQualified(self):
return self.attributes.get('elementFormDefault') == 'qualified'

def getAttributeFormDefault(self): def getAttributeFormDefault(self):
"""return attributeFormDefault attribute """return attributeFormDefault attribute
""" """
@@ -1727,6 +1730,11 @@ class ElementDeclaration(XMLSchemaComponent,\
self.content = None self.content = None
self.constraints = () self.constraints = ()


def isQualified(self):
'''Global elements are always qualified.
'''
return True

def getElementDeclaration(self, attribute): def getElementDeclaration(self, attribute):
raise Warning, 'invalid operation for <%s>' %self.tag raise Warning, 'invalid operation for <%s>' %self.tag


@@ -1816,6 +1824,18 @@ class LocalElementDeclaration(ElementDeclaration,\
contents = {'xsd':['annotation', 'simpleType', 'complexType', 'key',\ contents = {'xsd':['annotation', 'simpleType', 'complexType', 'key',\
'keyref', 'unique']} 'keyref', 'unique']}


def isQualified(self):
'''Local elements can be qualified or unqualifed according
to the attribute form, or the elementFormDefault. By default
local elements are unqualified.
'''
form = self.getAttribute('form')
if form == 'qualified':
return True
if form == 'unqualified':
return False
raise SchemaError, 'Bad form (%s) for element: %s' %(form, self.getItemTrace())



class ElementReference(XMLSchemaComponent,\ class ElementReference(XMLSchemaComponent,\
ElementMarker,\ ElementMarker,\
@@ -1893,6 +1913,12 @@ class ElementWildCard(LocalElementDeclaration,\
XMLSchemaComponent.__init__(self, parent) XMLSchemaComponent.__init__(self, parent)
self.annotation = None self.annotation = None


def isQualified(self):
'''Global elements are always qualified, but if processContents
are not strict could have dynamically generated local elements.
'''
return GetSchema(self).isElementFormDefaultQualified()

def getTypeDefinition(self, attribute): def getTypeDefinition(self, attribute):
raise Warning, 'invalid operation for <%s>' %self.tag raise Warning, 'invalid operation for <%s>' %self.tag




Loading…
Cancel
Save