[xsd-users] How to determine if the xsd:QName is qualified?

Vladimir Vasilyev Vladimir.Vasilyev at samtec.de
Mon Jun 7 05:10:37 EDT 2010


Hello,

When I use a qualified name in my xsd/xml, i want to be able to find out
if the name is qualified or not. As far as i found out there is a
special function for that qname::qualified.

Somehow in the following example i get that the "QName" is always
qualified (from my point of view it is not qualified in the supplied
xml):

XSD:
<?xml version="1.0"?>
<xsd:schema targetNamespace="MyNamespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:mns="MyNamespace"
elementFormDefault="qualified" >
  <xsd:complexType name="person">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string"/>
    </xsd:sequence>
    <xsd:attribute name="QName" type="xsd:QName"/>
  </xsd:complexType>
  <xsd:element name="supermen" type="mns:person"/>
</xsd:schema>

XML:
<?xml version="1.0"?>
<supermen xmlns="MyNamespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="MyNamespace supermen.xsd"
QName="NCName">
    <name>John Doe</name>
</supermen>

Code:
auto_ptr<person> sm(supermen(argv[1]));
if(sm->QName().present())
{
	cout << "Qual: " << sm->QName()->qualified() << endl;
	cout << "QName: " << sm->QName()->namespace_() << ":" <<
sm->QName()->name() << endl;
}

Output:
Qual: 1
QName: MyNamespace:NCName

What is wrong with my code, xsd or xml? How to determine if the
xsd:QName "QName" is qualified or not?

With regards
Vladimir Vasilyev.



More information about the xsd-users mailing list