[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Can XML Schemas do this?

Jim Acona wrote:
> Presumably a different rule applies for attributes, whose order cannot
> be constrained in any schema language I'm aware of, but should also
> never be significant.

RELAX NG, btw, handles attributes in an interesting way. You can apply
occurrence constraints uniformly to attributes just as you would elements;
nevertheless, a compliant RELAX NG processor will not permit duplicate
attributes in an instance or trouble itself over the order of attributes,
just as it should. An example follows to make it clear how this works.

Mike, RELAX NG devotee


C:\XML\Rng\Examples>cat atts.rng
<element name="date" xmlns="http://relaxng.org/ns/structure/1.0">
 <attribute name="year"/>
  <attribute name="month"/>
  <attribute name="day"/>
  <attribute name="utc"/>

C:\XML\Rng\Examples>grep date atts_?.xml
atts_1.xml:<date year="2003" month="January" day="21" utc="-08:00"/>
atts_2.xml:<date year="2003" month="January" day="20" day="21"
atts_3.xml:<date year="2003" month="January" day="21" utc="-08:00"
atts_4.xml:<date year="2003" month="January" utc="-08:00"/>
atts_5.xml:<date year="2003" month="January" day="21"/>

C:\XML\Rng\Examples>java -jar c:\lib\jing.jar atts.rng atts_1.xml

C:\XML\Rng\Examples>java -jar c:\lib\jing.jar atts.rng atts_2.xml
Fatal error at URL "file:/C:/XML/Rng/Examples/atts_2.xml", line number 1:
Attribute "day" already
appeared in this tag.

C:\XML\Rng\Examples>java -jar c:\lib\jing.jar atts.rng atts_3.xml
Fatal error at URL "file:/C:/XML/Rng/Examples/atts_3.xml", line number 1:
Attribute "utc" already
appeared in this tag.

C:\XML\Rng\Examples>java -jar c:\lib\jing.jar atts.rng atts_4.xml

C:\XML\Rng\Examples>java -jar c:\lib\jing.jar atts.rng atts_5.xml
Error at URL "file:/C:/XML/Rng/Examples/atts_5.xml", line number 1:
unfinished element



Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.