Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] xsl:apply-templates doesn't fill variable correctly

From: "Michael Kay" <mike@------------>
To:
Date: 8/1/2005 9:17:00 AM
I can't see what's wrong here, I suspect the error is in the part of the
stylesheet that you haven't shown us.

One comment on your coding style:

You do this:

>     <xsl:template match="*">
>     	<xsl:when test="name()='fussnote'">

and later this:

>     <xsl:template match="@*">
>		<xsl:when test="name()='href'">

In both cases, this isn't a good way of using template rules. It's much
better to have specific template rules for each kind of element or
attribute, than to have a generic rule which consists of a big xsl:choose
that switches on the element or attribute name.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Lensch, Thomas [mailto:Lensch@xxxxxxxx] 
> Sent: 01 August 2005 09:49
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] xsl:apply-templates doesn't fill variable correctly
> 
> Hi,
> 
> the following snipet shows the usage of variable tHtml:
> 
> When i find a 'fussnote' in my xml i apply templates into tHtml. Then,
> this variable is processed further.
> 
> 
>     <xsl:template match="*">
> 	...
> 			<xsl:when test="name()='fussnote'">
> 				<xsl:variable name="tHtml">
> 					<xsl:apply-templates
> select="text()|*"/>
> 				</xsl:variable>
> 				<!-- Pos_1 -->
> 				<xsl:variable name="ttHtml">
> 					<xsl:apply-templates
> select="xalan:nodeset($tHtml)" mode="escape"/>
> 				</xsl:variable>
> 				.... further processing and output of
> $ttHtml
> 			</xsl:when>
> 
>     <!-- Process Attributes -->
>     <xsl:template match="@*">
>         <xsl:choose>
> 			<xsl:when test="name()='href'">
>                 <xsl:choose>
>                     <xsl:when test="starts-with(.,'#')">
>                         <xsl:attribute name="href">
>                             <xsl:call-template name="VerityLink">
>                                 <xsl:with-param name="price"
> select="'0.0'"/>
>                                 <xsl:with-param name="part"
> select="/*/parameter/doc.part"/>
>                             </xsl:call-template>
>                             <xsl:value-of select="."/>
>                         </xsl:attribute>
>                     </xsl:when>
>                     <xsl:otherwise>
> 				....
> 
> 
> 
> Excerpts of my XML file:
> a)
> 	<fussnote nr="13">
>           <a href="#rd_200">Dazu Rn. 200</a>.</fussnote>
> 
> b)
> 	<fussnote nr="71">
>           <a href="#rd_103">Dazu Rn. 103</a>.</fussnote>
> 
> While a) works b) doesn't. In b) only the "." ist output.
> 
> When i use apply-templates without putting the result in a 
> variable, b)
> works too!
> 
> Does anybody have some hints for me? Possible problem of recursion on
> variable content?
> 
> Best regards
> Thomas.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent