You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Daniel Graversen <dg...@wdk.k-net.dk> on 2003/06/08 18:07:53 UTC

Read XML document via http with variables

Hi,

I'm trying to include information from an other document in an XSL. The
document I'm trying to get is made with Xindice and Cocoon as described in
tutorial about this, and the command work nicely in my browser.

I have tried with the following command where I whould like to change XXX
to anumber i have in the variable $cn.

<xsl:for-each
select="document('http://localhost:8080/cocoon1/mount/02288/xmldb2/02288/?xpath=course[contains(prerequisites/courseno,XXXX)]')//course">
 <xsl:variable name="course" select="@courseno"/>
...

Does any know how to do this.


Regards,
daniel



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Read XML document via http with variables

Posted by Joerg Heinicke <jo...@gmx.de>.
Hello Daniel,

you probably must build the request string step by step, because the 
variable $cn would not get evaluated otherwise:

<xsl:variable name="xindiceRequestString">
 
<xsl:text>http://localhost:8080/cocoon1/mount/02288/xmldb2/02288/</xsl:text>
   <xsl:text>?xpath=course[contains(prerequisites/courseno, '</xsl:text>
   <xsl:value-of select="$cn"/>
   <xsl:text>')]</xsl:text>
</xsl:variable>

<xsl:for-each select="document($xindiceRequestString)//course">
   ...
</xsl:for-each>

1. But be aware of a problem using document():
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10203

Maybe it's better to use XInclude or CInclude or sitemap aggregation:
http://cocoon.apache.org/2.0/userdocs/transformers/xinclude-transformer.html
http://cocoon.apache.org/2.0/userdocs/transformers/cinclude-transformer.html
http://cocoon.apache.org/2.0/userdocs/concepts/sitemap.html

(If you use Cocooon 2.1 simply replace the 2.0 by 2.1.)

2. And is it really necessary to use //course. Double slashes are almost 
always very time-consuming. I would change it to a more exact XPath.

3. Is it possible to replace the server's root 
http://localhost:8080/cocoon1/ by cocoon:/ to access simply Cocoon 
without HTTP. It's only an inner request and much faster:

http://cocoon.apache.org/2.0/userdocs/concepts/sitemap.html

Regards,

Joerg


Daniel Graversen wrote:
> Hi,
> 
> I'm trying to include information from an other document in an XSL. The
> document I'm trying to get is made with Xindice and Cocoon as described in
> tutorial about this, and the command work nicely in my browser.
> 
> I have tried with the following command where I whould like to change XXX
> to anumber i have in the variable $cn.
> 
> <xsl:for-each
> select="document('http://localhost:8080/cocoon1/mount/02288/xmldb2/02288/?xpath=course[contains(prerequisites/courseno,XXXX)]')//course">
>  <xsl:variable name="course" select="@courseno"/>
> ...
> 
> Does any know how to do this.
> 
> 
> Regards,
> daniel


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org