Compare 2 instance documents

"Bradley, Martin" <[email protected]> Thu, 30 Oct 2003 08:50:02 -0500
Newsgroups gmane.text.xml.schematron
Message-ID <[email protected]>
Hi all,

I've finally gotten back to this...

I sent a message about comparing 2 instances documents about a month ago
and I have modified the example slightly.  I created two extension
functions one does a soundex and the other does a table lookup for a
value.  Both functions will return a match score.  

What I would like to do is assign a "threshold" value on the address tag
and then average the scores of the child element matches (city and
state).  If the address threshold is 80 and the average threshold of the
child element match scores is >= 80 then I have a match otherwise a no
match.

I read a brief paper from Rick on "Optimizing Time Performance of
Schematron" and he spoke of scores but they may just be similar in name.
I'm still researching but every way I've come up with to try to do this
in one pass with Schematron has led me into what seems like ugly hacks.
The question is; is there a way to do this in schematron using the IoC
hooks provided by Schematron or is this really a 2 step process 1)
create an instance doc with just scores all the elements and then
consolidating the scores to test the thresholds at different levels in
the hierarchy.

I'm still new to Schematron and I've been trying to "back in" to a
solution using XSL and trying to create Schematron rules that generate
the XSL I'm looking for.

Any thoughts or suggestions, a pointer to research material would work
too.  If anyone else is interested in what I end up with I'll publish it
to this group.

Thanks for any help.
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 threshold="80">
  <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="http://www.ascc.net/xml/schematron">
  <title>target matching rules</title>
  <phase id="address">
    <p>City, State Zip information.</p>
    <active pattern="cityPattern" />
    <active pattern="statePattern" />
    <active pattern="zipPattern" />
  </phase>
  <pattern id="cityPattern">
    <rule context="address/csz/city">
      <assert
test="soundex(document('candidate.xml')/address/csz/city,.)">City - not
matched.</assert>
    </rule>
  </pattern>
  <pattern id="statePattern">
    <rule context="state">
      <assert
test="lookup(document('candidate.xml')/address/csz/state)">State not
found.</assert>
    </rule>
  </pattern>
  <pattern id="zipPattern">
    <rule context="zip">
      <assert test="string-length(.) &gt; 0">Zip is required.</assert>
    </rule>
  </pattern>
</schema>
 
NOTICE: This E-mail may contain confidential information. If you are not
the addressee or the intended recipient please do not read this E-mail
and please immediately delete this e-mail message and any attachments
from your workstation or network mail system. If you are the addressee
or the intended recipient and you save or print a copy of this E-mail,
please place it in an appropriate file, depending on whether
confidential information is contained in the message.




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/