February 28th, 2002, 05:02 PM
-
<br/> tag in XSL variable
I'm trying to get an HTML <br> tag, embedded into an XSL variable and I'm not sure that it's possible.
In short, I have stylesheet1.xsl which performs a specific function. stylesheet1.xsl includes Language.xsl. Within Language.xsl are all of the text strings that stylesheet1 uses (the reason for this is that there are 45+ stylesheets, however only one needs to be modified to change the language of the entire package.)
Within Language.xsl, I would like to define a variable lit_QuantityReceived. Such as:
<xsl:variable name="lit_QuantityReceived">Quantity Received</xsl:variable>
However, I would like to insert an HTML break in between the two words, so my result from inserting "$lit_QuantityReceived" in HTML would be:
Quantity<br/>Received
I've tried quite a few options that don't work. < doesn't work because the browser doesn't intepret that as the beginning of a tag, escaping a linefeed actually puts a line break in the HTML instead of a <br> tag, and I can't seem to find a single way to get a < or > symbol into my variable definition.
I've even referenced the xhtml DTD:
<br xmlns:html="http://www.w3.org/1999/xhtml" />
which *does* work when you use it directly in a .xsl, but not when you embed it within the variable as I'm trying to do.
Is this possible?
Thanks in advance.
March 4th, 2002, 04:12 PM
-
this may help
I am not sure if you can store Document nodes as part of a value, so the next best thing is to apply a separate stylesheet template that will convert characters (in this case a space) to line breaks (<br/>)
heres an example of swapping a space for a break.
<xsl:template name="break">
<xsl
aram name="text" select="."/>
<xsl:choose>
<xsl:when test="contains($text, ' ')">
<xsl:value-of select="substring-before($text, ' ')"/>
<br/>
<xsl:call-template name="break">
<xsl:with-param name="text" select="substring-after($text,' ')"/>
</xsl:call-template>
</xsl:when>
<xsl
therwise>
<xsl:value-of select="$text"/>
</xsl
therwise>
</xsl:choose>
</xsl:template>
to apply this to a value just do this:
<xsl:call-template name="break">
<xsl:with-param name="text" select="$yourVariable"/>
</xsl:call-template>
March 8th, 2002, 12:56 PM
-
Can you discuss the positive and negative effects of smileys in XML code?
Just kidding
Zach
March 8th, 2002, 12:59 PM
-
Unpredictable Results
Thanks for the humor Zach.
March 14th, 2002, 02:00 PM
-
hi high-1
I think you should try this
Code:
variable definition :
<xsl:variable name="lit_QuantityReceived"> Quantity <br>Received</xsl:variable>
output variable :
<xsl:value-of disable-output-escaping="yes" select="$lit_QuantityReceived"/>