Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


xml schema - restricted element content together with attributes

From: "Lee Brown" <lbrown@----------.--->
To: <xmlschema-dev@--.--->
Date: 6/11/2004 3:19:00 PM
What is the best practice for an XML schema describing an element with =
one or more
attributes plus data content, where the data content is not a supplied =
data type and
neither is it shared by other tags?

For example:

<tag1 attr="value1">some data</tag1>
<tag2 attr="value2">other data</tag2>

where I would like to describe each <tag> content something like

<xsd:restriction>
    <xsd:enumeration value="red"/>
    <xsd:enumeration value="blue"/>
    <xsd:enumeration value="green"/>
</xsd:restriction>

The short question is simply: what's the preferred way to do that?

The separate longer question is more specific.  In my particular case, =
there are many
different elements, each with a different description of the data =
content.  There are only
a small number of different attributes, where the same attribute could =
be used by several
elements.  It happens that the attribute definition is loosely related =
to the value's base type
(that is, the data content of all elements using a certain attribute =
might be based on
xsd:string, the data content of all elements using a certain other =
attribute might be based
on xsd:int, etc.)

That suggests to me that I should create my own base types, one for each =
attribute, that
describe both the attribute and the base type of the data content.  Then =
my element
definitions would be derived and further restrict the data content.  I =
can't figure out how
to do that.

So here's the exercise for the interested, what's the most efficient XML =
schema for
something like this, understanding that there are many more elements and =
maybe a few
more attributes:

element A accepts attribute "text" and string data "red", "blue", =
"green".
element B accepts attribute "text" and string data with a length less =
than 5.
element C accepts attribute "number" and numeric data between 100 and =
200.
element D accepts attribute "number" and numeric data between 1 and 10.

Thanks,
Lee


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