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

Connected attribute rules in schema?

Subject: Connected attribute rules in schema?
From: "Trevor Nicholls trevor@xxxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 18 Aug 2014 12:59:29 -0000
 Connected attribute rules in schema?
An XML element has numerous potential attributes, most of them optional. In
a couple of cases, an attribute needs to be mandatory if another attribute
has a particular value. Is there a way of defining this in the document
schema?

 

For example the following might define a code fragment, consisting of text
with embedded <nl> elements. The fragment can be highlighted or not
(highlight="Y" or highlight="N"), and it can be flagged as private or not
(private="Y" or private="N"). There is an optional note attribute, which can
among other things provide a reason for the element to remain "private".

 

<xs:simpleType name="boolean">

  <xs:restriction base="xs:string">

    <xs:enumeration value="Y"/>

   <xs:enumeration value="N"/>

  </xs:restriction>

</xs:simpleType>

 

<xs:element name="nl">

  <xs:complexType/>

</xs:element>

 

<xs:complexType name="fragment" mixed="true">

  <xs:choice minOccurs="0" maxOccurs="unbounded">

    <xs:element ref="nl"/>

 </xs:choice>

  <xs:attribute name="highlight" type="boolean"/>

  <xs:attribute name="private" type="boolean"/>

  <xs:attribute name="note"/>

</xs:complexType>

 

Is there any way to indicate in the schema that the "note" attribute is
mandatory IF private="Y"?

 

Coalescing the two attributes into one (e.g. "privatereason") and using a
value or no value as equivalent to a Boolean test is not feasible because
there are legitimate cases for a note when the element is not private.

 

Thanks for any ideas

T

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
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.