cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <>
Subject Re: XSL problem...again :(
Date Sat, 10 May 2003 15:45:44 GMT wrote:
> I've tried to sent this email to the XSL list 
> ( 
> <>) but with no sucess...The mail 
> does not appears in the list, I've sucessufly registered at that list :|, at the end of the page.

> I have this XSL code and I would like to parse an authors tag of a XML 
> document. The source file is like this:
> <DocSum>
>      <Id>12673722</Id>
>      (...)
>      <Item Name="Authors" Type="String">Kahle B, Hoffend J, Wacker J, 
> Hartschuh W</Item>
>      (...)
> </DocSum>
> I want to parse the Athors parameter, and get something like that:
> <authors>
>     <name>Kahle B</name>
>     <name>Hoffend J</name>
>     <name>Wacker J</name>
>     (...)
> </authors>

<xsl:template match="Item[@Name='Authors']">
     <xsl:call-template name="getAuthors">
       <xsl:with-param name="AuthorString" select="normalize-space()"/>

<xsl:template name="getAuthors">
   <xsl:param name="AuthorString" select="''"/>
     <xsl:when test="contains($AuthorString, ',')">
         <xsl:value-of select="substring-before($AuthorString, ',')"/>
       <xsl:call-template name="getAuthors">
         <xsl:with-param name="AuthorString"
                         select="substring-after($AuthorString, ',')"/>
         <xsl:value-of select="$AuthorString"/>

> For that I'm doing this: to each ID from the a list of ID's we're 
> getting the ID value and that grab the parameter that contains  "Kahle 
> B, Hoffend J, Wacker J, Hartschuh W"
> like the above example.
> <authors>
>    <xsl:for-each select="idlist/id">
>             <xsl:variable name="aux"><xsl:value-of 
> select="."/></xsl:variable>
>                     <name><xsl:value-of 
> select="/DocSum[Id=$aux]/Item[@Name='Authors']"/></name>
>     <xsl:for-each/>
> </authors>
> The problem is that the $aux variable isn't working inside the XPath 
> expression :|

I don't understand your logic behind this code. What says you that $aux 
is not working? In general don't use the variable construct as above, 
but use <xsl:variable name="aux" select=."/>. Otherwise you create a 
Result Tree Fragment, which can't be handled like a node-set 
( Maybe this or 
an explicit string conversion ( [string(Id) = string($aux)] ) already 
solves your problem.


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

View raw message