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:selector xpath="param" />
    <xs:field xpath="@name" />

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 :)



Jeni Tennison
Received on Friday, 15 March 2002 05:06:11 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:55 UTC