 |
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

July 29th, 2005, 10:06 AM
|
Authorized User
|
|
Join Date: Jul 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
USING PARAMETER INSIDE XSL:TEXT
Hi,
I cannot figure out how to use a parameter that is passed in to the xslt inside an <xsl:text> tag.
The parameter is declare like this and will contain either "," or ";"
<xsl:param name="delemeter">,</xsl:param>
or
<xsl:param name="delemeter">;</xsl:param>
This is what I have tried:
This works!! Because the comma is hard coded.
<xsl:text>",</xsl:text>
But this does not work since I am trying to use the parameter
<xsl:text>"<xsl:value-of select="$delemeter"/></xsl:text>
This does not work
<xsl:text>"{$delemeter}</xsl:text>
Cheers,
Cleyton
|

July 29th, 2005, 12:04 PM
|
Authorized User
|
|
Join Date: Jul 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Just to explain a little better what I am trying to achieve.
I am trying to build a comma delimited file using xslt (1.0 MSXML) and I have to use the <xsl:text> tag to write a comma(,). So, I am creating a file to be used in Excel.
However, since in some countries they use a comma as a decimal place, I am giving the user the option to set the delimiter character dynamically and am passing this option to the xsl as a parameter. Hence, this is how I create the parameter:
<xsl:param name="delimiter"></xsl:param>
However, I cannot figure out how to use it inside a <xsl:text> tag. I have tried both ways but they did not work.
<xsl:text>"<xsl:value-of select="$delimiter"/></xsl:text>
<xsl:text>"{$delimiter}</xsl:text>
I would appreciate if someone could help with that.
Cheers,
Cleyton
|

July 29th, 2005, 12:34 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
How are you setting the parameter?
You can set the default as a comma:
Code:
<xsl:param name="delimiter" select="','"/>
You can then use:
Code:
<xsl:text>"some text"<xsl:value-of select="$delimiter"/></xsl:text>
But you'll need to set the parameter externally before running the transform.
--
Joe ( Microsoft MVP - XML)
|

July 29th, 2005, 01:14 PM
|
Authorized User
|
|
Join Date: Jul 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Joe,
I can set the paremeter fine. However, when I try to use the parameter within the <xsl:text> tag the parser throws an error saying that we cannot use a
<xsl:value-of select="$delimiter"/> there. That is the problem I have.
Cheers,
Claduio
|

July 29th, 2005, 01:32 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Sorry, not paying attention. xsl:text can only contain text. You need to restyle your stylesheet to be like:
Code:
<xsl:text>"some text"</xsl:text><xsl:value-of select="$delimiter"/><xsl:text>"some more text"</xsl:text>
--
Joe ( Microsoft MVP - XML)
|

July 29th, 2005, 04:39 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Use <xsl:text>"</xsl:text> for fixed text.
Use <xsl:value-of select="$delimiter"/> for variable text.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|

July 29th, 2005, 07:30 PM
|
Authorized User
|
|
Join Date: Jul 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Joe and Michael,
Thanks for you help.
For some reason I cannot remember right now, I had to write the comma inside a <xsl:text> tag. I think that is the only way I got it to work in Excel.
But I will give it a try again and see what happens.
Cheers,
Cleyton
|
|
 |