XML Instance Generation

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
kingargyle
Posts: 58

XML Instance Generation

Thu Dec 14, 2006 6:34 pm

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: 4144

Fri Dec 15, 2006 1:28 pm

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

Sat Dec 16, 2006 2:18 am

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: 4144

Mon Dec 18, 2006 1:13 pm

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
Posts: 45

Mon Dec 18, 2006 7:15 pm

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-oxygenEclipse ... rator.html (for Eclipse)
http://www.oxygenxml.com/doc/ug-standal ... 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

Mon Dec 18, 2006 7:49 pm

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

Thu Dec 21, 2006 6:49 pm

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: 4144

Wed Jan 03, 2007 4:38 pm

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

Wed Jan 03, 2007 5:02 pm

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: 4144

Wed Jan 03, 2007 6:01 pm

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

Thu Jan 04, 2007 12:06 am

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: 4144

Thu Jan 04, 2007 10:09 am

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


Regards,
Sorin
stefan
Posts: 45

Re: XML Instance Generation

Tue Oct 28, 2008 11:04 am

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

Details: http://www.oxygenxml.com/doc/ug-oxygen/xml-schema-instance-generator.html
Video demonstration: http://www.oxygenxml.com/demo/GenerateSampleXMLFiles/generateSampleXMLFiles.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

Re: XML Instance Generation

Wed Nov 05, 2008 2:58 pm

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: 4144

Re: XML Instance Generation

Wed Nov 05, 2008 3:42 pm

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

Re: XML Instance Generation

Mon Nov 10, 2008 6:20 pm

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: 4144

Re: XML Instance Generation

Mon Nov 10, 2008 7:05 pm

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

Re: XML Instance Generation

Mon Nov 10, 2008 7:32 pm

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: 4144

Re: XML Instance Generation

Mon Nov 10, 2008 7:38 pm

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: 4144

Re: XML Instance Generation

Fri Dec 05, 2008 5:35 pm

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: 4144

Re:

Tue Mar 03, 2009 5:12 pm

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

Return to “Common Problems”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests