Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] 'Mail-merge' type of problem: using placeholders in text for substitution

From: Anton Triest <anton@-------->
To:
Date: 10/2/2004 11:50:00 PM
David wrote:



I suppose this problem could be akin to a 'mail-merge' type situation where

place-holders represent data that should be substituted with the text of a

document.  I'm transforming to html (using Cocoon.)  I need any mention of

the U.S. state name (e.g. "California") to be inserted where the

<statename/> element is.  I don't know how to write the XSLT transformation

for this to work.  I put below my first stab at the XSLT code, but I know

it's incomplete. 



I think from an XSLT standpoint the problem relates to the fact that

<statename/> appears - potentially multiple times - within the 'text value'

(is that the right term?) of an element.  Although I've solved a lot of XSLT

problems before, I don't think I've ever had to code for a situation like

this. 
 



Hi David,



I'm afraid I don't understand what the problem is - with your XSLT, plus 
a global variable

or parameter name="statename" select="'California'", I get the following 
output:



<html>

   <body>

       <p>Summary of Laws for California</p>

       <p>The laws in California are favorable to defendants. 
           If you live in California then your outcome is secure.

       </p>

   </body>

</html>



Isn't that what you want? If not please describe your problem more clearly



Regards,
Anton





If I should be approaching this differently, please advise.



Thanks,
David

<doc>
      <body>
      <para>Summary of Laws for <statename/></para>
      <para>The laws in <statename/> are favorable to defendants.  If you
live in <statename/> then your outcome is secure.</para>
      </body>
</doc>


And XSLT of the form:



<xsl:template match="/doc">
           <html>
                 <xsl:apply-templates/>
           </html>
</xsl:template>

<xsl:template match="body">
           <body>
                 <xsl:apply-templates/>
           </body>
</xsl:template>

<xsl:template match="para">

           <p><xsl:apply-templates/></p> 
</xsl:template>



<xsl:template match="statename">

           <xsl:value-of select="$statename"/> 
</xsl:template>


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