473,789 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3707
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(pa geTitle[../linkID = $activeLink]) = ''"></xsl:if>

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


Hmm, I had this:

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

And then tried your equation:

<xsl:when test="string(pa geTitle[../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(pa geTitle[../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(pa geTitle[../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
5040
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 double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
3
8900
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 a empty value instead of returning the browser type. Here is the line which i am using in my code and from manual: <?php echo $_SERVER; ?>
4
2305
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
2352
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
8575
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 double-quotes, and I don't want that. How can I use the String.Split to split the string EXCEPT the string that has double-quotes? In my case, the separator is the comma ','.
3
3789
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 Book's Title" is very simple When I display this field, it is totally blank. What's the solution?
31
88622
by: noagbodjivictor | last post by:
How to check if a string is empty in python? if(s == "") ??
4
2705
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 with the open quote as a quote and leave the rest of your code alone? What do you want it to do? This is a tokenizer question in disguise, of course. The simple way to
6
2358
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 the end of each condition so you can easily add more search boxes; _ we remove the trailing " AND " at the end. Dim strWhere As String 'The criteria string. Dim lngLen As...
0
9506
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
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
10193
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
7525
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
6761
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
5415
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...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4089
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2906
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.