RE: Finding Unique values in a set area??

"Edvard Robertsson" <[email protected]> Sun, 18 Jan 2004 13:44:26 +0100
Newsgroups gmane.text.xml.schematron
Message-ID <[email protected]>
Hi Chad,

It's been a while since the post so I'm not sure if the question is still 
valid but below is one solution.

>Within each Router I can have multiple Device elements and each of them can 
>have
>one PeerMap element.  In each PeerMap can be multiple Peer elements.  What 
>I
>need to do is verify that the LocalViewAddress and VirtualAddress are 
>unique
>within a PeerMap element, amongst all the Peers.  They can be the same if 
>they
>are in different Device/PeerMaps.  I've tried a ton of variations of the
>following with no success:
>
>   <sch:pattern name="PeerMap Validation">
>     <sch:rule context="PeerMap">
>       <sch:assert test="count ( //PeerMap [Peer/@VirtualAddress =
>current()/Peer/@VirtualAddress] ) = 1" diagnostics="router_id">Peer:
>VirtualAddress is not unique!</sch:assert>
>       <sch:assert test="child::Peer/@LocalViewAddress"
>diagnostics="router_id">Peer: LocalViewAddress is missing!</sch:assert>
>       <sch:assert test="child::Peer/@VirtualAddress"
>diagnostics="router_id">Peer: VirtualAddress is missing!</sch:assert>
>     </sch:rule>
>   </sch:pattern>
>
>I've tried changing the context path, the paths in the count arguments with 
>no
>success.  Please let me know how I need to fine tune this.

This should work:

<sch:pattern name="Router Validation">
    <sch:rule context="Router/Device/PeerMap">
        <sch:assert test="Peer/@LocalViewAddress">Peer: LocalViewAddress is 
missing!</sch:assert>
        <sch:assert test="Peer/@VirtualAddress">Peer: VirtualAddress is 
missing!</sch:assert>
    </sch:rule>
    <sch:rule context="Router/Device/PeerMap/Peer">
        <sch:assert 
test="count(following-sibling::Peer[current()/@LocalViewAddress = 
@LocalViewAddress]) != 1">LocalViewAddress is not unique within the 
PeerMap.</sch:assert>
        <sch:assert 
test="count(following-sibling::Peer[current()/@VirtualAddress = 
@VirtualAddress]) != 1">VirtualAddress is not unique within the 
PeerMap.</sch:assert>
    </sch:rule>
</sch:pattern>

Cheers,
/Eddie

>
>Thanks, chad
>____________________________________________________________
>
>Chad Williamson, B.Sc. CE                                    BOW Networks 
>Inc.
>Software Developer                                                 #200, 
>550-71
>Avenue S.E.
>TEL: (403) 640-8422                                                  
>Calgary,
>Alberta
>FAX: (403) 253-8979                                                  T2H 
>0S6
>e-mail: [email protected]
>---------------------------------------------------------------------------------------------------------
>
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: IBM Linux Tutorials.
>Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
>Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
>Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
>_______________________________________________
>Schematron-love-in mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/schematron-love-in

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn