Added Schema methods to seek attributeGroup and group nodes.
Added Type method getExtensionBaseType. Added Type methods to get lists of attribute, attributeGroup, element and group nodes. Added Type method getDescriptionAbsolutePath to be used to define a default description for all elements of a given type.
This commit is contained in:
parent
4daea9f3f0
commit
62c8a49ead
|
@ -62,6 +62,12 @@ class Schema(elements.Element):
|
|||
schemasContext.schemas = []
|
||||
schemasContext.schemas.append(self)
|
||||
|
||||
def getAttributeGroupNode(self, name):
|
||||
""" Returns the definition element "attributeGroup" with the given name.
|
||||
"""
|
||||
for node in schema.evaluateXpath("""xsd:attributeGroup[name="%s"]""" % name):
|
||||
return node
|
||||
|
||||
def getAttributeInNodeType(self, value, node, name):
|
||||
""" Returns a TypeContext for attribute "name" whose definition is a child of "node".
|
||||
Argument "value" is a ModelContext to be used as the context specimen.
|
||||
|
@ -169,6 +175,12 @@ class Schema(elements.Element):
|
|||
if globalType is not None:
|
||||
return globalType
|
||||
|
||||
def getGroupNode(self, name):
|
||||
""" Returns the definition element "group" with the given name.
|
||||
"""
|
||||
for node in schema.evaluateXpath("""xsd:group[name="%s"]""" % name):
|
||||
return node
|
||||
|
||||
def getIncludeLocations(self):
|
||||
""" Returns the list of included and imported schema locations.
|
||||
"""
|
||||
|
@ -199,7 +211,7 @@ class Schema(elements.Element):
|
|||
def getTypeInNode(self, value, node, name):
|
||||
""" Returns a TypeContext for element or attribute "name".
|
||||
Argument "value" is a ModelContext to be used as the context specimen.
|
||||
Argument "node" is the context node (where to look for the element or attribute declaration).
|
||||
Argument "node" is the context node (where to look for the type declaration).
|
||||
"""
|
||||
name = name.replace("'", "'")
|
||||
for typeNode in self.evaluateXpath("*[@name = '%s']" % name, node):
|
||||
|
@ -314,6 +326,44 @@ class AbstractType:
|
|||
class Type(AbstractType, elements.Element):
|
||||
""" A non-standard type.
|
||||
"""
|
||||
def getAttributeNodeList(self):
|
||||
""" Returns a list of all "attribute" nodes in this type definition.
|
||||
Includes inherited ones.
|
||||
"""
|
||||
list = []
|
||||
baseType = self.getExtensionBaseType()
|
||||
if baseType:
|
||||
list += baseType.getAttributeNodeList()
|
||||
list += self.evaluateXpath(
|
||||
"xsd:complexContent/xsd:extension/xsd:attribute | xsd:attribute"
|
||||
)
|
||||
return list
|
||||
|
||||
def getAttributeGroupNodeList(self):
|
||||
""" Returns a list of all "attributeGroup" nodes in this type definition.
|
||||
Includes inherited ones.
|
||||
"""
|
||||
list = []
|
||||
baseType = self.getExtensionBaseType()
|
||||
if baseType:
|
||||
list += baseType.getAttributeGroupNodeList()
|
||||
schema = self.getSchema()
|
||||
list += [
|
||||
schema.getAttributeGroupNode(name)
|
||||
for name in [
|
||||
node.content
|
||||
for node in self.evaluateXpath(
|
||||
"(xsd:complexContent/xsd:extension/xsd:attributeGroup|xsd:attributeGroup)/@ref"
|
||||
)
|
||||
]
|
||||
] + [
|
||||
node
|
||||
for node in self.evaluateXpath(
|
||||
"(xsd:complexContent/xsd:extension/xsd:attributeGroup|xsd:attributeGroup)[@name]"
|
||||
)
|
||||
]
|
||||
return list
|
||||
|
||||
def getAttributeType(self, value, attributeName):
|
||||
""" Returns a TypeContext for attribute "attributeName".
|
||||
Argument "value" is a ModelContext to be used as the context specimen.
|
||||
|
@ -410,6 +460,55 @@ class Type(AbstractType, elements.Element):
|
|||
return elementType
|
||||
return None
|
||||
|
||||
def getDescriptionAbsolutePath(self):
|
||||
""" Returns a description path if defined, or None.
|
||||
"""
|
||||
return None
|
||||
|
||||
def getElementNodeList(self):
|
||||
""" Returns a list of all "element" nodes in this type definition.
|
||||
Includes inherited ones.
|
||||
"""
|
||||
list = []
|
||||
baseType = self.getExtensionBaseType()
|
||||
if baseType:
|
||||
list += baseType.getElementNodeList()
|
||||
list += self.evaluateXpath(
|
||||
"xsd:complexContent/xsd:extension/xsd:sequence/xsd:element | xsd:sequence/xsd:element"
|
||||
)
|
||||
return list
|
||||
|
||||
def getExtensionBaseType(self):
|
||||
""" Returns the type we inherit from.
|
||||
"""
|
||||
for node in self.evaluateXpath("xsd:complexContent/xsd:extension/@base"):
|
||||
return self.getSchema().getGlobalType(None, node.content).prototype
|
||||
|
||||
def getGroupNodeList(self):
|
||||
""" Returns a list of all "group" nodes in this type definition.
|
||||
Includes inherited ones.
|
||||
"""
|
||||
list = []
|
||||
baseType = self.getExtensionBaseType()
|
||||
if baseType:
|
||||
list += baseType.getGroupNodeList()
|
||||
schema = self.getSchema()
|
||||
list += [
|
||||
schema.getGroupNode(name)
|
||||
for name in [
|
||||
node.content
|
||||
for node in self.evaluateXpath(
|
||||
"(xsd:complexContent/xsd:extension/xsd:group|xsd:group)/@ref"
|
||||
)
|
||||
]
|
||||
] + [
|
||||
node
|
||||
for node in self.evaluateXpath(
|
||||
"(xsd:complexContent/xsd:extension/xsd:group|xsd:group)[@name]"
|
||||
)
|
||||
]
|
||||
return list
|
||||
|
||||
def getName(self):
|
||||
""" Returns the name of this Type.
|
||||
"""
|
||||
|
|
Reference in New Issue