Generate xml from xsd

Oxygen general issues.
matze
Posts: 9
Joined: Wed Jan 23, 2008 2:57 pm

Generate xml from xsd

Post by matze »

Hello,
if I generate a sample xml file from the this xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="eTEIheader">
<xs:complexType>
<xs:sequence>
<xs:element ref="fileDesc"/>
</xs:sequence>
<xs:attributeGroup ref="attlist.eTEIheader"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="attlist.eTEIheader">
<xs:attribute name="type" default="text"/>
<xs:attribute name="creator"/>
</xs:attributeGroup>
<xs:element name="fileDesc">
</xs:element>
</xs:schema>

I get the following result:

<?xml version="1.0" encoding="UTF-8"?>
<Incl xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:/F:/Studium/SFB441_C2/metadatenschema/eTEI_dtd_2-3/eTEI0.2.3.xsd"></Incl>

Shouldn't there be at least the elements eTEIheader, fileDesc, attlist.eTEIheader? Does Oxygen have problems with following the references?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Generate xml from xsd

Post by sorin_ristache »

Hello,

I generated the following XML instance from the XML Schema that you posted:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<eTEIheader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ftopic2752.xsd" type="text" creator="creator0">
<fileDesc>
</fileDesc>
</eTEIheader>
As you can see the references to fileDesc and attlist.eTEIheader are followed correctly. I think you did not generate the XML instance that you posted from that XML Schema because the schema does not define an Incl element as in your XML instance.


Regards,
Sorin
matze
Posts: 9
Joined: Wed Jan 23, 2008 2:57 pm

Re: Generate xml from xsd

Post by matze »

It works now. Somehow there was by default the wrong root-element selected (<Incl>).
If I use the option "Generate other options as comments" in the section Option>Choice-Groups, oxygen creates nested comments, which is not valid. Is there a bug?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Generate xml from xsd

Post by sorin_ristache »

In the generated XML instance a choice is generated as comment when one of the other choices from the same group generates an element of the XML instance. If there is other choice nested in the commented choice that is also generated as comment then you have nested comments. That XML instance is not valid but detecting such cases in the generated XML instance is not very easy. We will think about how we can avoid this validation error in the XML instance.


Regards,
Sorin
drrwxml
Posts: 1
Joined: Mon Dec 01, 2008 7:22 am

Re: Generate xml from xsd

Post by drrwxml »

To generate whole sets of realistic test examples and cases can be done using some XSLT and refactoring of your information model from the XSD schema.

The tutorial on ingesting the XSD schema, generating a new content model template and then outputting sets of XML test cases can be found here:
http://wiki.oasis-open.org/cam/Generati ... s_from_XSD

Enjoy, DW
Post Reply