xsl-list
[Top] [All Lists]

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

2011-08-05 09:43:45
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(_dot_)mcdonald(_at_)cogeco(_dot_)ca>:
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




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