XML Instance Generation

Having trouble installing Oxygen? Got a bug to report? Post it all here.
kingargyle
Posts: 58
Joined: Fri Nov 11, 2005 6:35 am

XML Instance Generation

Post by kingargyle »

In Oxygen 8 for Eclipse, when creating a XML file from the New -> Oxygen -> XML File wizard, and using a Schema as the base the sample instance is not populated with data, even though the XML Instance Generator preference options are set to have Random values added to the instance.

Also, it would be nice if an element has an enumerated type that a random value from the enumeration could be populated into the instance. XML Spy has this feature, and I find it highly useful. At this point, I need to go back to XML Spy just to generate the XML instances, and it's the only reason I go back into XML Spy at all.

It would be nice to have the wizard appear more like the wizard that shows up in the Standalone version to allow the options to be changed on a per instance basis.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

The XML Instance Generator preference options apply only to the XML Instance Generator tool available from XML Tools -> Generate Sample XML Files. When creating new XML documents the options are presented in the New XML Document wizard: Add optional content and Add first choice particle.

When the range of values of an element/attribute is specified with an enumeration in the XML Schema the XML Instance Generator tool uses one of the values of the enumeration as the value of the element/attribute in the generated instances. So you will not have to use XML Spy for that :)


Regards,
Sorin
kingargyle
Posts: 58
Joined: Fri Nov 11, 2005 6:35 am

Post by kingargyle »

Actually, that later part with the enumerations doesn't always seem to work. I'll have to put together some samples of the issues when I get some time. Also, is there a way to do a batch generation or call the generation from an ANT task? I have about 120 sample instances I need to generate, and doing them by hand is tedious.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

There is no way to do a batch generation of XML instances. I will add a request for that. Please send us a schema for which the generated instance does not contain a value of the enumeration in the element of type enumeration.


Regards,
Sorin
stefan

Post by stefan »

About the batch generation: You can use the XML Instance Generator tool and specify the number of instances (for example 120) in the "Number of instances" field.

See more info here:
http://www.oxygenxml.com/doc/ug-oxygenE ... rator.html (for Eclipse)
http://www.oxygenxml.com/doc/ug-oxygen/ ... rator.html (for standalone).

In order to get random values for elements/attributes please make sure you specify Random for "Values of elements and attributes" field from the "Options" tab.
kingargyle
Posts: 58
Joined: Fri Nov 11, 2005 6:35 am

Post by kingargyle »

I have a 120 Schemas that need to have seperate instance documents generated. Plus I would like to include this in a build so that it can be run attended. Thus the question about an Ant Task.

I work for STAR (Standards for Technology in Automotive Retail), and need to make sure that samples are in synch with the schemas that are being developed for members.

http://www.starstandard.org/
kingargyle
Posts: 58
Joined: Fri Nov 11, 2005 6:35 am

Post by kingargyle »

I have narrowed the problem with Instance generation down to just using the Oxygen XML wizard to create a new file. If you use this wizard in Eclipse with Oxygen 8, and specify a schema to be used to generate the XML, it will not populate any code lists.

Also, slight bug with the XML Tools -> XML Instance Generator. If you delete the prefix for the namespace, oxygen tries to generate a default namespace that lookslike xmlns:="http...." basically it still tries to generate the prefix format. It works correctly under the XML Wizard when specifying a schema.

If you need sample schemas to duplicate this issue, you can download them from

http://www.starstandard.org

The XML Tools -> XML Instance Generator does populate the code lists correctly.

Plus it would still be nice to be able to run the instance generator from an ant task.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

kingargyle wrote:I have narrowed the problem with Instance generation down to just using the Oxygen XML wizard to create a new file. If you use this wizard in Eclipse with Oxygen 8, and specify a schema to be used to generate the XML, it will not populate any code lists.
...
The XML Tools -> XML Instance Generator does populate the code lists correctly.
The XML instance generator is a tool for generating full XML documents which are valid against the specified schema while the XML wizard only generates a partial document which you intend to fill in manually. You should use the wizard only for creating a new document, that is a document which contains only the root element generated automatically and also possibly some optional elements controlled by the two checkboxes and which you want to edit manually in an editor panel in oXygen.
kingargyle wrote:Also, slight bug with the XML Tools -> XML Instance Generator. If you delete the prefix for the namespace, oxygen tries to generate a default namespace that lookslike xmlns:="http...." basically it still tries to generate the prefix format.
Thank you for reporting it. We will fix it in the next version.
kingargyle wrote:Plus it would still be nice to be able to run the instance generator from an ant task.
I added an enhancement request with that.


Regards,
Sorin
kingargyle
Posts: 58
Joined: Fri Nov 11, 2005 6:35 am

Post by kingargyle »

Sorin, the issue with enumeration is that there is a difference between the way the Menu option XML -> XML Instance Generator works, and the one used by the XML File wizard. The Menu option, correctly populates any xml element that has an enumerated list with a value from that enumerated list. The one used by the Wizard, does not populate these elements correctly. No values are placed in those elements when used from the wizard.

Again this is in eclipse 3.2.1 and Oxygen 8.

Thanks for looking into the other two items.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

What I tried to explain in my previous post is that the difference is by design due to the different use cases for the two actions. The Generate Sample XML Files action on the XML Tools menu is a tool for generating full and valid XML documents based on a schema which can be only of type XML Schema. The XML File action available on the File -> New menu creates only a skeleton XML document based on the specified schema which can be of type XML Schema, DTD, Relax NG or NVDL.


Regards,
Sorin
kingargyle
Posts: 58
Joined: Fri Nov 11, 2005 6:35 am

Post by kingargyle »

Okay, I was expecting it to behave similarly to how the Eclipse Web Tools new XML wizard behaves. It generates the shell, but also populates with an initial value from the enumerated list if an element can contain an enumerated value.

If you are going to keep the behavior different between the two ways to generate the XML Instance within Oxygen, then I would suggest clearly stating that enumerations won't be included in the File -> New -> XML File wizard generates. As it is now, it's not clear.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Thank you for the suggestion. We will make the distinction clearer in the User Manual.


Regards,
Sorin
stefan

Re: XML Instance Generation

Post by stefan »

Starting with version 10 you can call the XML instance generator tool from command line.

Details: http://www.oxygenxml.com/doc/ug-oxygen/ ... rator.html
Video demonstration: http://www.oxygenxml.com/demo/GenerateS ... Files.html

You can call the XML instance generator from an ANT task using the following example:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<project>
<target name="generate">
<java classname="ro.sync.xml.generator.XMLInstanceGenerator">
<classpath>
<pathelement path="lib/log4j.jar"/>
<pathelement path="lib/xercesImpl.jar"/>
<pathelement path="lib/oxygen.jar"/>
<pathelement path="lib/resolver.jar"/>
</classpath>
<arg value="path_to_your_configuration_file.xml"/>
<arg value="-verbose"/>
</java>
</target>
</project>
Note: The configuration file is generated from the XML instance generator interface using the "Export Settings" option.
chrisprobert
Posts: 6
Joined: Wed Nov 29, 2006 8:43 am

Re: XML Instance Generation

Post by chrisprobert »

Hi we have run into an issue with instance generation in version 10 - has anyone else had the same problem:

When generating an instance, we are checking the boxes for optional elements and attributes, but seemingly still get only mandatory elements in the output. Doing the exact same thing with 9.3 gives all of the optional elements.
Any suggestions as to what may be causing, or a workaround in version 10 (those that have upgraded can't go back due to the alteration of the license structure, so we are relient on those still on 9.3 at the moment)

Thanks

Chris
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: XML Instance Generation

Post by sorin_ristache »

Hello Chris,

I am sorry, I cannot reproduce the problem. When I select the option for optional elements/attributes the generated XML instances contain the optional elements/attributes. When I unselect the option the optional elements/attributes are not generated. Please post a sample XML Schema for reproducing the problem.


Regards,
Sorin
chrisprobert
Posts: 6
Joined: Wed Nov 29, 2006 8:43 am

Re: XML Instance Generation

Post by chrisprobert »

Hi Sorin,

Yes, it seems it is a strange corner case. Here is an example schema that shows the behaviour. I only seem to see the behaviour in nested structures such as the one in the schema below. The schema we were having problems with was large and complex so this is a cut down example to show the problem. You should notice that even with the check box for optional elements selected, you still only get the mandatory.
We don't see the same problem with 9.3.

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.com/chrisprobert"
targetNamespace="http://www.example.com/chrisprobert"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:element name="TestElement" type="TestType"/>

<xs:complexType name="TestType">
<xs:sequence>
<xs:element name="CustomerList" type="CustomerListType"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="CustomerListType">
<xs:sequence>
<xs:element name="Customer" type="CustomerType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="CustomerType">
<xs:sequence>
<xs:element name="LocationList" type="LocationListType"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="LocationListType">
<xs:sequence>
<xs:element name="Location" type="NameAddressType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="NameAddressType">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="AddressLine" type="xs:string"/>
<xs:element name="TelephoneNum" type="xs:string" minOccurs="0"/>
<xs:element name="MobileNum" type="xs:string" minOccurs="0"/>
<xs:element name="FaxNum" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>



</xs:schema>
This is the output I get (with preferred repetitions = 2):

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<TestElement xmlns="http://www.example.com/chrisprobert"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.com/chrisprobert file:/C:/cprobert/oxygen/testing/Test.xsd">
<CustomerList>
<Customer>
<LocationList>
<Location>
<Name>Name0</Name>
<AddressLine>AddressLine0</AddressLine>
</Location>
<Location>
<Name>Name1</Name>
<AddressLine>AddressLine1</AddressLine>
</Location>
</LocationList>
</Customer>
<Customer>
<LocationList>
<Location>
<Name>Name2</Name>
<AddressLine>AddressLine2</AddressLine>
</Location>
<Location>
<Name>Name3</Name>
<AddressLine>AddressLine3</AddressLine>
</Location>
</LocationList>
</Customer>
</CustomerList>
</TestElement>
Thanks

Chris
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: XML Instance Generation

Post by sorin_ristache »

Hello,

Thank you for the sample XML Schema. Now I can reproduce the problem and we will fix it probably in the next version of Oxygen. Unfortunately there is no workaround that forces generating optional elements from your schema.


Regards,
Sorin
chrisprobert
Posts: 6
Joined: Wed Nov 29, 2006 8:43 am

Re: XML Instance Generation

Post by chrisprobert »

Hi Sorin,

Do you have a timescale for this next release? The problem we have is that we have two developers with version 10 licenses, who need this functionality. They tried installing 9.3 but their licenses aren't backwards compatible and won't work with version 9.
Any suggestions as to what we should do in the meantime? I guess we could install 9.3 and use trial licenses until the update to 10 is available?

Thanks,

Chris
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: XML Instance Generation

Post by sorin_ristache »

Yes, we can provide a license key for Oxygen 9.3 for your users. Please contact us in order to send you the license key by email. You can download Oxygen 9.3 from the Software Archive page.


Regards,
Sorin
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: XML Instance Generation

Post by sorin_ristache »

chrisprobert wrote:Do you have a timescale for this next release? The problem we have is that we have two developers with version 10 licenses, who need this functionality.
I just sent you by email a download link for a preview of Oxygen 10.1 that includes a fix for the reported problem and also other small improvements in the tool for generating XML instances of XML Schema.


Regards,
Sorin
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re:

Post by sorin_ristache »

Hello,
kingargyle wrote:Also, is there a way to do a batch generation or call the generation from an ANT task? I have about 120 sample instances I need to generate, and doing them by hand is tedious.
You can call the XML instance generator tool in an Ant script as described above or you can run the tool from a command line using the script schemaDocumentation.bat (schemaDocumentation.sh on Linux and Mac OS X). The script accepts as parameter an XML config file created with the Export Settings button of the dialog box used in the Oxygen GUI for generating XML instances. This button exports all the option values set in the dialog as an external file.


Regards,
Sorin
Post Reply