Subject: Re: [xsl] Connected attribute rules in schema? From: "Michael Schäfer michael.schaefer@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 18 Aug 2014 13:34:32 -0000 |
What version of XML Schema do you use? AFAIK, XSD 1.1 offers some support in this direction, but I've stuck with 1.0 at the moment and don't know if they will meet your requirements.
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
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe <-list/696613> (by email <>)
-- ___________________________________________
C302 IT-Kompetenzzentrum Datenerhebung und Aufbereitung
michael.schaefer@xxxxxxxxxxx www.destatis.de
DESTATIS wissen.nutzen. | Statistisches Bundesamt
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Connected attribute rules in , Trevor Nicholls trev | Thread | Re: [xsl] Connected attribute rules, Trevor Nicholls trev |
[xsl] Connected attribute rules in , Trevor Nicholls trev | Date | [xsl] Comparing attributes and sett, varun bhatnagar varu |
Month |