You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Hussain, Malik" <Mh...@rational.com> on 2001/01/25 02:06:36 UTC
Extracting namespace URI from a referenced type ?
Does xerces provide any way to extract the namespace URI of a referenced
type ?
Details...
There are two .xsd files below: customer.xsd and account.xsd.
The "savingAccount" element in customerNS namespace in customer.xsd derives
off of "saving" type in accountNS in account.xsd using the <<import>> tag.
Note that both files define types in two different namespaces.
I like to be able to extract "http://theXFiles/accountNS" (the saving's
namespace) from savingAccount element while parsing customer.xsd.
Is the solution available for both xerces's DOM and SAX parsers ?
thanks
malik
customer.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://theXFiles/customerNS"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:tns="http://theXFiles/customerNS"
xmlns:accountNS="http://theXFiles/accountNS" elementFormDefault="qualified">
<xsd:import namespace="http://theXFiles/accountNS"
schemaLocation="D:\work\wm-xml\doc\product management\Rose XML
Modeler\account.xsd"/>
<xsd:element name="customer" type="tns:customerType"/>
<xsd:complexType name="customerType">
<xsd:sequence>
<xsd:element name="lastName" type="xsd:string"/>
<xsd:element name="firstName" type="xsd:string"/>
<xsd:element name="contactInfo" type="xsd:string"/>
<xsd:element name="savingAccount"
type="accountNS:saving"/>
<xsd:element name="checkingAccount"
type="accountNS:checking"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
account.xsd
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://theXFiles/accountNS"
xmlns="http://www.w3.org/2000/10/XMLSchema"
xmlns:tns="http://theXFiles/accountNS" elementFormDefault="qualified">
<complexType name="account">
<sequence>
<element name="number" type="positiveInteger"/>
<element name="balance" type="float"/>
<element name="transaction"
type="tns:transactionType" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="transactionType">
<sequence>
<element name="date" type="date"/>
<element name="kind" type="tns:transactionKind"/>
</sequence>
</complexType>
<simpleType name="transactionKind">
<restriction base="string">
<enumeration value="withdraw"/>
<enumeration value="deposit"/>
</restriction>
</simpleType>
<complexType name="saving">
<complexContent>
<extension base="tns:account">
<sequence>
<element name="interest"
type="float"/>
</sequence>
</extension>
</complexContent>
</complexType>
<complexType name="checking">
<complexContent>
<extension base="tns:account">
<sequence>
<element name="fee" type="float"/>
</sequence>
</extension>
</complexContent>
</complexType>
</schema>