Home Products Consulting About Us White Papers Careers Contact Us Tutorials
 

 Download Delve® SOA Fast-Prototyping Toolkit (Beta 1.0)

Tutorials - How to Declare Attributes with Defaults or Optional Values
Page 1 of 2

In the lesson “How to Declare an XML Element with Properties” we took a look at how to go about declaring an XML element with XML-Schema properties. The same basic technique applies to XML attributes as well, and in this lesson we’ll take a look at the two properties most often applied to attributes, “optional” and “default.”

XML-Schema uses the “default” property to designate an attribute as possessing a default value. This means that if a document containing that attribute doesn’t assign an explicit value to the attribute, it is assumed to have the default value. To designate properties values in Tectonic, we use the verbose form of attribute declaration, which starts with the keyword “attribute” followed by the name of the attribute being declared.

 

 

In this example, we define a type, “office-suite” with element members “address,” “num-employees,” and so on. We can create a document containing an instance of the type like so:

 

 

and take a look at its XML text using the elaboration operator.


 Download Delve® SOA Fast-Prototyping Toolkit (Beta 1.0)
Next Step

Move On To Next Step - "Creating a XML Element Instance From a Schema Definition"

Read a Detailed Product Description

Read About Delve and XML-Schema Documents in Detail

Browse Product White Papers

 
Home Products Consulting About Us White Papers Careers Contact Us Tutorials