W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2002

Re: Content-restriction

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 15 Mar 2002 10:06:09 +0000
Message-ID: <175179314480.20020315100609@jenitennison.com>
To: Kai Ojansuu <clapu@pori.tut.fi>
CC: xmlschema-dev@w3.org
Hi Kai,

> Is there a way of implementing a xpath-like content-checking in
> XMLSchema?

Not within XML Schema itself. However, you can embed Schematron (which
expresses these kinds of constraints using XPaths) within an XML
Schema schema. See
http://www.topologi.com/public/Schtrn_XSD/Paper.html for more details.

> I have an application that produces this kind of xml:
> ...
> <request-params xsi:type="showstudent">
>  <param name="foo" value="bar"/>
>  <param name="id" value="234" />
>  <param name="..." value="..."/>
> </request-params>
> ...
>
> For example this doc is valid only if it has one param-element with
> name-attribute valued 'id'

If it's true that all the param elements have to have unique names,
then you could use an identity constraint in the declaration of the
request-params element:

  <xs:unique>
    <xs:selector xpath="param" />
    <xs:field xpath="@name" />
  </xs:unique>

But that's about as close as you can get with XML Schema.

If you changed your markup language so that the value of the 'name'
attribute was actually used as the name of the element then things
would be a lot easier :)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Friday, 15 March 2002 05:06:11 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:30 GMT