cocoon-users mailing list archives

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

http://www.mulberrytech.com/xsl/xsl-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']">
   <authors>
     <xsl:call-template name="getAuthors">
       <xsl:with-param name="AuthorString" select="normalize-space()"/>
     </xsl:call-template>
   </authors>
</xsl:template>

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

> 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 
(http://www.w3.org/TR/xslt#section-Result-Tree-Fragments). Maybe this or 
an explicit string conversion ( [string(Id) = string($aux)] ) already 
solves your problem.

Joerg



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


Mime
View raw message