472,333 Members | 1,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,333 software developers and data experts.

When to use <xsl:text>

When is the use of <xsl:text>blah blah</xsl:text> necessary? I'm finding
that, although it's used religously in the book I'm learning from, if I
miss it out, the output is just the same.
Jul 20 '05 #1
3 3472
Derek

the main reason you want to use this is when whitespace is significant in
the result document. For instance, consider this snippet of xsl

<h1>
details for user
<xsl:value-of select="@username"/>
in group
<xsl:value-of select="@groupname"/>
</h1>

the text node for the phrase 'details for user' starts just after the
closing > of <h1> and ends just before the opening < of <xsl:value-of>. All
this extra whitespace will be copied into the resulting output. This doesn't
normally matter with HTML but you might be using an output format where
whitespace is significant or you maybe want the HTML to look nice. in this
case you can do this:

<h1>details for user<xsl:value-of select="@username"/>in group<xsl:value-of
select="@groupname"/></h1>

but this can get unwieldy (and if you use a pretty printer to reformat your
XSL it might break it up again). Here's where xsl:text comes in:

<h1>
<xsl:text>details for user</xsl:text>
<xsl:value-of select="@username"/>
<xsl:text>in group</xsl:text>
<xsl:value-of select="@groupname"/>
</h1>

now you have no whitespace within those text nodes. Instead you have created
some new text nodes which just contain the whitespace but fortunately the
XSLT processor will ignore those.

Dealing with whitespace in XSL is a pain the butt and you usually don't need
to bother. on those occasions where you need to control the whitespace that
gets generated, xsl:text is the way to do it

HTH

Andy

"Derek Fountain" <no****@hursley.ibm.com> wrote in message
news:3f***********************@freenews.iinet.net. au...
When is the use of <xsl:text>blah blah</xsl:text> necessary? I'm finding
that, although it's used religously in the book I'm learning from, if I
miss it out, the output is just the same.

Jul 20 '05 #2
"Derek Fountain" <no****@hursley.ibm.com> wrote in message
news:3f***********************@freenews.iinet.net. au...
When is the use of <xsl:text>blah blah</xsl:text> necessary?
I'm finding that, although it's used religously in the book I'm
learning from, if I miss it out, the output is just the same.


I'm no guru but I'd say the element probably comes into play whenever you
are using variables rather than actual text. A similar scenario is possible
with <xsl:element name="Mine">, which is equivalent to simply entering
<Mine>, but because the attriibute is quoted text, you can use a variable
instead.

hth
Christopher Boomer
Jul 20 '05 #3
<snip!>
HTH

Andy


Yes, it did help, thanks. Makes sense now... :o)
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael Ahlers | last post by:
I am looking for a way to get my transformations to output a default value from <xsl:value-of/> if a selected element doesn't exist or is empty...
2
by: websls | last post by:
I tried to do this : <xsl:if test="ToutCompris"> some output </xsl:if> ToutCompris is a boolean element in my XML file My problem is the...
5
by: Luke Vogel | last post by:
Hi all, Probably a really basic question, but I cant find an answer ... I have an xml file of books something like: <product>...
3
by: tldisbro | last post by:
Hello All, I am trying to use the returned value of the <fo:page-number> element/function in my <xsl:if> test condition. But am unsuccessful in...
2
by: Paul Verbelen | last post by:
I have a file with topics. I like to copy them in another file but want to have some blank lines between the different topics. I use <xsl:text>...
4
by: Jon | last post by:
Hi, I used XslCompiledTransform with the following Xsl file. The <xsl:text disable-output-escaping="yes"does not work when using...
5
by: jhurrell | last post by:
I have been having some trouble getting my XSL style sheet to parse correctly. I have some XML outputted from an SQL-Server, that I then need to...
4
by: C.W.Holeman II | last post by:
I am using Firefox 2.0.0.3 on MSWindows. I have an XML file http://emle.sourceforge.net/emle020000/testb.xml which invokes an XSLT file...
3
by: Petterson Mikael | last post by:
Hi, I was running the following in Netbeans 5.5: sing com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl - default JRE XSLT...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.