Re: Two Hard Questions (at least for me)

Subject: Re: Two Hard Questions (at least for me)
From: Edd Dumbill <edd@xxxxxxxxxxxxx>
Date: Sun, 4 Jul 1999 00:44:25 +0000
On Sat, Jul 03, 1999 at 05:30:35PM -0500, Ross Cormier wrote:
> I hope they are easy for some someone here.

That would be a relative term... ;)

> I am using IBM's XML parser and the Lotus XSL parser.
> 1.  How to match null
> I want to match any node with no data.
>     example:
> 	<field1>data</field1>
> 	<field2></field2>
> How do I match field2's null.  I have tried the following with no luck.
> <xsl:template match="*[not(text())]">
> </xsl:template> 

I'm using XT and your template works as you would like!
(Though this seems like a crazy kind of thing to match for globally
throughout the stylesheet)

However there is room for some confusion.  Having read the
WD ( it says
"The node test text() is true for any text node."  Which would lead
me to think that the correct way to say what you're doing is:
match="*[not(from-children(text()))]" which filters the nodes down
to all those which don't have text-node children, which is what you

But in section 6.1.4 the WD lists as an abbreviated syntax:
"text() selects all text node children of the context node".
I've tried both your way and my longer way expressed above in
XT and they both work (at least for the example XML input documents
I tried).  So it would seem that XT and LotusXSL behave differently
in this respect. 

I don't use LotusXSL myself, but try the longer match:
<xsl:template match="*[not(from-children(text()))]">

and see if it works for you.

[there is of course another question -- does 'null' for you mean
 just 'no-text' or does it mean 'empty'?  For instance your above
 test would identify <field2><field3/></field2> as "NULL VALUE"
 when it isn't, as it doesn't have a text-node child. The best I
 can come up with to match true emptiness is this:
 match="*[not(from-children(*) or from-children(text()))]" which
 assumes that nodes with comments or PIs in count as 'null' for

> 2. How do I include an '&' in the resulting HTML.  I am trying to create a
> query string, Servlet?data1=foo&data2=bar.
> The XML looks something like this.
> <some_data>The Data
>   <link servlet="SomeServlet" Query="?data1=foo&data2=bar"/>
> </some_data>
> I want to ouput <A HREF="Query?data1=foo&data2=bar">The Data</A>

:-) You will have a difficult time as your input XML is invalid.
The ampersand is the introducer for a character entity reference.  Valid XML
would be: <link servlet="SomeServlet" Query="?data1=foo&amp;data2=bar"/>
which should do what you want.


& is deprecated as a parameter separator, use ; instead if possible.  Then
you shouldn't have this difficulty.  I'm afraid I do not know whether or not
servlets support ; as a parameter separator.

(see B.2.2 in

> TIA, 
> Ross Cormier


Edd Dumbill | Director, Useful Information Co. & Pharmalicensing Ltd
tel: +44 (0) 702-093-6870 | edd@xxxxxxxxxxxxx |
fax: +44 (0) 870-164-0230 | pgp:

 XSL-List info and archive:

Current Thread