xsl-list
[Top] [All Lists]

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

2010-12-20 07:15:46
On 20/12/2010 13:09, David Lee wrote:
XSLT 2.0
I have a problem (probably my own misuse of XSLT) but I run into cases where

<xsl:template  match="NODE/text()">
…
</xsl:template>

can match more then once in a row.   I have not debugged this yet to
determine if something more complex is really the culprit (probably is),
and the text nodes matched seem to be whitespace  " \n\t .."
But before I really start digging maybe someone could tell me offhand what
the *expected* behaviour is ?

If I have an element lik
                 <ELEM>
   some

Text
Here</ELEM>


is
<xsl:template  match="NODE/text()">

*supposed* to be called once and only once with the entire text children or
is it possible that it is called multiple times with chunks of data as the
processer sees fit. ?

The xpath data model never has empty text nodes in a document or adjacent text nodes, they have to be merged appropriately.

So text() should match the entire text node. matching text() is a pretty rare thing to need to do though (and makes your code fragile if for example there are any comments in the file, then the text nodes are split either side of the comment.)

David



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________

--~------------------------------------------------------------------
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>
--~--