You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Jim McMaster <ji...@comcast.net> on 2005/05/24 22:06:18 UTC
Problems with namespace prefixes in version 2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I am using XmlBeans v2 to access appinfo elements in a schema, which
I then process to create XML based on that schema. A portion of the
schema is:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ontology="http://www.aptas.com/ontology"
xmlns:papyrus="http://www.aptas.com/papyrus"
targetNamespace="http://www.aptas.com/ontology"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<xs:import namespace="http://www.aptas.com/papyrus"
schemaLocation="xsd/PapyrusAppinfo.xsd" />
<xs:complexType name="ontology">
...omitted for brevity
</xs:complexType>
<xs:element name="datafeed">
<xs:complexType>
<xs:sequence>
<xs:element name="ontology" type="ontology:ontology">
</xs:element>
</xs:sequence>
<xs:attribute name="locale" type="xs:language"
default="en">
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
A sample of the generated XML is:
<?xml version="1.0" encoding="UTF-8"?>
<datafeed xmlns="http://www.aptas.com/ontology" locale="en-US">
<ontology>
...stuff omitted
</ontology>
</datafeed>
The problem is, this XML does not validate against the schema. The
only way I can get it to validate is to define the namespace prefix
"ontology" in the XML, then prefix the datafeed element, and only the
datafeed element, with "ontology:".
The first question, non-XmlBeans-related, is why the datafeed element
needs to be prefixed? I am hoping a schema guru can educate me.
The second question is, I can't find the prefix to add. When I get
the SchemaTypeSystem from the XmlBeans compiler, the SchemaType and
the SchemaLocalElement for the datafeed element both have a QName
with a correct namespaceURI and localPart, but the prefix is an empty
string. Assuming I really need it, where can I find the prefix?
Thank you. If I have not provided enough information, please let me
know and I will send more.
- --
Jim McMaster
mailto:jim.mcmaster@comcast.net
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.1
iQA/AwUBQpOJOmaP5l7/atSJEQJayQCfUoyPcRTXuHgYSE4MvYm3JA18DMwAn2Uo
7e81Xxzf/nHOIN+3WTbKVg4p
=fwFK
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org