Subject: RE: [xsl] text() handling From: "Ross, Douglas" <DRoss@xxxxxxxxxx> Date: Fri, 14 Jan 2005 11:08:03 -0500 |
I have a couple observations and questions: Question: does the function text() return a boolean or the text of the node? Observation: the text node may contain white space. Suggestion: You might try Match="node[string(.)=xalan:trim(string(.))='anyValue']" Presumes you use the xalan extension method to invoke the Java String::trim method. If the nodes don't contain white space you can omit the trim part. Douglas Ross Developer, HTML UI Framework Kronos E-mail: dross@xxxxxxxxxx www.kronos.com -----Original Message----- From: Robert Soesemann [mailto:rsoesemann@xxxxxxxxxxx] Sent: Friday, January 14, 2005 11:02 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] text() handling Sorry for not being that precise. I only had and only need one template. With this template I need to replace the text node 'anyValue' with the text node 'otherValue'. And this does not work with the following template. Why? <xsl:template match="person[text()='anyValue'> otherValue </xsl:template> -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: Freitag, 14. Januar 2005 16:55 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] text() handling Why does: <xsl:template match="person/text()"> David <xsl:apply-templates/> </xsl:template> 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 elements. 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 tab. 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. but <xsl:template match="person/text()[.="Peter"]"> David <xsl:apply-templates/> </xsl:template> Not overwrite every <person>Peter</person> with <person>David</person>???? 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"> <xsl:text>David</xsl:text/> </xsl:template> again unless the template for match="person" applies templates to its children this will have no effect. David ________________________________________________________________________ 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: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] text() handling, David Carlisle | Thread | RE: [xsl] text() handling, Michael Kay |
RE: [xsl] msxml apostrophe encoding, Pieter Reint Siegers | Date | Re: [xsl] Trying to Achieve inside/, W. Eliot Kimber |
Month |