Re: Content-restriction

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 UTC