Get Text from Nodeset
Posted: Thu Jun 07, 2018 11:33 am
Hi everybody, I work in xslt 1..0 and I have just get an Array and convert it to a Node Set by the msxsl:node-set() function so i get an array with 12 elements as you can see in the code, but which sentence I need to introduce for getting an text value of for example position 3 of the array I think that i've tested all the possibilities and I always get a Nodeset and not a text value
<xsl:variable name="urlSchema" select="string('http://www.info.es/es/fr/data/2017-09-12/space.xsd')" /> --> Array by split by the / character
<xsl:variable name="arraySchema">
<xsl:call-template name="split">
<xsl:with-param name="str" select="$urlSchema" />
<xsl:with-param name="splitString" select="'/'" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="cvt" select="msxsl:node-set($arraySchema)" /> --> convert into Array
<xsl:variable name="Totcvt" select="$cvt/node()" /> ---> now it has 12 elements
<xsl:variable name="uno" select="$Totcvt[3]" /> ---- access to third element (nodeset)
<xsl:variable name="dos" select="$uno/text()" /> --> also nodeset
<xsl:variable name="cuenta" select="count($Totcvt)" /> ---> number 12
Which Sentence for getting Text and not Nodeset ???
<xsl:template match="/">
<xsl:copy-of select="$uno"/>
<xsl:copy-of select="$dos"/>
<xsl:value-of select="$cuenta"/>
</xsl:template>
Best Regards
<xsl:variable name="urlSchema" select="string('http://www.info.es/es/fr/data/2017-09-12/space.xsd')" /> --> Array by split by the / character
<xsl:variable name="arraySchema">
<xsl:call-template name="split">
<xsl:with-param name="str" select="$urlSchema" />
<xsl:with-param name="splitString" select="'/'" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="cvt" select="msxsl:node-set($arraySchema)" /> --> convert into Array
<xsl:variable name="Totcvt" select="$cvt/node()" /> ---> now it has 12 elements
<xsl:variable name="uno" select="$Totcvt[3]" /> ---- access to third element (nodeset)
<xsl:variable name="dos" select="$uno/text()" /> --> also nodeset
<xsl:variable name="cuenta" select="count($Totcvt)" /> ---> number 12
Which Sentence for getting Text and not Nodeset ???
<xsl:template match="/">
<xsl:copy-of select="$uno"/>
<xsl:copy-of select="$dos"/>
<xsl:value-of select="$cuenta"/>
</xsl:template>
Best Regards