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>

....

Postnext
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

Postnext
siddharth srivastavSubject: XMLSchema - optional attributeGroup definition
Author: siddharth srivastav
Date: 08 May 2011 11:09 PM
Hi,

Can anyone help me with the below problem:

I have to define a attribute group for 2 mutually inclusive data elements. In the below example if TO_DT is present FROM_DT has to be present and TO_DT is not present then FROM_DT is not present.

I thought of creating these as mandatory attributes and define attributegroup as optional but its not working:

<xs:attributeGroup name="DateRangeAttributes" id="Element_Common_545">
<xs:attribute name="TO_DT" type="xs:date" use="required" id="Element_Common_547"/>
<xs:attribute name="FROM_DT" type="xs:date" use="required" id="Element_Common_546"/>
</xs:attributeGroup>

Can anyone suggest a way to handle this using attributes

Thanks,
Siddharth

Postnext
siddharth srivastavSubject: Advantages of using attributes over data elements
Author: siddharth srivastav
Date: 08 May 2011 11:21 PM
Hi,

I am new to XML schema and currently looking for some guideline on attributes or data elements.

Please help

Thanks,
Siddharth

Posttop
Ivan PedruzziSubject: Advantages of using attributes over data elements
Author: Ivan Pedruzzi
Date: 18 May 2011 02:45 AM


Attributes should be used to hold small amount of data like IDs or short strings and when the order on which they appear is not relevant.

For everything else elements are more flexible.





 
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-2016 All Rights Reserved.