示例#1
0
 def test_property_prefixes(self):
     namespaces = Namespaces()
     namespaces.add_all({
         "b": "bar",
         None: "http://www.w3.org/2001/XMLSchema",
         "foo": "http://www.w3.org/2001/XMLSchema-instance",
     })
     self.assertEqual(["b", "xs", "xsi"], namespaces.prefixes)
     self.assertEqual("b", namespaces.prefix("bar"))
     self.assertEqual("xs",
                      namespaces.prefix("http://www.w3.org/2001/XMLSchema"))
     self.assertIsNone(namespaces.prefix("http://xsdata"))
示例#2
0
def qname_to_xml(qname: QName, namespaces: Namespaces) -> str:
    namespaces.add(qname.namespace)
    prefix = namespaces.prefix(qname.namespace)

    return f"{prefix}:{qname.localname}" if prefix else qname.localname