Generating sample xml from xsd

This should cover W3C XML Schema, Relax NG and DTD related problems.
imran
Posts: 1
Joined: Mon Dec 19, 2016 1:38 pm

Generating sample xml from xsd

Post by imran » Mon Dec 19, 2016 1:47 pm

-1
down vote
favorite
I've generated a sample XML from an XSD schema file here is a snippet of the output:

Code: Select all

      <data name="name1">
<data name="name1">0</data>
<data name="name2">65535</data>
<data name="name3">1</data>
</data>
But ideally I need the sample file to contain attributes and data from the original XML file. So the output should be:

Code: Select all


      <data name="attribute1" type="primary">
<data name="attribute2">
<data name="attribute3">_366170470</data>
<data name="attribute2">
<data name="attribute4">_120494376</data>
</data>
</data>
</data>
The attribute1,2,3 etc are actuall attribute names for the data element from the original XML.

Is this possible?

adrian
Posts: 2673
Joined: Tue May 17, 2005 4:01 pm

Re: Generating sample xml from xsd

Post by adrian » Mon Dec 19, 2016 4:35 pm

Hi,

The "Generate Sample XML Files" tool is designed to generate XML starting from an XML schema (XSD). There is no way to feed it content from an XML file. What you can do is configure some predefined values for some elements and attributes (the elements need to be declared globally in the schema).

Go to the Options tab, in the upper section press New and pick the Namespace and element name. Select the new element item from the upper list and switch to the "Attribute values" tab. Press New in that section and pick the namespace and name of the attribute. Select the new attribute item from the middle list and add the desired values in the bottom, "Values" section.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

vtai
Posts: 1
Joined: Fri May 15, 2020 7:28 pm

Re: Generating sample xml from xsd

Post by vtai » Fri May 15, 2020 7:41 pm

Hi Adrian,
I've read your advice with interest.
But please how could I add the curent date to the value for the date time element instead of the default generated date (2006-05-04).
Regards
Tai

adrian
Posts: 2673
Joined: Tue May 17, 2005 4:01 pm

Re: Generating sample xml from xsd

Post by adrian » Mon May 18, 2020 5:33 pm

Hi,

You can't configure it to provide the current date, but you can manually enter a predefined specific date (which can be the current date).

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Post Reply