Page 1 of 1

Element Default Values

Posted: Tue Nov 22, 2005 7:55 pm
by integragreg
Hi,

I want to be able to automatically assign a default value for an element whenever I create a new xml document that is based on a particular schema definition. Can anyone tell me how to specify this in my xsd?

Thanks!

Greg

Clarification

Posted: Tue Nov 22, 2005 8:24 pm
by integragreg
I should probably clarify my last post.

What I want to do is have the default values automatically appear in the xml document when Oxygen generates it from the schema. I don't intend to use the default or fixed attributes in the element declaration, because I want to be able to change the value if necessary. I merely want there to be suggested default values that appear when the document is generated.

Re: Clarification

Posted: Wed Nov 23, 2005 12:14 pm
by sorin_ristache
Hello,
integragreg wrote:I don't intend to use the default or fixed attributes in the element declaration
What is the default value that you expect if you don't use the default or fixed attribute in the declaration ?

Regards,
Sorin

Posted: Wed Nov 23, 2005 1:22 pm
by integragreg
Thanks for the reply, Sorin.

The XML file that is derived from the schema is a configuration file for a software application. What I want to be able to do is generate the file from the schema and automatically insert specific element values when it's generated.

For example, let's say that my schema defines the following set of elements:

<xs:element name="serialportsettings" form="qualified">
<xs:complexType>
<xs:sequence>
<xs:element name="comport" form="qualified" type="xs:int"/>
<xs:element name="baudrate" form="qualified" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>

When Oxygen generates the XML file from this schema, I'd like for the output to automatically contain the default values of 1 and 9600 for the comport and baudrate elements, like so:

<serialportsettings>
<comport>1</comport>
<baudrate>9600</baudrate>
</serialportsettings>

This way, the person who generates the xml file will be given default values that they can change if they choose to do so.

I'm beginning to think that this might be better accomplished using xslt, rather than trying to force this through the schema. Maybe the schema definition language was not intended to be used for what I am trying to accomplish.

Posted: Wed Nov 23, 2005 1:37 pm
by sorin_ristache
Hello,

Generation of a sample document containing default values in the elements from a specified schema will be added in a future version of <oXygen/>. The current version can only generate empty elements when a new document is created based on a schema. When the feature will be added to <oXygen/> the value specified in the default attribute of xsd:element could be inserted as default element content.

Regards,
Sorin

Posted: Wed Nov 23, 2005 4:42 pm
by integragreg
Thanks. is there a projected schedule for when this feature will be released?

Posted: Thu Nov 24, 2005 12:29 pm
by sorin_ristache
Hello,

It is scheduled to be included in the next release of <oXygen/> so probably the next version will include it.

Regards,
Sorin