Re: [xsl] test on string-length of text() for element with node

Subject: Re: [xsl] test on string-length of text() for element with node
From: Bram Reader <bram.listmail@xxxxxxxxx>
Date: Fri, 5 Aug 2011 16:43:34 +0200
If I use string-length(normalize-space(maritalstatus/text())), the result =
0.
If I place 'textstring' direct after the starttag like the example
below, the result = 10

<maritalstatus>textstring
       <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>
</maritalstatus>

But the xml node I have to work with is like the example below, and
then the result is 0

<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>



2011/8/5 Murray McDonald <m.mcdonald@xxxxxxxxx>:
> I assume "it doesn't work" means you're not getting the right length? -- If
> so try using normalize-space().
>
> string-length(maritalstatus/text()) == 11
>
> string-length(normalize-space(maritalstatus/text())) == 10
>
> Murray
>
> 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

Current Thread