OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng-comment message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: Re: [relax-ng-comment] Mixing patterns and (empty) tags


Hi Daniel,

>Thanks for your explanations and suggestions.
>
>It seems that I currently have two options:
>
>1. Unsafe: Use unrestricted text and check the text elsewhere
>   (as originally suggested my Mike).
>
There might be one more option if the validation time of the application 
isn't critical which is to embedd Schematron rules in your RELAX-NG 
schema to check that the unrestricted text content match your defined 
constraints. Here is an example of how this could look for the example 
provided by Mike:

<?xml version="1.0" encoding="UTF-8"?>
<element name="example" xmlns="http://relaxng.org/ns/structure/1.0";>
    <sch:pattern name="Check the text content" 
xmlns:sch="http://www.ascc.net/xml/schematron";>
        <sch:rule context="example">
            <sch:assert test="text()[1] = 'The quick '" >The first text 
node must be 'The quick '.</sch:assert>
            <sch:assert test="text()[2] = ' brown fox '" >The second 
text node must be ' brown fox '.</sch:assert>
            <sch:assert test="text()[3] = ' jumped over the lazy dog 5 
times.'">The third text node must be ' jumped over the lazy dog 5 
times.'.</sch:assert>
            <sch:assert test="normalize-space(.) = 'The quick brown fox 
jumped over the lazy dog 5 times.'">The whole text must be 'The quick 
brown fox jumped over the lazy dog 5 times.'.</sch:assert>
        </sch:rule>
    </sch:pattern>
    <interleave>
        <text/>
            <element name="a"><empty/></element>
            <element name="b"><empty/></element>
            <element name="c"><empty/></element>
    </interleave>
</element>

As you can see you can make assertions about each text node separataly 
or as a whole. In Schematron you have access to all the String and 
Number fucntions in XPath so can make fairly complex assertions about 
the text even if you can't use regular expressions. For more info on how 
to embedd Schematron rules in RELAX-NG schemas (or W3C XML Schema) see [1].

Cheers,
/Eddie

[1] http://www.topologi.com/public/Schtrn_XSD/Paper.html

>
>2. Inelegant: Wrap the text bits in their own tags
>    (as more recently suggested by Mike).
>
>I'll probably be going with the former for the moment (since
>I can check non-schema constraints elsewhere if needed).
>
>However, I'm curious as to whether this limitation could be lifted.
>It seems to me that this might be done either using the <interleave>
>idiom, or without by requiring each text fragment to form a complete
>pattern.
>
>Opinions?
>
>Thanks again
>
>Daniel
>
>--
>Dr Daniel Prager
>Research Fellow & Consultant
>Deakin University & Freelance
>
>Phone: +61 3 9251 7484
>Web: www.deakin.edu.au/~danielp
>
>
>
>----------------------------------------------------------------
>To subscribe or unsubscribe from this elist use the subscription
>manager: <http://lists.oasis-open.org/ob/adm.pl>
>  
>



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC