tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: XTags: Usage of org.dom4j.Documents?
Date Sun, 09 Sep 2001 19:21:20 GMT
Hi Manuel

Sorry for the delay getting back to you, I'm just back from vacation.

The quick answer is absolutely yes - you can pass in documents, nodes or
'node sets' (a List of Node objects) to all the tags. This is achieved via
either the context attribute using a scriptlet expression or via XPath
variables.

e.g.

<xtags:forEach select="foo/bar" context="<%= mydoc %>">
    ...
</xtags:forEach>

You can define a variable for any expression or parse to allow you to
evaluate once and keep it around for future reference.

e.g.

<xtags:parse id="mydoc">
    <some>
        <tag>hello there</tag>
    </some>
</xtags:parse>

then later...

<xtags:valueOf select="/some/tag" context="<%= mydoc %>"/>

or you could use the XPath variables. Whenever an attribute is defined in
page / request / session / application scope it is available as an XPath
variable. So you could rewrite the above as

<xtags:valueOf select="$mydoc/some/tag"/>

You can also use the <xtags:variable> tag to define a variable of an XPath
expression, to avoid reevaluation. e.g.

<xtags:variable id="mytags" select="//tag"/>

Of course you could always define your own scripting variables for documents
and pass them in as a context parameter or create your own attributes and
use the XPath variable syntax.

Hope that helps.

James
----- Original Message -----
From: "Manuel Tromm" <tromm@oTRIs.de>
To: <taglibs-user@jakarta.apache.org>
Sent: Thursday, September 06, 2001 9:36 AM
Subject: XTags: Usage of org.dom4j.Documents?


> Hi folks,
>
> I've got a question about using XTags:
>
> The common way to use the XTags, is to parse an XML document
> from somewhere by using the "<xtags:parse>"-Tag.
> After the XML-Code has been parsed, it can be accessed
> by the different "X"-Tags...
>
> Sometimes I have to use the XML-Source
> (that is needed as input for XTags) twice or more or
> at completely different locations of my web-application.
> For this reason I've added the XML-Code to a cache.
> The problem is now, that every time when the XTags-JSP is
> requested, the XML-Input has to be parsed by the XTags again.
> That means a lack of performance.
>
> Now my question: Because the XTags are built on top
> of the dom4j, I'd like to know if there is any way to use
> an (already parsed!) org.dom4j.Document as input for
> XTags, so that I don't have to parse XML-Sources twice?
> If yet there is no way, I'd like to ask the developers
> to provide an appropriate Tag, because I think it would be
> also quite helpful for other users.
>
> Does someone know a solution?
>
>
> Regards,
> Manuel Tromm
>


Mime
View raw message