Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] XPath XMLOutputter Context Results in HTML

Andrew Rapp

2006-04-20

Replies:

I'm interested in building a simple webapp to that will evaluate xpath expressions and return the results in HTML.  The tricky part is that I'd like to highlight the result nodes in context of the source document.  For example, if I have an XML document that looks like

<?xml version="1.0" encoding="UTF-8"?>
<a>
    <b>
        <c>
            <d/>
        </c>
    </b>
</a>

and I execute the xpath expression "//d/ancestor::*", I would like to display the results in HTML as follows:

<strong>&lt; a &gt; </strong>
    <strong>&lt; b &gt; </strong>
       <strong>&lt; c &gt; </strong>
          &lt; d &gt;
       <strong>&lt; /c &gt; </strong>
    <strong>&lt; /b &gt; </strong>
<strong>&lt; /a &gt; </strong>

I started writing my own JDOM XMLOutputter to highlight the result nodes but I'd rather avoid this effort, especially if someone else has already solved this problem.  I'd appreciate any insight on this.  Thanks.

-Andrew

 

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.