atom feed23 messages in org.oasis-open.lists.relax-ng-commentRe: [relax-ng-comment] Mixing pattern...
FromSent OnAttachments
Daniel PragerSep 26, 2002 7:48 pm 
Michael FitzgeraldSep 27, 2002 10:34 am 
Michael FitzgeraldSep 27, 2002 5:02 pm 
Michael FitzgeraldSep 28, 2002 11:31 pm 
Daniel PragerSep 29, 2002 6:41 pm 
Eddie RobertssonSep 29, 2002 7:16 pm 
Daniel PragerSep 29, 2002 8:37 pm 
Rick JelliffeSep 29, 2002 9:11 pm 
Daniel PragerSep 29, 2002 9:41 pm 
Rick JelliffeSep 30, 2002 2:04 am 
Yonekura KojiSep 30, 2002 3:28 am 
Robert KobergOct 7, 2002 11:05 am 
didier demanyOct 8, 2002 1:35 am 
Robert KobergOct 8, 2002 1:45 am 
Robert KobergOct 8, 2002 1:48 am 
Kohsuke KAWAGUCHIOct 8, 2002 6:32 am 
Robert KobergOct 9, 2002 11:50 am 
MURATA Makoto (FAMILY Given)Oct 9, 2002 5:26 pm 
Eddie RobertssonOct 14, 2002 4:24 pm 
Robert KobergDec 3, 2002 6:52 am 
Michael FitzgeraldDec 3, 2002 8:43 am 
James ClarkDec 3, 2002 8:57 pm 
Robert KobergDec 4, 2002 3:09 am 
Subject:Re: [relax-ng-comment] Mixing patterns and (empty) tags
From:Eddie Robertsson (erob@allette.com.au)
Date:Sep 29, 2002 7:16:42 pm
List:org.oasis-open.lists.relax-ng-comment

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

Phone: +61 3 9251 7484 Web: www.deakin.edu.au/~danielp