RELAX NG - How to define "oneOrMore" for attributes?

R

Robert Dailey

Hi,

I have a specific element that has 2 attributes. I want to force the
XML to use 1 or more of these attributes in any order. For example:

<Offset x="0" y="1"/>

could be

<Offset x="0"/>

or could be

<Offset y="1"/>

but could NOT be (invalid):

<Offset/>


I want to do this without any schema code duplication (for example, no
duplicating of attribute definitions).

Thanks.
 
U

usenet

Hi,

I have a specific element that has 2 attributes. I want to force the
XML to use 1 or more of these attributes in any order. For example:

<Offset x="0" y="1"/>

could be

<Offset x="0"/>

or could be

<Offset y="1"/>

but could NOT be (invalid):

<Offset/>

I want to do this without any schema code duplication (for example, no
duplicating of attribute definitions).

Thanks.

My take is that you can't do it without duplication. e.g. you have to
do something like:

<choice>
<group>
<attribute name="x"/>
<optional>
<attribute name="y"/>
</optional>
</group>
<attribute name="y"/>
</choice>

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic
for XML Schema to C++ data binding visit
http://www.codalogic.com/lmx/
=============================================
 
B

Bjoern Hoehrmann

* Robert Dailey wrote in comp.text.xml:
I have a specific element that has 2 attributes. I want to force the
XML to use 1 or more of these attributes in any order. For example:

<Offset x="0" y="1"/>

could be

<Offset x="0"/>

or could be

<Offset y="1"/>

but could NOT be (invalid):

<Offset/>

I want to do this without any schema code duplication (for example, no
duplicating of attribute definitions).

RELAX NG has no operator for this, you have to combine the options in a
choice or use e.g. Schematron to specify that at least one attribute has
to occur. You can avoid giving the attribute definitions multiple times
by using a named pattern (<define> and <ref>).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top