Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 8th, 2006, 08:11 AM
Registered User
 
Join Date: Mar 2006
Location: , , Canada.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default <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.

Reply With Quote
  #2 (permalink)  
Old June 8th, 2006, 05:00 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
Reply With Quote
  #3 (permalink)  
Old June 9th, 2006, 06:43 AM
Registered User
 
Join Date: Mar 2006
Location: , , Canada.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #4 (permalink)  
Old June 9th, 2006, 07:24 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
Reply With Quote
  #5 (permalink)  
Old June 9th, 2006, 07:33 AM
Registered User
 
Join Date: Mar 2006
Location: , , Canada.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When <xsl:value-of select="Tooltip" /> = value ismailc XSLT 3 October 17th, 2008 04:43 AM
embedded <xsl:element> into <xsl:with-param> petergoodman XSLT 2 July 9th, 2008 06:36 AM
Performance for <xsl:import> and <xsl:include> vikkiefd XSLT 2 April 16th, 2008 08:06 AM
<xsl:for-each> with a variable select="attribute" BeneathClouds XSLT 1 August 1st, 2005 03:36 AM
HELP: XSL -> HTML <select selected=true> jedbartlett XSLT 4 October 7th, 2004 11:16 PM



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


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