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

 

luis.costa@alert.pt

 

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@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.