473,791 Members | 3,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When to use <xsl:text>

When is the use of <xsl:text>bla h 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 3574
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="@userna me"/>
in group
<xsl:value-of select="@groupn ame"/>
</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="@userna me"/>in group<xsl:value-of
select="@groupn ame"/></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>detai ls for user</xsl:text>
<xsl:value-of select="@userna me"/>
<xsl:text>in group</xsl:text>
<xsl:value-of select="@groupn ame"/>
</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>bla h 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>bla h 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
4302
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/> blocks everywhere. Is there a quick solution to this or am I going to have to take the pain? (Also, suggestions on where else I should post this question would be helpful.)
2
1740
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 tried <xsl:if test="ToutCompris = true"> and it does'nt work either
5
2337
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 Step</title> <author>Michael Halvorsen</author> <subject>Programming</subject>
3
14280
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 with a conversion or correct syntax? I would like to test the current page number and see if it is even or odd - and if it is odd I would like to perform additional steps. I would like to do something like this (assume all namespaces are set):...
2
1823
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 this. To clarify my question, I have add all the files required to perform the test. First question: Why doesn't this works anymore if I remove the line with "&#x00A0;" in the XSL-file ?
4
9183
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 contain < not <), while it works when using MSXML2 to do the transform. Does anyone have the same problem and how to make the escape work? Thanks. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
3416
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 with moderate success using Saxon and <xsl:result-document>, but Saxon is throwing an error and I don't know how to resolve it. Maybe someone can offer some advice? This is a long question, for which I apologise... OS= Windows XP Pro, Saxon=8.8 XML...
4
2112
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 version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet href="testb.xsl" type="text/xsl"?> <z xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <x/> </z>
3
5063
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 XSL element 'http://www.w3.org/1999/XSL/Transform:document' Transformation finished.
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9517
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.