xsl-list
[Top] [All Lists]

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

2010-12-22 16:22:11
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(_at_)mulberrytech(_dot_)com
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
======================================================================

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--