cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Painter-Wakefield" <>
Subject Re: Java variable inside of document() function?
Date Thu, 16 Aug 2001 22:02:06 GMT


first, are you trying to do this in a logicsheet or in a stylesheet?  In a
logicsheet, this won't work because your logicsheet exists to generate Java
code.  The Java code doesn't exist and hasn't been compiled and can't run
yet.  Only your XSL transformations are being applied.  The <xsl:for-each
select="document([the Java variable])"> can't use the value stored in the
Java variable, because it doesn't exist yet.

In a stylesheet, you can't do this, because you can't use XSP Java code in
a stylesheet.  It is too late.  All XSP code has already been run,
producing XML which is being processed by your stylesheet.  You can,
however, do this:

In your XML file:
<!-- do something here to set your variable, e.g. -->
String doc = "info.xml";


then in your XSL stylesheet:
<xsl:variable name="thefile" select="doc"/>
<xsl:for-each select="document($thefile)">


Please respond to

To:   <>

Subject:  Java variable inside of document() function?

How can I use a Java variable in the document() funkction?

<xsl:for-each select="document([the Java variable])">

I have tried it with the help of

<xsl:variable name="src"><xsp:expr>[the Java
<xsl:for-each select="document([$src])">

but this doesn't work. <xsp:expr/> won't be processed and so the value of
$name is
the String "src". When I use <xsp:expr>src</xsp:expr> outside of
<xsl:variable/> it
works fine.

How can I solve this problem? Is there any workaround?


Please check that your question has not already been answered in the
FAQ before posting. <>

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

View raw message