Re: [xsl] Novice Question - matching entire text children

Subject: Re: [xsl] Novice Question - matching entire text children
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 22 Dec 2010 17:22:05 -0500
Hermann,

On 12/22/2010 3:59 PM, Hermann Stamm-Wilbrandt wrote:
In XPath 2.0:

normalize-space(string-join(text(),''))

In XPath 1.0 you're stuck, just as you feared.

Just had an idea -- finite string-join approximations. Simulate string-join(text(),'') by concat(text()[1],text()[2],...,text()[k]) for any finite chosen value k.

This works in XPath 1.0 given that k is chosen big enough.
Sample:
$ xpath++ "concat(/a/text()[1],/a/text()[2],/a/text()[3])" mixed.xml  13
$

Yes but I think it will fail if /a has only one text node child, since concat() will only have one argument in that case. (OTOH you now know not to trust my error-prone wetware XPath processor.)


You could try concat('','',/a/text()[1],/a/text()[2],/a/text()[3]) to make sure there are always at least two arguments.

But I'd rather not have the problem to begin with. :-)

Cheers,
Wendell

--
======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread