Compare 2 instance documents

<[email protected]> Fri, 19 Sep 2003 16:38:51 -0400
Newsgroups gmane.text.xml.schematron
Message-ID <[email protected]>
Hi,

I=92ll provide some background, but my general question is; =93Am I going=
 past the intention of schematron if I use schematron rules to provide th=
e ability of a candidate instance document to match a target document=94?=


For example, I borrowed from the Schematron tutorial (thanks by the way) =
to create the following sample candidate.xml and target.xml, if I use the=
 rules.sch file against the target the =93incoming candidate=94 data for =
address/csz/city doesn=92t match.  That=92s cool.  Next I=92ll add some e=
xtension functions to my XSL processor to do Soundex or Metaphone.  I cou=
ld then use these functions for a different type of match (good so far?)

If it isn=92t obvious by now, I=92m new to Schematron, but if I work this=
 correctly into my XSD I can define =93match rules=94 to any level of my =
target schema.  Does this make sense or am I trying to force an unnatural=
 act on Schematron?

Has anyone else done anything like this?

Thanks for any feedback=85

Marty

Sample matcher:

-----------------
candidate.xml
<address>
  <addr1>
    <streetnumber>1234</streetnumber>
    <streetname>Main</streetname>
    <streetsuffix>Street</streetsuffix>
  </addr1>
  <csz>
    <city>Anytownmisspelled</city>
    <state>VA</state>
    <zip>12345</zip>
  </csz>
</address>

--------------------
target.xml
<address>
  <addr1>
    <streetnumber>1234</streetnumber>
    <streetname>Main</streetname>
    <streetsuffix>Street</streetsuffix>
  </addr1>
  <csz>
    <city>Anytown</city>
    <state>VA</state>
    <zip>12345</zip>
  </csz>
</address>

----------------------
rules.sch
<schema xmlns=3D"http://www.ascc.net/xml/schematron">
  <title>target matching rules</title>
  <phase id=3D"address">
    <p>City, State Zip information.</p>
    <active pattern=3D"cityPattern" />
    <active pattern=3D"statePattern" />
    <active pattern=3D"zipPattern" />
  </phase>
  <pattern id=3D"cityPattern">
    <rule context=3D"address/csz/city">
      <assert test=3D"document('candidate.xml')/address/csz/city=3D.">Cit=
y - not matched.</assert>
    </rule>
  </pattern>
  <pattern id=3D"statePattern">
    <rule context=3D"state">
      <assert test=3D"string-length(.) &gt; 0">State is required.</assert=
>
    </rule>
  </pattern>
  <pattern id=3D"zipPattern">
    <rule context=3D"zip">
      <assert test=3D"string-length(.) &gt; 0">Zip is required.</assert>
    </rule>
  </pattern>
</schema>






-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf