473,387 Members | 1,504 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,387 software developers and data experts.

XSL: choosing another node if one is not available

APB
I am working on an XSL to transform RSS/RDF feeds into HTML

I have come across a bunch of feeds that only have a <description> for each
<item> but no <title>.

In this event I would like to use the <description> node as if it where the
<title> node. I tried something like the following fragment, but it doesn't
change anything. How can I obtain what I require while keeping one single
universal XSLT? Thanks!

<xsl:template match="item">
<xsl:variable name="item_link" select="link"/>
<xsl:variable name="item_descr" select="description"/>
<xsl:variable name="item_title" select="title"/>
<li >
<a href="{$item_link}" target="_blank" >
<xsl:if test="$item_title=''">
<xsl:value-of select="description" />
</xsl:if>
<xsl:value-of select="title"/>
</a>
<br /><div style="display:none"><xsl:value-of select="description"
disable-output-escaping="yes" /></div>
</li>
</xsl:template>

Alex.
--
__________________________________________________ _________
a p bertolini

(www.webwarrior.org)
Jul 20 '05 #1
2 1509
Hi.

I'm not sure, but if the <title> element doesn't exist at all, its
value is rather invalid than an empty string. This would mean, that
your comparison never will be true because there is no value to
compare with. You have to test if the value exists anyway. Try the
following change:

....
<xsl:if test="$item_title">
....

If you also want avoid empty strings, you have to combine both
comparisons.
Bye
Peter
Jul 20 '05 #2
APB
Looks like I'm getting somewhere with this, thanks!

<xsl:if test="not($item_title)">

does the trick.

Alex.

--
__________________________________________________ _________
a p bertolini

(www.webwarrior.org)
Jul 20 '05 #3

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

Similar topics

5
by: ipg | last post by:
I am running into issues passing a parameter (that is a XML string) into a stylesheet and using msxsl:node-set to parse the string. Can someone please explain why. my html: var xsl = new...
4
by: sylvain.loiseau | last post by:
Hello Given a node set, I try to compute the total of the string-length value of each node. For instance, with : <xsl:for-each select="//q"> <!-- the length of each node is compute with:...
7
by: Andy Fish | last post by:
Hi, I'm stuck with an XSL problem - can anyone give me any hints? I have some XML with nested formatting tags like this: <text> this is plain <bold> this is bold
6
by: Loopy | last post by:
I'm learning XML and XSL at the moment, but I still can't get my head around the concept of non-updatable variables. I know we can use recursion to cycle through a data structure and get the sum...
4
by: JLP | last post by:
Hello, I have a couple of hundred books in TEI based XML. I want to output html and pdf documents. I started building my own style sheets to do this and I ran into a problem with footnotes. Many...
3
by: Blaise Garant | last post by:
Hi I've made a stylesheet to transform my data into XSL-FO. This stylesheet used to work with MSXSL 4.0 but I've got some issues in ..NET. First, I changed removed all the "node-set()" function...
3
by: Steve | last post by:
Is there any way of specifying the startMode when using the xslTransform class? We are updating code which used msxml to the system.xml classes but can find no way to specify the startMode. We...
1
by: infiniti | last post by:
Hi, I am trying to transform this xml section using xsl, but there is a glitch in the xsl file which I do not know how to rectify. Any help is appreciated. XML: <?xml version="1.0"...
3
by: Simon Brooke | last post by:
As various people will have noticed, I've been having a lot of trouble with XSL lately. Brief history: I wrote myself an XML toolkit back in 2000, and it worked well enough for me, so it's been...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.