You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Parvatikar, Narayan" <np...@informatica.com> on 2014/01/27 13:36:35 UTC
Handling namespaces in xsd
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
RE: Handling namespaces in xsd
Posted by Cezar Andrei <ce...@oracle.com>.
I used inst2xsd tool in bin directory:
./xmlbeans/bin/inst2xsd inst.xml
[ -verbose -validate ] switches are optional.
If you need to call it from your code just look at the implementation.
I don't remember if imports are implemented but it's not an XmlSchema
spec requirement.
Cezar
On Mon, 2014-01-27 at 20:20 -0800, Parvatikar, Narayan wrote:
> Thanks lot Cezar, this is what I am looking for.
>
> How did you do that ? I am using xmlbeans 2.6.0 and API Inst2Xsd.inst2xsd() , but I am not able to generate like this.
> Is there any specific option to generate like this ?
>
> I tried xmloptions. setLoadAdditionalNamespaces() but it dint help.
>
> Also, I noticed that there are no import statements added in schema you sent , Is there a way to do that ?
>
> Thanks
> Narayan
>
> -----Original Message-----
> From: Cezar Andrei [mailto:cezar.andrei@oracle.com]
> Sent: Monday, January 27, 2014 9:14 PM
> To: user@xmlbeans.apache.org
> Subject: Re: Handling namespaces in xsd
>
> 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
> >
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
RE: Handling namespaces in xsd
Posted by "Parvatikar, Narayan" <np...@informatica.com>.
Thanks lot Cezar, this is what I am looking for.
How did you do that ? I am using xmlbeans 2.6.0 and API Inst2Xsd.inst2xsd() , but I am not able to generate like this.
Is there any specific option to generate like this ?
I tried xmloptions. setLoadAdditionalNamespaces() but it dint help.
Also, I noticed that there are no import statements added in schema you sent , Is there a way to do that ?
Thanks
Narayan
-----Original Message-----
From: Cezar Andrei [mailto:cezar.andrei@oracle.com]
Sent: Monday, January 27, 2014 9:14 PM
To: user@xmlbeans.apache.org
Subject: Re: Handling namespaces in xsd
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
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
Re: Handling namespaces in xsd
Posted by Cezar Andrei <ce...@oracle.com>.
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
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org