Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


How to improve XSD for a list with differently typed items + multiplicity and uniqueness constraints

From: gvt.junk@----.--
To: xmlschema-dev@--.---
Date: 4/21/2009 5:26:00 PM
Hi Experts,

I was facing a problem to write a XML schema to define a <LIST> element t=
hat
obeys multiple rules (see below).

I finally reached a fully functional solution, but would like to know of =
an
alternate XML schema producing "better-looking" documents (with reduced n=
esting
levels).

Here are the rules the schema shall enforce for the <LIST> element:
1. The list allows a limited set of items;
   (say: <ITEM_A>, <ITEM_B> and <ITEM_C>)
2. The list does not allow duplicate items (same element name);
   (items <ITEM_A>, <ITEM_B> and <ITEM_C> can only occur 0 or 1 time in t=
he
list)
3. Order of items in the list does not matter;
4. The list must contain at least 1 item (among: <ITEM_A>, <ITEM_B> and
<ITEM_C>);
5. The content of item elements is typed and "data type" is psecific to e=
ach
item;
   (e.g.: <ITEM_A> contains integer data, while <ITEM_B> contains string =
and
<ITEM_C> a complex type)

I succeed in writing an XML schema that enforce all these rules. A compli=
ant
document look like this:
<LIST>
  <ITEM>
    <ITEM_B>100</ITEM_B>
  </ITEM>
  <ITEM>
    <ITEM_A>0</ITEM_A>
  </ITEM>
  <ITEM>
    <ITEM_C>aa-123</ITEM_C>
  </ITEM>
</LIST>

My question:
Is there any chance to write an alternate XML schema that enforce all the=
se
rules, but produce "better-looking" compliant document that would look li=
ke the
following one, with reduced nesting levels?
Really, I'm not convinced it is possible with XML schema...

<LIST>
  <ITEM_B>100</ITEM_B>
  <ITEM_A>0</ITEM_A>
  <ITEM_C>aa-123</ITEM_C>
</LIST>

I can provide the XML schema I produced to anyone interrested in this
chalenge... Just let me know: gvt {dOt} junk {a}{t} fREe {DOt} fr

Thanks and regards,
Gr=E9goire Vatry


From boris@c... Thu Apr 23 06:57:47 2009
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3.o


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent