xml - Python: QName on node's attribute, lxml -
in python's lxml.etree, how add namesapce attribute of node one: name space is:
xs_ns = 'http://www.w3.org/2001/xmlschema'
result looking is:
<xs:element name="label" type="xs:string"></xs:element>
i tried 1 result not looking for:
element = et.subelement( sequence, et.qname(xs_ns, "element"), name="label", type=str(et.qname(xs_ns, "string")), )
gave me:
<xs:element name="label" type="{http://www.w3.org/2001/xmlschema}string"/>
as far know, while attribute self may have namespace, value of attribute doesn't consider namespaces:
<!-- attribute has namespace prefix --> <dummy xs:foo="bar"/> <!-- attribute has value of string containing colon --> <dummy foo="xs:bar"/>
so can put "prefix" , "value" single string altogether:
type="xs:string"
related discussion: xml schema. processing namespace-aware attribute values. there it's implicitly stated prefix in attribute value isn't significant, placeholders actual namespaces.
Comments
Post a Comment