You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Lorenzo Sicilia <ar...@kemen.it> on 2003/10/01 15:04:51 UTC

xml filter parser

Hi to all,

I need filter a xmlDocument.

<x:parse filter="${filter}" xml="${param.xmlDocument}" var="xmlDoc" />

the problem is create a org.xml.sax.XMLFilter object in ${filter}.

I nees filter my xmlDocument with a Xpath string like "//packet/param".
With Jdom I can try with this:

XPath filterPath = XPath.newInstance("//packet/param");
List rows = filterPath.selectNodes(this.xmlDoc);

Can I do in jstl?

Best Regards Lorenzo Sicilia

p.s. Sorry for my poor english :)





---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: xml filter parser

Posted by Lorenzo Sicilia <ar...@kemen.it>.
Kris Schneider wrote:

> Isn't something like this the JSTL equivalent of your code example:
> 
> <x:parse xml="${param.xmlDocument}" var="xmlDoc"/>
> <x:set var="stuff" select="$xmlDoc//packet/param"/>

it is perfect!

1k tks.

Best Regards Lorenzo Sicilia



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: xml filter parser

Posted by Kris Schneider <kr...@dotech.com>.
Isn't something like this the JSTL equivalent of your code example:

<x:parse xml="${param.xmlDocument}" var="xmlDoc"/>
<x:set var="stuff" select="$xmlDoc//packet/param"/>

If you're really planning on iterating over each of the nodes:

<x:forEach var="item" select="$xmlDoc//packet/param">
  ...
</x:forEach>

Otherwise, if you really need to use a filter, you have to create an instance
and store it as a scoped attribute. It's probably better practice to do this in
a servlet (or action if you're using a framework like Struts) that operates on
the request before forwarding to the JSP:

XMLReader parser = XMLReaderFactory.createXMLReader();
MyXPathFilter filter = new MyXPathFilter("//packet/param");
filter.setParent(parser);
request.setAttribute("filter", filter);
// forward to JSP

If you need an implementation of an XPath XMLFilter (and since it sounds like
you use JDOM), it looks like org.jdom.contrib.input.scanner.ElementScanner might
work, but I've never used it.

Quoting Lorenzo Sicilia <ar...@kemen.it>:

> Hi to all,
> 
> I need filter a xmlDocument.
> 
> <x:parse filter="${filter}" xml="${param.xmlDocument}" var="xmlDoc" />
> 
> the problem is create a org.xml.sax.XMLFilter object in ${filter}.
> 
> I nees filter my xmlDocument with a Xpath string like "//packet/param".
> With Jdom I can try with this:
> 
> XPath filterPath = XPath.newInstance("//packet/param");
> List rows = filterPath.selectNodes(this.xmlDoc);
> 
> Can I do in jstl?
> 
> Best Regards Lorenzo Sicilia
> 
> p.s. Sorry for my poor english :)

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org