473,326 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 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 3540
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 without having to have tons and tons of <xsl:choose/>...
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 output is parse even when ToutCompris is false I...
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> <isbn>0-735-61374-5</isbn> <title>Microsoft Visual Basic Step By...
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 doing so. Is it possible to use it in this fashion...
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> element with as data some blank lines to perform...
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 XslCompiledTransform to do the trnasform (namely the output...
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 turn into multiple HTML files. This I have done...
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 http://emle.sourceforge.net/emle020000/testb.xsl <?xml...
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 processor. Creating output/NcmiSigTest.java Unsupported...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.