473,406 Members | 2,356 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,406 software developers and data experts.

empty quotes != not(string(.)) ????

I have a when statement:

<xsl:when test="//pageTitle[../linkID = $activeLink] = not(string(.))">

This should find the 'pageTitle' node that has a sibling of 'linkID' that
matches the '$activeLink' parameter and see if it is empty or not.

The above returns FALSE

However, this:

<xsl:when test="//pageTitle[../linkID = $activeLink] = ''">

returns TRUE (that's a pair of empty single quotes after the '=')

Why? I thought not(string(.)) *is* the same as an empty element?

-Darrel
Nov 12 '05 #1
8 3693
darrel wrote:

Why? I thought not(string(.)) *is* the same as an empty element?


not(string(.)) returns boolean. So in effect you are comparing node with
boolean? And . in
//pageTitle[../linkID = $activeLink] = not(string(.))
has nothing to do with pageTitle node, instead it refers to current node
in a context xsl:when is executed.

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #2
Hello, darrel!
You wrote on Mon, 12 Apr 2004 15:11:11 -0500:

d> <xsl:when test="//pageTitle[../linkID = $activeLink] =
d> not(string(.))">

d> This should find the 'pageTitle' node that has a sibling of 'linkID'
d> that matches the '$activeLink' parameter and see if it is empty or not.

d> The above returns FALSE

Here is you compare nodeset and boolean value. The comparision is true "if
the result of performing the comparison on the boolean and on the result of
converting the node-set to a boolean using the boolean function is true."

boolean(nodeset) returns true if nodeset is not empty.

So, if the string(context node) is equal to nonempty string, then
not(string(.)) will always return false.
The pageTitle[../linkID = $activeLink] returns non empty nodeset, and above
expression returns false, 'cause true = false equals false.

d> However, this:

d> <xsl:when test="//pageTitle[../linkID = $activeLink] = ''">

d> returns TRUE (that's a pair of empty single quotes after the '=')

d> Why? I thought not(string(.)) *is* the same as an empty element?
Here is you compare nodeset with a string, which is true "if there is a node
in the node-set such that the result of performing the comparison on the
string-value of the node and the other string is true."

Seemingly, there is pageTitle[../linkID = $activeLink] with the empty string
in the document.

With best regards, Alex Shirshov.
Nov 12 '05 #3
not(string(.)) returns boolean. So in effect you are comparing node with
boolean?
Aha! OK...that makes sense now.
//pageTitle[../linkID = $activeLink] = not(string(.))
has nothing to do with pageTitle node, instead it refers to current node
in a context xsl:when is executed.


Not quite sure what that means. Can you elaborate?

I'm still trying to grasp all of the syntax.

I'm trying to find the specific 'pageTitle' element that has a sibling
element of 'linkID' with an empty value. I think the problem is that I'm
looking at a nodeset, not an element?

-Darrel
Nov 12 '05 #4
> Seemingly, there is pageTitle[../linkID = $activeLink] with the empty
string
in the document.


Thanks, Alex.

So, what is the proper way to test for what I'm looking for? Is it fine to
compare a specific node to empty quotes to determine if it is empty?

And is my syntax correct to begin with?

<xsl:when test="//pageTitle[../linkID = $activeLink] = ''">

In english, I'm trying to find the one (well, first, I suppose, though there
is only one) 'pageTitle' element in the document that has a sibling element
'linkID' equal to activeLink. Once found, I want to see if the 'pageTitle'
element is empty.

-Darrel
Nov 12 '05 #5
Hello, darrel!
You wrote on Tue, 13 Apr 2004 09:08:47 -0500:
[Sorry, skipped]

d> In english, I'm trying to find the one (well, first, I suppose, though
d> there is only one) 'pageTitle' element in the document that has a
d> sibling element 'linkID' equal to activeLink. Once found, I want to see
d> if the 'pageTitle' element is empty.

<xsl:if test="string(pageTitle[../linkID = $activeLink]) = ''"></xsl:if>

With best regards, Alex Shirshov.
Nov 12 '05 #6
<xsl:if test="string(pageTitle[../linkID = $activeLink]) = ''"></xsl:if>


Hmm, I had this:

<xsl:when test="//pageTitle[../linkID = $activeLink] = ''">

And then tried your equation:

<xsl:when test="string(pageTitle[../linkID = $activeLink]) = ''">

The first one seems to work, but the second one doesn't. I'm guessing it's
because the second one isn't defining a specific node?

-Darrel
Nov 12 '05 #7
darrel wrote:
//pageTitle[../linkID = $activeLink] = not(string(.))
has nothing to do with pageTitle node, instead it refers to current node
in a context xsl:when is executed.

Not quite sure what that means. Can you elaborate?


In expression
//pageTitle[../linkID = $activeLink] = not(string(.))

<xsl:template match="foo">
<!-- Here current node (context node) is foo -->
<xsl:if test="//pageTitle[../linkID = $activeLink] = not(string(.))">

.. in your expression is foo element.
I'm trying to find the specific 'pageTitle' element that has a sibling
element of 'linkID' with an empty value. I think the problem is that I'm
looking at a nodeset, not an element?


It's
//pageTitle[../linkID = $activeLink][.='']

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
Nov 12 '05 #8
Hello, darrel!
You wrote on Tue, 13 Apr 2004 13:47:24 -0500:
??>> <xsl:if test="string(pageTitle[../linkID = $activeLink]) =
??>> ''"></xsl:if>

d> Hmm, I had this:

d> <xsl:when test="//pageTitle[../linkID = $activeLink] = ''">

This will be true if there is a node in nodeset, that reterned by
//pageTitle[../linkID = $activeLink] expression, equals to empty string.

d> And then tried your equation:

d> <xsl:when test="string(pageTitle[../linkID = $activeLink]) = ''">

True if the first node in nodeset, that reterned by //pageTitle[../linkID =
$activeLink] expression, equals to empty string.

I use string function, 'cause you said
[q]
I'm trying to find the _one_ (well, _first_, I suppose, though there is only
one)
[/q]

d> The first one seems to work, but the second one doesn't. I'm guessing
d> it's because the second one isn't defining a specific node?

Please, be more precise and post some snippets of the original xml.

With best regards, Alex Shirshov.
Nov 12 '05 #9

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

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
3
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns...
4
by: Cyrus D. | last post by:
Hi guys, What's the best way to test for an empty form value ? I am doing it like this now: $test = $_POST; if(strlen($test) < 1) // it is empty ! Maybe I can just go:
14
by: cj | last post by:
What is string.empty used for? I can't say: if string.empty then I have to use: if string = "" then which is ok, I just want to know what .empty is for.
4
by: VMI | last post by:
How can I split a string that looks like this: John, Doe, 37282, box 2, 10001, "My description, very important", X, Home If I use String.Split(), it'll split the string that's between the...
3
by: Bob | last post by:
I accept text, add_slashes, and store it in my MySQL DB. When I display the text, I normally strip_slashes and also strip_tags. This all works excepts for a field with double quotes. e.g. "My...
31
by: noagbodjivictor | last post by:
How to check if a string is empty in python? if(s == "") ??
4
by: MartinRinehart | last post by:
Thinking about unclosed multi-line quotes. When you open a multi-line quote (type '"""') what does your editor do? Does it color the remainder of your text as a quote, or does it color the line...
6
jinalpatel
by: jinalpatel | last post by:
I am using following code for searching records. 'Purpose: Build up the criteria string form the non-blank search boxes, and apply to the form's Filter. 'Notes: 1. We tack " AND " on...
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?
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
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...
0
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...
0
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,...

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.