[Schematron] Schematron for each element validation

Kendall Shaw skendall at atypon.com
Tue Nov 4 13:11:58 EST 2008


Luis Costa wrote:
>
> Hi all,
>
> My goal is to test if there is only one Element4 in each Root/Element.
>
> I try to do this validation with schematron “a” but the result I have 
> got is the wrong one because “a” is testing if there is only one 
> Element4 in all xml “b” and that is not my intend.
>
> Can anyone help me?
>
You could assert that count(.//Element4) = 1. Your current rule is 
asserting that there is an Element4 in a specific location that has a 
text value that equals 1 when converted to a number.

Kendall
>
>
>
> a)
>
> <sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
>
> <sch:title>XXX</sch:title>
>
> <sch:phase id="yyy">
>
> <sch:active pattern="rrr" />
>
> </sch:phase>
>
> <sch:pattern id="rrr">
>
> <sch:rule context="Root/Element">
>
> <sch:assert test="Element2[@name='Attribute1']/Element3/Element4 = 
> 1">Attribute1 shall be single Element4</sch:assert>
>
> </sch:rule>
>
> </sch:pattern>
>
> </sch:schema>
>
> b)
>
> <Root>
>
> <Element>
>
> <Element2 name="Attribute1">
>
> <Element3>
>
> <Element4>Smitty</Element4>
>
> </Element3>
>
> </Element2>
>
> <Element2 name="Attribute2">
>
> <Element3>
>
> <Element4>Cleveland Clinic</Element4>
>
> <Element4>Parma Community</Element4>
>
> </Element3>
>
> </Element2>
>
> </Element>
>
> <Element>
>
> <Element2 name="Attribute1">
>
> <Element3>
>
> <Element4>Dopplemeyer</Element4>
>
> </Element3>
>
> </Element2>
>
> <Element2 name="Attribute2">
>
> <Element3>
>
> <Element4>Cleveland Clinic</Element4>
>
> <Element4>Berea Community</Element4>
>
> </Element3>
>
> </Element2>
>
> </Element>
>
> </Root>
>
> Thank you for your attention and best regards,
>
> Luís Costa
>
> Software Developer
>
> luis.costa at alert.pt <mailto:luis.costa at alert.pt>
>
> www.alert-online.pt <http://www.alert-online.pt/>
>
> ALERT Life Sciences Computing, S.A.
>
> Edifício Lake Towers – pisos 7, 8 e 9
>
> Rua Daciano Baptista Marques, n.º 245
>
> 4400-617 Vila Nova de Gaia
>
> Portugal
>
> Tel.: +351 22 832 89 80
>
> Fax.: +351 22 832 89 82
>
> info at alert.pt <mailto:info at alert.pt>
>
> This e-mail is privileged, confidential and contains private 
> information. Any reading, retention, distribution or copying of this 
> communication by any person other than its intended recipient is 
> prohibited.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Schematron mailing list
> Schematron at eccnet.com
> http://www.eccnet.com/mailman/listinfo/schematron
>   




More information about the Schematron mailing list