xml schema constraints

1 view
Skip to first unread message

chinoka

unread,
Feb 25, 2008, 8:08:35 AM2/25/08
to XML Schema
Hi,
I am new to XML Schema and I am facing a requirement that I'm not sure
it can be done. I will post it here to see if anyone can help me.

Given the following XML abstract:

<a>
<b name="elementB_1" type="type1"/>
<b name="elementB_2" type="type2" />
</a>

<elementB_1>
......
</elementB_1>

<elementB_2>
......
</elementB_2>

I would like to produce an XML schema that can describe the preceding
XML.

There are 2 things I don't know how to do...

1) There could be more than 2 elements "b" inside "a". But their
possible attributes (name and type) are predefined. In this example, I
would like to restrict the attributes to the following set:
name=elementB_1 , type=type1
name=elementB_2 , type = type2
name=elementB_3 , type=type3

2) Do you see how after <a> there are two elements defined with names
equal to the names in elements "b"? I want to restrict the existence
of these elements to those defined inside element "a". So, in this
example if I add an element "b" within "a" to the xml, I will have to
add an element "elementB_3" too... like so:

<a>
<b name="elementB_1" type="type1"/>
<b name="elementB_2" type="type2" />
<b name="elementB_3" type="type3" />
</a>

<elementB_1>
......
</elementB_1>

<elementB_2>
......
</elementB_2>

<elementB_3>
......
</elementB_3>


Is this possible??? Can anyone show me how to do this?

Thanks!



Reply all
Reply to author
Forward
0 new messages