cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Huber, Daniel" <Daniel.Hu...@TechniDATA.DE>
Subject How to avoid xpath's document() function?
Date Mon, 20 Sep 2004 13:51:23 GMT

some of you may have read the thread "No lucene, but "Too many open
Now I really try to avoid the use of the xpath function "document()" in
my XSL transformations at all.

But, my use case is not to include content (or complete sub-trees), but
to use the external documents as a look-up table and then react on the
information retrieved.

A concrete, but simplyfied example would be to generate some HTML
select-boxes and populate the options from another XML file:

<xsl:variable name="phrases"
select="document('phrases.xml')/phrases/chapter[@id =
$chapterID]/field[@name = $fieldName]"/>
<xsl:variable name="currentSelection" select="."/>

<select name="{@id}">
   <xsl:for-each select="$phrases/option">
         <xsl:if test="text() = $currentSelection">
            <xsl:attribute name="selected">true</xsl:attribute>
         <xsl:value-of select="."/>

My first idea was to use the XIncludeTransformer. The problem here is
that the returned information has to be processed dynamically. So I
can't simply include a returned sub-tree unmodified.
(OK, admittedly I could split the stylesheet into two parts, but I still
believe there must be a *nicer* way.)

My second idea was to use aggregation, so i would merge the source XML
and all the XML files needed for looking-up some information while
transforming. So the process would be quite the same, but I could stay
within the same XML file. Despite this I find this approach a bit
clumsy, because eventually I must carry along quite large XML trees just
for asking for some values.

Is there sombody out there, with more elegant ideas?



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message