[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Recursive Split

Subject: RE: Recursive Split
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 14 Nov 2007 20:51:29 -0500
RE:  Recursive Split
At 2007-11-14 20:28 -0500, Alice Ju-Hsuan Wei wrote:
Looks like now I am trying to use the tokenize function, but it appears that it does not allow me to use id() with it.

You are misinterpreting the evidence.


When I ran the XSLT, it tells me this: F Cannot select a node here: the context item is an atomic value, with the errors pointing to the line where it says id(.).

Exactly. The value of "." is a string. The id() function works on the ID table created for a given tree. When you do not supply a second argument to id(), the tree assumed is that of the current node. There is no tree associated with an atomic value. You need to supply a second argument with a node in the tree from which you wish to draw your ID values.


Here is my XML:

             <listItem>
                  <to_do xml:id="cheese">Cheddar Cheese</to_do>
              </listItem>
               <listItem>
                  <to_do xml:id="beef">Chuck Steak</to_do>
              </listItem>
               <listItem>
                  <to_do xml:id="vegetables">Brocoli, Beans, Carrots</to_do>
              </listItem>
              <listItem>
                  <to_do xml:id="milk">Dean's Low Fat Milk 2%</to_do>
              </listItem>

 <do>
  <date>2007-11-14</date>
 <list>milk cheese vegetables beef</list>
 <limit_price>20</limit_price>
  <do>

Okay, I'm assuming both of the above are in the same file and not separate files.


Current XSL:

 <xsl:template name="do_list">
  <xsl:variable name="do" select="list">
  <xsl:variable name="item" select="tokenize($item, '\s+')"/>
   <xsl:for-each select="$item">
  <xsl:value-of select="id(.)"/>
  </xsl:for-each>
  </xsl:template>

Some of the above is just wrong ... you cannot base a variable on a variable of the same name.


I'm assuming you want:

    <xsl:variable name="do" select="list"/>
    <xsl:variable name="item" select="tokenize($do, '\s+')"/>
    <xsl:for-each select="$item">
      <xsl:value-of select="id(.,$do)"/>
    </xsl:for-each>

I hope this helps.

. . . . . . . . . . Ken

--
Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.