Example #1
0
	def __init__ (self, path=None, xml=None):
		if path:
			print "reading %s" % path
		XmlRecord.__init__ (self, path=path, xml=xml)

		import xsd_globals
		xsd_globals.XSD_PREFIX = self.root_name_space_prefix
		del xsd_globals
		
		# since these use XSD prefix - we define only after figuring out what it is..
		self.enumeration_path = qp("schema/simpleType/restriction/enumeration")
		self.restriction_path = qp("schema/simpleType/restriction")
		self._enumTypes = None
Example #2
0
	def createEnumerationType (self, typeName):
		"""
		create a new EnumerationType instance (named for typeName)
		- enumType is NOT populated with values at this time
		""" 
		simpleType = createSchemaElement("simpleType")
		simpleType.setAttribute ("name",typeName)
		restriction = createSchemaElement("restriction")
		restriction.setAttribute ("base", qp("token"))
		simpleType.appendChild (restriction)
		return self.enumType_constructor (simpleType)
Example #3
0
def getEnumerationTypeXmlStub(typeName):
    """
	create a new enumerationType definition (named for typeName)
	enum is NOT populated with values at this time
	"""
    simpleType = createSchemaElement("simpleType")
    simpleType.setAttribute("name", typeName)
    restriction = createSchemaElement("restriction")
    restriction.setAttribute("base", qp("token"))
    simpleType.appendChild(restriction)
    return simpleType
Example #4
0
    def __init__(self, element=None, data=None):

        self.description_path = qp("annotation/documentation")

        if element is not None:
            # print "AnnotatedVocabTerm with element of type %s" % type(element)
            self.value = element.getAttribute("value")
            self.description = XmlUtils.getTextAtPath(element,
                                                      self.description_path)
        if data is not None:
            self.value = data[0]
            self.description = data[1]
Example #5
0
	def getEnumerationTypes (self):
		"""
		get the Enumeration Type defs defined in this XSD
		"""
		
		# print "getEnumerationTypes: enumTypes is %s" % type(self._enumTypes)
		
		if self._enumTypes is None:
			self._enumTypes = []
			for typeDef in self._get_typeDefs():
				# print "typeDef (%s) %s" % (type(typeDef), typeDef.getAttribute("name"))
				
				# we don't require any enums to be present
				if XmlUtils.selectSingleNode (typeDef, qp("restriction")):
					self._enumTypes.append (self.enumType_constructor (typeDef))
	
			if len(self._enumTypes) == 0:
				print "WARNING: getEnumerationTypes did not find any"
		return self._enumTypes
Example #6
0
	def __init__ (self, element):
		self.element = element
		self.name = element.getAttribute ("name")
		self.restriction = XmlUtils.selectSingleNode (element, qp("restriction"))
		self.terms = XmlUtils.selectNodes (self.restriction, qp("enumeration"))
Example #7
0
	def _get_typeDefs (self):
		return self.selectNodes (self.dom, qp("schema/simpleType"))
Example #8
0
	def addValue(self, value):
		vocabTerm = XmlUtils.createElement (qp("enumeration"), XSD_NAMESPACE_URI)
		vocabTerm.setAttribute ("value", value)
		self.restriction.appendChild (vocabTerm)