| <xsl:variable name="text">
| <xsl:for-each select="/path/to/maritalstatus/text()">
| <xsl:value-of select="."/>
| </xsl:for-each>
| </xsl:variable>
|
| <xsl:value-of select="string-length($text)"/>
|
that is correct, but can be done shorter ...
<xsl:variable name="text"><xsl:copy-of select="/path/to/maritalstatus/
text()"/></xsl:variable>
<xsl:value-of select="string-length($text)"/>
Mit besten Gruessen / Best wishes,
Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
Fixpack team lead
WebSphere DataPower SOA Appliances
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
From:
Andrew Welch <andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com>
To:
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date:
08/05/2011 04:44 PM
Subject:
Re: [xsl] test on string-length of text() for element with node
Ah sorry it's because in XSLT 1.0 'first item semantics' kick in when
you supply a sequence of more than 1 item to a function that expects
only one... so doing /text() returns multiple nodes and then all but
the first are silently dropped.
I haven't written any xslt 1.0 for a long time, but I think you would
need to store all the text node in a variable, then get the string
length of that:
<xsl:variable name="text">
<xsl:for-each select="/path/to/maritalstatus/text()">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="string-length($text)"/>
If you want to ignore whitespace only nodes, then use xsl:strip-space
on the <maritalstatus> element or do text()[normalize-space(.)]
cheers
andrew
On 5 August 2011 15:27, Bram Reader <bram(_dot_)listmail(_at_)gmail(_dot_)com>
wrote:
I also thought so, but I don't know why its not working.
If 'textstring' is placed direct after the starttag <maritalstatus>,
followed by the child elements it works.
But in this case it doesn't work
Regards,
Boudewijn
2011/8/5 Andrew Welch <andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com>:
On 5 August 2011 15:06, Bram Reader
<bram(_dot_)listmail(_at_)gmail(_dot_)com> wrote:
Hello,
Probably it's not difficult, but I'm struggling with the following
issue (maybe it's because it's Friday afternoon)
From an xml node set, I need to select the string-length of an
elements content without its child elements.
xml node set
<maritalstatus>
<cs:info xmlns:cs="http://cs.nl/cs" id="6">
<codeList>maritalstatus</codeList>
<instruction id="7">no instruction</instruction>
<length>1</length>
<minOccurs>0</minOccurs>
<pattern>\d*</pattern>
</cs:info>
<cs:update xmlns:cs="http://cs.nl/cs">
<additionalInfo>test</additionalInfo>
<oldData>2</oldData>
<newData>5</newData>
</cs:update>textstring
</maritalstatus>
From the element <maritalstatus> the string-length of only
'textstring' must be selected. How do I escape the child elements in
the xsl:value-of select.
I'm using XSLT 1.0 with xsltproc.
Its just:
maritalstatus/text()
--
Andrew Welch
http://andrewjwelch.com
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--
--
Andrew Welch
http://andrewjwelch.com
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--