W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2003

Re: Defining content based on attributes

From: Jeni Tennison <jeni@jenitennison.com>
Date: Tue, 23 Sep 2003 10:18:11 +0100
Message-ID: <13310434631.20030923101811@jenitennison.com>
To: "Steven Baker" <steven.baker@adazzle.com>
Cc: xmlschema-dev@w3.org

Hi Steve,

> 1 - Has anyone found a way round this using keys? My thought was
> that I could at least define which fileds must not be null using
> Keys - this right?? Anyone found any cunning ways to define a bit
> more using this or is non-null as good as it gets? (would just about
> do for my current purposes)

I'm not sure what you have in mind here, but bearing in mind that the
XPaths that are used when selecting unique nodes (and the fields that
make them unique) can't contain predicates, I doubt that you'll be
able to achieve what you want to achieve. For example, you *couldn't*
do something like:

  <xs:key name="intFields">
    <xs:selector xpath="field[@type = 'int']" />
    <xs:field xpath="output_value" />

to ensure that all <field> elements whose type was 'int' had an
value in their <output_value> child.
(Note that in XML Schema, "null" values are distinct from empty
values; <output_value/> is empty whereas <output_value
xsi:nil="true"/> is nilled. If you were using keys to ensure that
certain elements had values, you would have to label those elements in
the instance that were nilled using xsi:nil.)

> 2 - Isn't this a bit of an obvious flaw in XSD


> and is a fix / enhancement intended - essentially (as I see it,
> anyway), you can only do useful validation of data (rather than just
> structure) IF you have unique element names in your XML? I see one
> of the key benefits of XML as being is flexibility - by using common
> element names processing templates and functions are MUCH simpler -
> yes, there are work arounds but is it that big an ask to have XSD
> able to define type by element name and then, say, extend it
> depending on an attribute type (have NO idea how complex this would
> make an implementation...)

It would surprise me if the WG weren't considering adding support for
co-occurrence constraints (at least of some kinds) in the next version
of XML Schema. I'm sure it would help them decide what the
requirements for that actually are if you sent your example to the XML
Schema comments list www-xml-schema-comments@w3.org.



Jeni Tennison
Received on Tuesday, 23 September 2003 05:25:50 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:13 UTC