473,802 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSL Attribute Test

18 New Member
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 3518
Dormilich
8,658 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. <xsl:apply-templates select="DBE:Attribute[@name='s0SelectedSite']"/>
what is that supposed to do?
Sep 14 '09 #2
prao2005
18 New Member
Its purpose is to display the the value of s0SelectedSite attribute which belong to a class/object.
Sep 14 '09 #3
Dormilich
8,658 Recognized Expert Moderator Expert
does it do what it is supposed to do?
Sep 14 '09 #4
prao2005
18 New Member
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 Recognized Expert Moderator Expert
@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
11252
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
3673
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. And i have things to offer, and to request. And a lot of ideas, but who needs them.... here's an example (from type_struct.py):
0
2184
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" ?> <?xml-stylesheet type="text/xsl" href="stylesheet.xslt"?>
3
8745
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"?> <FormDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Forms.xsd"> <list id="1"> <status>partially completed</status> </list>
3
12025
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. Example: public class Test {}
1
2042
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
2230
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, compiled assembly for the compiler to load during compilation class MyMethodCompiler : Attribute { // This is called during compilation public override void GenerateMethod(MethodBuilder method)
0
1663
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" xmlns="http://www.bonc.com.cn" targetNamespace="http://www.bonc.com.cn" elementFormDefault="qualified"> <xs:attribute name="testAttribute" type="xs:string"/> <xs:attributeGroup name="testAttributeGroup"> <xs:attribute ref="testAttribute"/>
3
1580
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 of that statement, how would one explain the output of this code: class Test(object): x =
2
3285
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 attributes successfully (ManagementKey, ManagementProbe, ManagementBind...). The only one attribute I am having problem with is ManagementCreate. As I understand from the documentation, it is supposed to support creation of new instances of a...
0
9699
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
10538
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
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...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
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
6838
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();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2966
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.