XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
lucrecia chiartanoSubject: XMLSchema - optional attributeGroup definition
Author: lucrecia chiartano
Date: 20 Jan 2005 06:53 AM

Hello,

Can anyone help me to find a way to reference a group of attributes as optional?
Here I describe my problem,
thanks a lot,

Lucrecia Chiartano

-----------------------

I must define within a schema a rule that allows an xml leaf-node to carry with it two attributes.
Both of them may be present or not, but if only one exists it must be a precise one (attribute1 within next examples).

(Ex1 :--> allowed <node attribute1="attr1" attribute2="attr2">nodetext</node>)
(Ex2 :--> allowed <node>nodetext</node>)
(Ex3 :--> allowed <node attribute1="attr1">nodetext</node>)
(Ex4 :--> NOT allowed <node attribute2="attr2">nodetext</node>)


If 'attribute1' and 'attribute2' where just tags instead of attributes I could bound the rule defining an optional group with a required tag ('attribute1') and an optional one ('attribute2').
But they must be attributes, and I found that they can be grouped only using the xsd:attributeGroup tag that admits not a 'minOccurs' or a 'use' attribute (and then cannot be referenced as optional).


Here's the code I'm using

<xsd:element name="tagName">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attributeGroup ref="attrGroupName"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>

....

<xsd:attributeGroup name="attrGroupName">
<xsd:attribute name="attr1" type="xsd:string"/>
<xsd:attribute name="attr2" type="xsd:string" use="optional"/>
</xsd:attributeGroup>

....

Posttop
Ivan PedruzziSubject: XMLSchema - optional attributeGroup definition
Author: Ivan Pedruzzi
Date: 25 Jan 2005 12:49 AM
Lucrecia,


As far as i know XML Schema is not capable to express the attribute
presence conditionalized on another attribute.

You need to use a different schema language like Schematron to do it.

Ivan

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

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