Re: Search strategy that returns hits and context?

Rick Jelliffe <[email protected]>
Newsgroups gmane.text.xml.devel
Message-ID <CADUdYQWvYdsiDjYQfDE0Afpndevz9rMph_OBdNdtFcK6OwpmmA@mail.gmail.com>
1) SVRL

<sch:schematron ...>
<sch:pattern ..>
<sch:rule context="*[contains(text(), 'abc')]" ...>
<sch:report test="true()"  role="info" id="has-ABC">
   Element contains 'abc' should be processed specially: '<sch:value-of
select="."/>
</sch:report>
</sch:rule>
</sch:pattern>
<sch:schema>

The SVRL result will typically contain an XPath to the context (in the
@location attribute) and the assertion  text will contain the full path.
(The implementation may provide alternate Xpaths to suit your use.)

You can add whatever other info you want to report, either as rich, dynamic
text (in the assertion or an sch:diagnostics element) or as generated
elements in some other namespace (using sch:properties).

So the SVRL would contain both XPaths to, say, the context, and as much of
the text value as desired, plus whatever ancillary annotations you want
transferred.

Plus you can state the intent of finding 'abc' so that the maintainer and
the recipient are well-informed. (Just being able to say "I found abc" is
something, but it will always be part of some pipeline or SDLC, and each
stage of the pipeline or SDLC needs to play nicely with the next  not
assume it is in magnificent isolation.)

2) XML Fragments

There was a W3C specification for fragments, which were (well-formed)
partial documents that provided full ancestor context down to the elements
of interest. I liked it, and if you are looking for something, it is a good
place to start.

XML Fragments never made it into the mainstream though AFAIK: it was
especially aimed at query results IORC, which was too much an intrusion
into what people hoped might be proprietary opportunities. Also, I don't
think it could be workable without the ubiquity of some different
validation approach than binary-validity: e.g. some idea of partial
validity (which Trang implemented) or Schematron phases.

On Fri, 11 Nov 2022, 1:49 am Roger L Costello, <[email protected]> wrote:

> Hi Folks,
>
> I have this XML document:
>
> <Test>
>     <Context1>
>         <ItemA>abc - yes!</ItemA>
>         <ItemB>def</ItemB>
>     </Context1>
>     <Context2>
>         <ItemC>ghi</ItemC>
>         <Context3>
>             <ItemD>abc ... oky-dokey</ItemD>
>             <ItemE>jkl</ItemE>
>         </Context3>
>     </Context2>
>     <Context4>
>         <ItemF>mno</ItemF>
>     </Context4>
> </Test>
>
> I want to know if the document contains the string "abc". I want software
> to search the document for all occurrences of "abc" and I want the results
> of the search to show both the value that "abc" is part of and the value's
> context. In the above XML document there are two occurrences of "abc", one
> in the <ItemA> element and the other in the <ItemD> element.
>
> I can think of two ways to display the search results. I describe the two
> ways below. Are there other ways?
>
> One way is to return, for each occurrence, the element value and the path
> to the element, e.g.,
>
> abc - yes!
> /Test/Context1/ItemA
>
> abc ... oky-dokey
> /Test/Context2/Context3/ItemD
>
> Another way is to show the entire document, omitting the portions that do
> not contain the desired search value, e.g.,
>
> <Test>
>     <Context1>
>         <ItemA>abc - yes!</ItemA>
>     </Context1>
>     <Context2>
>         <Context3>
>             <ItemD>abc ... oky-dokey</ItemD>
>         </Context3>
>     </Context2>
> </Test>
>
>
> _______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: [email protected]
> subscribe: [email protected]
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.