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

XSL Attribute Test

Q) How to check whether the value of an attribute is not null or if the lenght of characters in the value of an attribute is greater than 0?

Solution applied -->
s0SelectedSite is an attribute of a class or a column of a table.

Expand|Select|Wrap|Line Numbers
  1. <xsl:if test="string-length(@s0SelectedSite) &gt; '0'">
  2. <tr>
  3.   <td width="50%" bgcolor="#C0C0C0"><font size="2"><b>Selected Site:</b></font></td>
  4.   <td><font size="2">*<xsl:apply-templates select="DBE:Attribute   [@name='s0SelectedSite']"/></font></td>
  5. </tr> 
  6. </xsl:if>
In the above, the value of s0SelectedSite exists but still the lines are not getting printed.

For eg. It should display the following:-

Selected Site: Singapore
Please let me know if something is wrong.
Sep 14 '09 #1
5 3494
Dormilich
8,658 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. <xsl:apply-templates select="DBE:Attribute[@name='s0SelectedSite']"/>
what is that supposed to do?
Sep 14 '09 #2
Its purpose is to display the the value of s0SelectedSite attribute which belong to a class/object.
Sep 14 '09 #3
Dormilich
8,658 Expert Mod 8TB
does it do what it is supposed to do?
Sep 14 '09 #4
Thanks to all....

0
I tried this way now --> It worked for me :

Expand|Select|Wrap|Line Numbers
  1. <xsl:choose>
  2.   <xsl:when test="string-length(DBE:Attribute[@name='s0SelectedSite']/node()) &gt; 0"> 
  3.     <table>
  4. ...<tr> 
  5.   <td width="50%" bgcolor="#C0C0C0"><font size="2"><b>Selected Site:</b></font></td> 
  6.   <td><font size="2">*<xsl:apply-templates select="DBE:Attribute   [@name='s0SelectedSite']"/></font></td> 
  7. </tr>
  8.     </table>
  9.   </xsl:when>
  10.   <xsl:otherwise>
  11.     <table>
  12. ...<tr> 
  13.   <td width="50%" bgcolor="#C0C0C0"><font size="2"><b>Selected Site:</b></font></td> 
  14.   <td><font size="2">*<xsl:apply-templates select="DBE:Attribute   [@name='s0SelectedSite']"/></font></td> 
  15. </tr>
  16.     </table>
  17.   </xsl:otherwise>
  18. </xsl:choose>
It works now.....i get the field empty incase of no value....incase of value i get the selected site value.
Sep 14 '09 #5
Dormilich
8,658 Expert Mod 8TB
@prao2005
that is correct behaviour. if you want to skip empty values, you have to test for them before.
Sep 14 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: yamini | last post by:
Here I am trying to use tag files in JSP2.0 with tomcat 5. test.jsp ------- %@ taglib prefix="test" tagdir="/WEB-INF/tags" %> <html> <head> <title>Untitled Document</title> </head> <body>
7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
0
by: Carl | last post by:
Hi, I have found a way to map attributes (columns) to column headings. But this runs really slow. Is there a way to improve it? Thanks, Carl <?xml version="1.0" encoding="utf-8" ?>...
3
by: Patrick | last post by:
>Is it actually valid to have an XML document with 2 XML Elements having the same ID attribute? XML Spy seems to allow something like the following <?xml version="1.0" encoding="UTF-8"?>...
3
by: Steve | last post by:
Is there a way to get the type information for the class an attribute is defined on at runtime? I tried getting the attribute type, and then checking the DeclaringType property but it was null. ...
1
by: arnold | last post by:
Hi, I've been knocking my head against the wall trying to create an XSL transform to perform "normalizations" of a set of XML files that have a common structure. % XML file before transform
5
by: Stuart Carnie | last post by:
I suspect it's unlikely, but you'll never know until you ask, but are there any attributes that would allow us to contribute to the compiled output? e.g. // this class exists in a separate,...
0
by: Aray | last post by:
Let us see the test file following: -------file nowork.xsd begin----------- <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"...
3
by: 7stud | last post by:
"When you bind (on either a class or an instance) an attribute whose name is not special...you affect only the __dict__ entry for the attribute(in the class or instance, respectively)." In light...
2
by: =?Utf-8?B?dXJrZWM=?= | last post by:
I am trying to create an in-process WMI provider using System.Management.Instrumentation namespace. For testing I use a simple class as a wrapper for FileInfo class. I have been able to use all...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.