[Newbie] Text in nested tags

F

Federico

Hi all,

I have some texts codifed in XML and I'implementing eXist
(http://exist.sourceforge.net) for textual researches.

The XML file I obtain after the query from eXist, highlight the word
searched with the tag <exist:match>

So the situation is (if we have searched for the word "ago" for
example)

<p>Call me Ishmael. Some years <exist:match>ago</exist:match> -- never
mind how long precisely -- having little or no money....</p>

I should be able to select a prefixed number of words (four for
example) before and after the <exist:match>, so that the result should
be:

<p>me Ishmael. Some years <exist:match>ago</exist:match> -- never mind
how long</p>

Now I can apply an XSL Stylesheet to present this result in HTML.

But How can I select backwards the prefixed number of words before the
<exist:match> tag and forwards the words after the tag, eliminating
all the others?.

Is it possible using XSLT or should I use SAX?

Thank you
Federico
 
A

Andy Dingley

Is it possible using XSLT or should I use SAX?

Sounds like a job for XSLT, with Javascript extensions. XSLT is good
at node structure , but falls down a bit within a #cdata.

Or you could certainly do it through the DOM. I guess the relative
ease depends on what you get back from your search routine - is this
just one search result you're given, or do you also have to extract
that from a results page ? (for which XSLT might be useful)
 
F

Federico

Or you could certainly do it through the DOM. I guess the relative
ease depends on what you get back from your search routine - is this
just one search result you're given, or do you also have to extract
that from a results page ? (for which XSLT might be useful)

The result is an XML file, I think I will use JDOM to manipulate the
XML file and then I will pass it to an XSLT stylesheet for the
visualization of the resutls.

Need only to find a way do manage the characters before and after the
nested tag

Thank you
Fede
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top