[oXygen-user] Schematron for each element validation
George Cristian Bina
Tue Nov 4 14:49:00 CST 2008
Dear Luis,
Your description of the problem differs clearly from what you put in the
Schematron schema. From your description it looks you want
<sch:rule context="Root/Element">
<sch:assert test="count(.//Element4)=1">There should be only one
element Element4 in Root/Element</sch:assert>
</sch:rule>
but from your schema it looks like you want
<sch:rule context="Root/Element/Element2[@name='Attribute1']/Element3">
<sch:assert test="count(Element4)=1">There should be only one
element Element4 in
Root/Element/Element2[@name='Attribute1']/Element3</sch:assert>
</sch:rule>
Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
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?
>
>
>
>
>
> 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
>
>
>
> <mailto:>
>
>
>
> 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
>
> <mailto:>
>
>
>
> 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.
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> oXygen-user mailing list
>
> http://www.oxygenxml.com/mailman/listinfo/oxygen-user
More information about the oXygen-user
mailing list