From d69e383aca6b494b225f466d611042e7b9065c92 Mon Sep 17 00:00:00 2001 From: Joshua Boverhof Date: Tue, 16 Nov 2004 20:59:29 +0000 Subject: [PATCH] ---------------------------------------------------------------------- Modified Files: XMLSchema.py -- added a couple helper methods for discovering whether or not an element should be qualified. ---------------------------------------------------------------------- --- XMLSchema.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/XMLSchema.py b/XMLSchema.py index b72f80b..46f18c0 100755 --- a/XMLSchema.py +++ b/XMLSchema.py @@ -1006,6 +1006,9 @@ class XMLSchema(XMLSchemaComponent): """ return self.attributes.get('elementFormDefault') + def isElementFormDefaultQualified(self): + return self.attributes.get('elementFormDefault') == 'qualified' + def getAttributeFormDefault(self): """return attributeFormDefault attribute """ @@ -1727,6 +1730,11 @@ class ElementDeclaration(XMLSchemaComponent,\ self.content = None self.constraints = () + def isQualified(self): + '''Global elements are always qualified. + ''' + return True + def getElementDeclaration(self, attribute): raise Warning, 'invalid operation for <%s>' %self.tag @@ -1816,6 +1824,18 @@ class LocalElementDeclaration(ElementDeclaration,\ contents = {'xsd':['annotation', 'simpleType', 'complexType', 'key',\ '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,\ ElementMarker,\ @@ -1893,6 +1913,12 @@ class ElementWildCard(LocalElementDeclaration,\ XMLSchemaComponent.__init__(self, parent) 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): raise Warning, 'invalid operation for <%s>' %self.tag