[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] text() handling

Subject: Re: [xsl] text() handling
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 14 Jan 2005 15:54:49 GMT

  Why does:

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

  easily overwrite all <person> text nodes with the value "David",..

It's a bit hard to know exactly what you mean here, but I suspect that
the answer is: "it doesn't".

person nodes are element nodes not text nodes, and text nodes have no
name. I suspect you mean text nodes that are children of person

Note that a template never does anything unless it is applied, so the
above does nothing unless the template for person elements calls
apply-templates on its child text nodes. If it does then _each_ such
text node will generate  a newline a tab David a newline and another
the xsl:apply-templates  in teh above will never generate anything as it
does nothave a select attribute so applies templates to the children of
the text node, and text nodes never have children.


  <xsl:template match="person/text()[.="Peter"]">

  Not overwrite every <person>Peter</person> with

The same comments apply here, this will match the text node that you
indicate, although it has the same priority as the first template so if
they are both there that's an error although the system may recover by
just using one of them, you may want to add priority="10".

 <xsl:template match="person/text()[.="Peter"]" priority="10">

again unless the template for match="person" applies templates to its
children this will have no effect.


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

Current Thread