Re: Handling namespaces in xsd
Cezar Andrei <[email protected]> Mon, 27 Jan 2014 07:44:08 -0800 (PST)
| Newsgroups | gmane.text.xml.xmlbeans.user |
|---|---|
| Message-ID | <1390837448.3966.61.camel@i7> |
Narayan,
It seems correct to me. Each namespace is defined by a separate schema
file. And there is a definition in the last schema for abc element:
<element name="abc" type="abcType"/>
Cezar
Here are the generated schema files:
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.w3schools.com/furniture"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="table" type="fur:tableType"
xmlns:fur="http://www.w3schools.com/furniture"/>
<complexType name="tableType">
<sequence>
<element type="xs:string" name="name"
xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<element type="xs:byte" name="width"
xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
<element type="xs:byte" name="length"
xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
</sequence>
</complexType>
</schema>
----------------------
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.w3.org/TR/html4/"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="table" type="htm:tableType"
xmlns:htm="http://www.w3.org/TR/html4/"/>
<complexType name="trType">
<sequence>
<element name="td" maxOccurs="unbounded" minOccurs="0">
<simpleType>
<restriction base="xs:string"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<enumeration value="Apples"/>
<enumeration value="Bananas"/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
<complexType name="tableType">
<sequence>
<element type="htm:trType" name="tr"
xmlns:htm="http://www.w3.org/TR/html4/"/>
</sequence>
</complexType>
</schema>
----------------------
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="abc" type="abcType"/>
<complexType name="abcType">
<sequence>
<element ref="fur:table"
xmlns:fur="http://www.w3schools.com/furniture"/>
<element ref="htm:table" xmlns:htm="http://www.w3.org/TR/html4/"/>
</sequence>
</complexType>
</schema>
Cezar
On Mon, 2014-01-27 at 04:36 -0800, Parvatikar, Narayan wrote:
> Hi
>
>
>
> I am trying to convert a xml sample which has multiple namespaces
> using xmlbeans inst2xsd java API.
>
> The generated xsd does not look correct?
>
> Source XML :
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <abc xmlns:h="http://www.w3.org/TR/html4/"
> xmlns:f="http://www.w3schools.com/furniture"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>
> <f:table>
>
> <f:name>African Coffee Table</f:name>
>
> <f:width>80</f:width>
>
> <f:length>120</f:length>
>
> </f:table>
>
> <h:table>
>
> <h:tr>
>
> <h:td>Apples</h:td>
>
> <h:td>Bananas</h:td>
>
> </h:tr>
>
> </h:table>
>
> </abc>
>
>
>
> The generated XSD contains only f: table and does not produce element
> definition for root element abc.
>
> Is there any way to handle the multiple namespaces in xmlbeans ?
>
>
>
>
>
> Thanks
>
> Narayan
>
>
>
>