Re: is this a job for schematron?
Oliver Becker <[email protected]> Tue, 6 Apr 2004 17:22:57 +0200
| Newsgroups | gmane.text.xml.schematron |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Apr 06, 2004 at 11:53:54AM +0100, Peter Aberline wrote: > I want my schema to define the following rules: > > 1: The letters element must contain a, b, and c elements in any order. > 2: The letters element can also contain any number of other elements, in > any order, such as dog, cat, fish etc. [...] > Instead, would it be better to define a schema that allows any elements > under letters, and then use schematron to test if particular elements are > there, and of the correct datatype? Can schematron do this? Any advice > would be greatly appreciated. I believe datatypes are a problem since Schematron builds on XPath 1 which is not datatype aware. Things might be different with XPath 2. However, you want to assert that a, b, and c are present (besides other possible elements), so you could use something like this: <rule context="letters"> <assert test="count(a)=1">letters must contain one a element</assert> <assert test="count(b)=1">letters must contain one b element</assert> <assert test="count(c)=1">letters must contain one c element</assert> </rule> Hope that helps, Oliver -- /-------------------------------------------------------------------\ | ob|do Dipl.Inf. Oliver Becker | | --+-- E-Mail: [email protected] | | op|qo WWW: http://www.informatik.hu-berlin.de/~obecker | \-------------------------------------------------------------------/ ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click