473,386 Members | 1,766 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,386 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 3493
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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: 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...

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.