Finding Unique values in a set area??

"Chad Williamson" <[email protected]> Fri, 19 Dec 2003 17:03:06 -0700
Newsgroups gmane.text.xml.schematron
Message-ID <[email protected]>

Happy Holidays everyone :-)

I'm trying to verify unique values in a set area and haven't been able to focus
the area to do this on.  Here is part of my valid xml file structure:

<ConfigurationRoot ConfigurationVersion="0.01" FileVersion="0.02">
   <Router RouterID="Alhambra_Router_A">
     <Device DeviceElementID="Alhambra_TIE_A" VirtualAddress="3"
ActualAddress="0" ListenCluster="1"/>
      <Device DeviceElementID="IED11" VirtualAddress="1101" ActualAddress="1102"
FixedHostAddress="911">
         <PeerMap>
            <Peer LocalViewAddress="1" VirtualAddress="2"/>
            <Peer LocalViewAddress="3" VirtualAddress="4"/>
            <Peer LocalViewAddress="5" VirtualAddress="6"/>
            <Peer LocalViewAddress="7" VirtualAddress="8"/>
         </PeerMap>
      </Device>
     <Device DeviceElementID="IED53" VirtualAddress="5301" ActualAddress="5302"
FixedHostAddress="953">
         <PeerMap>
            <Peer LocalViewAddress="9" VirtualAddress="2"/>
            <Peer LocalViewAddress="1" VirtualAddress="4"/>
            <Peer LocalViewAddress="3" VirtualAddress="6"/>
            <Peer LocalViewAddress="5" VirtualAddress="8"/>
         </PeerMap>
      </Device>
   </Router>
...other Router elements.
</ConfigurationRoot>

I can have multiple Router elements, each with a unique RouterID and I was able
to properly enforce as such:
  <sch:pattern name="Router Validation">
    <sch:rule context="Router">
      <sch:assert test="@RouterID" diagnostics="router_id"> RouterID is missing!
</sch:assert>
      <sch:assert test="count ( //Router [@RouterID = current()/@RouterID] ) =
1" diagnostics="router_id"> RouterID must be unique! </sch:assert>
    </sch:rule>
  </sch:pattern>

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.

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