p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   <xsl:for-each select="tokenize($indoc,'&#xA;')"> (http://p2p.wrox.com/showthread.php?t=43685)

kapy_kal June 8th, 2006 08:11 AM

<xsl:for-each select="tokenize($indoc,'&#xA;')">
 
I am getting an unexpected behavior with the tokenize() function or perhaps this is what the output ought to be. The following stylesheet:
<xsl:variable name="indoc" select="unparsed-text('input.txt','ISO-8859-1')"/>
 <doc>
  <xsl:for-each select="tokenize($indoc,'#xA;')">
   <inline>
     <xsl:value-of select="."/>
   </inline>
  </xsl:for-each>
</doc>
produces something like this:
<doc >
 <inline>10 01 1001 23 23
     11 01 1001 24 24
     12 01 1001 25 25
 </inline>
</doc>
instead of (what I would expect):
<doc >
 <inline>10 01 1001 23 23</inline>
 <inline>11 01 1001 24 24</inline>
 <inline>12 01 1001 25 25</inline>
</doc>
Is there something I am missing?
Thanks,
Francine.


mhkay June 8th, 2006 05:00 PM

Your subject line says &_#xA; (without the underscore) but the content says #xA; (with no ampersand). Perhaps that's a mailer corruption, or perhaps it's the bug you are looking for.

I'm not sure without detailed checking whether &_#xA; should work. I think in a regular expression it's safer to write it as \n.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

kapy_kal June 9th, 2006 06:43 AM

Hi Michael!
Thanks for your response.
It is a mailer corruption. However using '\n' does not change anything in the output, I get the same result. The "for-each" element used with the "tokenize" function seems to ignore the fact the <inline> element must be repeated with each iteration and only puts it once as a top element. I find this to be a rather unsual behavior...
Thanks,
Francine.


mhkay June 9th, 2006 07:24 AM

I don't know what you're doing wrong. It works for me. What XSLT 2.0 processor are you using?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

kapy_kal June 9th, 2006 07:33 AM

Oh, that's it! Thanks Michael, it's the processor. I was running the processor that comes with Altova XMLSpy (not sure which one it is) and that is why. Saxon gave the expected result.

Francine.



All times are GMT -4. The time now is 02:02 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.