[XML4Lib] Help with XPATH in a Schematron document
Conal Tuohy
conal.tuohy at vuw.ac.nz
Wed Jun 6 19:01:26 EDT 2007
On Wed, 2007-06-06 at 15:18 -0400, Schlosser, Melanie Brynn wrote:
> 1. I want it to check for the type attribute in <list>, and make sure
> the content matches one of the four values listed. Right now it doesn't
> notice if I remove the attribute.
>
> <sch:rule id="r12" context="list">
> <sch:assert role="M" test="@type='simple' or
> @type='ordered' or @type='footnotes' or @type='bibliography'"
> >List elements must have a 'type' attribute with the
> value simple|ordered|footnotes|bibliography.</sch:assert>
> </sch:rule>
I'll wager this is because you are using a TEI DTD which defines
"simple" as the default value of list/@type?
> 2. The rend attribute is optional, but if it is present, the only value
> is 'blockquote.' As it is, it doesn't notice if I change 'blockquote'
> to something else.
>
> <sch:rule id="r13" context="quote/@rend">
> <sch:assert role="M" test="normalize-space(.) = 'blockquote'"
> >'Blockquote' is the only acceptable value for the 'rend'
> attribute in 'quote'.</sch:assert>
> </sch:rule>
I don't know about this one ... but I notice the text of your assertion
says "Blockquote" while the XPath says "blockquote".
> 3. I want to make sure there are no elements inside <placeName> besides
> country, region and settlement. I know this isn't the correct XPATH for
> this, but I can't figure out how to use the syntax I used for <front>
> and <back> on this one (see below).
>
> <sch:rule id="r14" context="placeName">
> <sch:assert role="M" test="country|region|settlement"
> >PlaceName must contain only country, region, or settlement
> elements.</sch:assert>
> </sch:rule>
Try
<sch:rule id="r14" context="placeName/*">
<sch:assert role="M" test="self::country|self::region|self::settlement"
>placeName must contain only country, region, or settlement elements.</sch:assert>
</sch:rule>
>
> 4. This is the same situation as 'blockquote'. It's commented out in
> the document below because as it is it actually breaks the validator.
>
> <sch:rule id="r16" context="placeName/region/@type">
> <sch:assert role="M" test="@type='state' or @type='county'
> or @type='province'"
> >Region's optional 'type' attribute must have the value
> "state," "county," or "province."</sch:assert>
> </sch:rule>
The test should be ".='state' or .='county' or .='province'"
Cheers!
More information about the XML4Lib
mailing list