Re: Compare 2 instance documents

Rick Jelliffe <[email protected]> Sat, 20 Sep 2003 16:26:17 +1000
Newsgroups gmane.text.xml.schematron
Message-ID <[email protected]>
Marty wrote:

> =93Am I going past the intention of schematron if I use=20
> schematron rules to provide the ability of a candidate=20
> instance document to match a target document=94?

No. =20

At the Open Publish Asia/Pacific 2003 Conference a few
months ago, I gave a presentation specifically centering=20
on this point.  The slides (try doing that with PowerPoint:-)
are at
    http://www.topologi.com/resources/pdfs/OpenPublish2003.pdf

To summarize the argument:=20

1) We can characterize a basic few kinds of distinct dataflows=20
(Use Cases) for how XML is used:=20
 - transformation
 - read/write
 - pipelines

2) Each of these different kinds of data flows have different=20
requirements.

3) We can therefore match the requirements against the capabilities
of different schema languages to see which is best-ish.=20

....
n) Therefore Schematron is the current best for transformations,=20
WXS is the current best for pipelines, and RELAX NG is the current
best for read/write.  (Not to say that there are not other factors
at play too.)

Cheers
Rick Jelliffe

>Hi,
>
>I=92ll provide some background, but my general question is; =93Am I goin=
g past the intention of schematron if I use schematron rules to provide t=
he 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 th=
e 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 =
extension functions to my XSL processor to do Soundex or Metaphone.  I co=
uld 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 thi=
s 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 unnatura=
l 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.">Ci=
ty - not matched.</assert>
>    </rule>
>  </pattern>
>  <pattern id=3D"statePattern">
>    <rule context=3D"state">
>      <assert test=3D"string-length(.) &gt; 0">State is required.</asser=
t>
>    </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
>_______________________________________________
>Schematron-love-in mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/schematron-love-in
> =20
>




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