[XML-SIG] xml-schema parsing using minidom.

Sylvain Thenault Sylvain.Thenault@logilab.fr
Tue, 4 Dec 2001 09:31:19 +0100 (CET)


On Mon, 3 Dec 2001, Mariappan, MaharajanX wrote:

> 2) There is another question on created list from return value of
> getAttribute() method.
> 
> See below function, which will collect all the enumeration values defined
> within specified simpleType element and return that result list.
> 
> def getSimpleTypeValues(dom,simpletypeName):
> 	enums = []
> 	simpletypes = dom.getElementsByTagName("xsd:simpleType")
> 	for simpletype in simpletypes:
> 		#print "%s" % simpletype.getAttribute("name")
> 		if simpletype.getAttribute("name") == simpletypeName:
> 			enumerations =
> simpletype.getElementsByTagName("xsd:enumeration")
> 			for enum in enumerations:
> 				enums.append(enum.getAttribute("value"))
> 	return enums
> 
> When I print using print "%s" % enums, It is printing like
> [u'enum1', u'enum2']
> 
> Any reason for that why print with u' ' aling with list elements?
 
this means that it's an Unicode string (try "type(u'')" vs "type('')" in 
the python interpreter).

Another thing: when you use DOM with namespaces, you should use the NS
interface of DOM, i.e. replace getAttribute("value") with
getAttributeNS(NO_NS, "value" where NO_NS is None or empty string,
depending on the dom implementation you are using (This have been fixed
in the CVS, now the empty namespace is None, independantly from the dom
implementation).
  
regards

-- 
Sylvain Thenault

  LOGILAB           http://www.logilab.org