[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Announce: XML Schema, The W3C's Object-Oriented Descriptio


descriptio house
John Cowan wrote:
>> For example, at the ISO DSDL meeting we had a suggested requirement
>> from a large European publishing house that we can validate than a
>> mixed content element in the Dutch language should only contain
>> Dutch characters.
>
> An interesting idea. All schema languages known to me are weak in
> supporting mixed content; even RNG, which is the strongest, cannot
> express this constraint. (I don't really know Schematron: can it
> cope?)

Come XPath 2.0, and assuming that it supports regular expressions like
those in XML Schema, Schematron would be able to test this with
something like:

<sch:rule context="mixedContentElement[lang('nl')]">
  <sch:assert
    test="match(string(.),
                '^(/p{IsBasicLatin}|/p{IsLatin-1Supplement}|...)*$')">
    A Dutch-language <sch:name /> element must contain only Dutch
    characters.
  </sch:assert>
</sch:rule>

Before then, you could still use Schematron, but the test would be
pretty nasty -- create a string that contained the relevant characters
and then use translate() to test whether it contains any other
strings.

In general, Schematron's as good at mixed content as it is at
text-only content because XPath can give you access to the individual
text nodes between the elements in mixed content. For example, if you
had something like:

<length>12.5<unit>cm</unit></length>

in XML Schema you could state that the length element had mixed
content and had to contain a unit element:

<xs:element name="length">
  <xs:complexType mixed="true">
    <xs:element name="unit" type="lengthUnit" />
  </xs:complexType>
</xs:element>

in RELAX NG you could additionally state that the text had to come
before the unit element:

<element name="length">
  <text />
  <element name="unit"><ref name="lengthUnit" /></element>
</element>

and in Schematron you could state that the text node child of the
length element had to be a number (here using the fact that NaN !=
NaN):

<sch:rule context="length/text()">
  <sch:assert test="number(.) = number(.)">
    The text within the length element must be a number.
  </sch:assert>
</sch:rule>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.