Re: Search strategy that returns hits and context?

Thomas Passin <[email protected]>
Newsgroups gmane.text.xml.devel
Message-ID <[email protected]>
It depends on what you mean by "display" and what you want to 
accomplish. Since you use the word "display", I suppose you mean that a 
person will read this on a computer screen - as opposed to, e.g., having 
some computer program make use of the results.

For human reading, it's a good idea to eliminate as much clutter as 
possible.  Showing the entire document or even a reduced version as in 
your second suggestion will involve a lot of clutter.

If the user may want to look at the relevant part of the original 
document, then you could make the result contain a hyperlink to the 
original context.

You also need to decide what to do if there are repeated elements like 
<Context1> or <ItemA>.

On 11/10/2022 9:48 AM, Roger L Costello 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
> 


_______________________________________________________________________

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.