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

Subject: Re: [xsl] Novice Question - matching entire text children
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 20 Dec 2010 15:35:51 -0500

On 12/20/2010 12:09 PM, David Lee wrote:
It's understandable that the novice might not know that 'string()' is a
function, while 'text()' is a node test. A novice probably isn't going
to know what the difference between a function and a node test is.

The funny thing (knowing quite a lot about XQuery but still hardly anything
about XSLT) is that I know very well the difference between string() and
in XQuery, XDM and XPath.
I know text() is a node and string() is a function.

Yes, and I know you know. :-)

Of course, in a public forum, one writes for a public audience, and there are plenty of novices around who might benefit from seeing it confirmed that no, those two things aren't at all the same, notwithstanding appearances. A lot of learning goes on around here just from people's watching over each other's shoulders (to say nothing of experts pretending to be novices).

I was just hoping (and worth wasting 30 seconds trying) that Maybe in some
magic fairyland  XSLT would *evaluate* the match="ELEM/string()" and
determine that indeed that evaluated to a non-empty string and decide to run
the template...  Especially when running into the tidbit in the specs that
match expressions are a 'subset of XPath expressions' ... so hey, toss a
little pixie dust and you never know what comes out ... It would be nice if
it worked ...

More knowledge is even MORE Dangerous !

Indeed, and your being willing to conduct such experiments and draw conclusions from them is one of the reasons you're never a novice for long.

match="ELEM[string()]" would work not too differently from what you're thinking. It matches when ELEM/string() returns a Boolean true(), i.e. when ELEM's string value is not "". Of course, it matches the ELEM not the text inside it.

As to the question at hand, I'm still not sure we know why your template matching "ELEM/text()" was matching more than once inside a given ELEM, whether because of something about your tree, or the presence of a comment or PI or other interference.

But I'm not sure you care any more: maybe your actual question has been asked and answered.


Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.      
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