Re: [xsl] Unable to get text() of node

Subject: Re: [xsl] Unable to get text() of node
From: "Liron" <magilam@xxxxxxxxxxxxxxxx>
Date: Sat, 21 Jan 2006 16:11:40 +0100
Hi Mukul,

Thank you very much for your reply and indeed you're right but I must ask for an explanation.
I can see why text()[2] would get me the second text node for the <child> element but I tried to do the following after your reply:
<child>
<childname/>
name
</child>


1) The output was "name" which means that even though <childname> is empty, its content is still considered as text node (though empty). Is that the case?

2) How can I get the text of <child> without knowing his descendants?. Just the absolute text of it ("name" in this case). I thought that child:text() would do the trick but it didn't.

I'm really trying to understand this but a newbie is a newbie after all...

Thank you
Liron

----- Original Message ----- From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Saturday, January 21, 2006 3:44 PM
Subject: Re: [xsl] Unable to get text() of node



Hi Liron,
 I think you need

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">


<xsl:output method="xml" indent="yes" />

<xsl:template match="/">
  <tree>
    <xsl:for-each select="tree/child/childname">
      <childText>
        <xsl:value-of select="../text()[2]"/>
      </childText>
    </xsl:for-each>
  </tree>
</xsl:template>

</xsl:stylesheet>

Regards,
Mukul

Current Thread