Configurable sample data for instance generator

Are you missing a feature? Request its implementation here.
jhausherr
Posts: 1
Joined: Fri Jun 03, 2005 12:20 pm

Configurable sample data for instance generator

Post by jhausherr »

Hi,

I am currently working on an XML Schema document to describe input for a jasper reports report. As the application that is developed in parallel does not yet deliver any data I find the instance generator extremely useful.

IMHO the instance generator misses just one tiny feature: The ability to define sets of sample data to choose from (eg. for a tag <name> choose one of {"Alice", "Bob", "John", ...}), which could greatly assist to generate more "life-like" sample data.

Is there any chance for such an extension to the instance generator?

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

Post by sorin_ristache »

Hello,

This is already implemented: in the XML Schema specify the sample data ("Alice", "Bob", "John", ...) as enumeration values of a simple data type that restricts the xs:string type, for example:

Code: Select all

<xs:element name="name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Bob"/>
<xs:enumeration value="Alice"/>
<xs:enumeration value="John"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
In the Generate Sample XML Files dialog select the Random value for Values of elements and attributes.


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

Post by kingargyle »

Problem is that you are limited to just those data types. I think the request is asking for a way to configure on a field by field basis, or field type basis the type of information populated into the instance.

While I agree the enumerations should be used if they are specified, but generic fields that use the built in data types need another way to configure what type of sample data can be populated there.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

I think you are limited only by the data types allowed in an XML Schema. If the type of a field is a generic built-in type of XML Schema you can have a random value of that type in the generated instance by selecting the value Random in the combo box Values of elements and attributes or you can have a default value by selecting Default in the same combo box. If you want to restrict the set of values on a field type basis then you should define a type with these values in your schema and associate the fields with this type. For example:

Code: Select all

<xs:simpleType name="PossibleValues">
<xs:restriction base="xs:NCName">
<xs:enumeration value="some_name"/>
<xs:enumeration value="otherName"/>
<xs:enumeration value="newName_here"/>
</xs:restriction>
</xs:simpleType>

<xs:element name="parentElem">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="childElem" type="PossibleValues"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="otherRootElem" type="PossibleValues"/>
Regards,
Sorin
kingargyle
Posts: 58
Joined: Fri Nov 11, 2005 6:35 am

Post by kingargyle »

I'm actually looking for something a bit different. I'm looking for a way to have a set of data that is external to the schema, not defined in enumerations (I have those defined already in the schema). This would have to be a mapping excercise and not just relying on the information in the schema to get the data populated. If it didn't find something that was in the external input, it would use what it thought best.

Content in a schema only goes so far especially when you have over 128 schemas that need to be generated.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

If it is a set of values used in many schemas you can create an XSD file and include this file in all the schemas which need the set of values. Can you specify more details? Please give an example when it would be easier with an external input than with enumerations in the XML Schemas?


Regards,
Sorin
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

I think that what Sorin is trying to say is that you have a schema then you can get a copy of that and change it to add enumerations. That is your configuration for the instance generator, use that to generate instances and you will get values as you defined in the enumerations. Does that help? Do you think you still need another support for configuring that?

Best Regards,
George
George Cristian Bina
stefan

Re: Configurable sample data for instance generator

Post by stefan »

Starting with version 10 you can define a set of sample data to be used as content for elements or attributes.
Details: http://www.oxygenxml.com/doc/ug-oxygen/ ... rator.html
Video demonstration: http://www.oxygenxml.com/demo/GenerateS ... Files.html
Post Reply