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

using str:tokenize named template results

Subject: using str:tokenize named template results
From: "vwiswell" <vwiswell@xxxxxxxxxxx>
Date: Fri, 28 Mar 2008 14:58:30 -0500
 using str:tokenize named template results
The str:tokenize template works beautifully (I am required to use xslt 1.0). I am using it to split the input from a multiple select box submitted from an html page thusly:

      <xsl:variable name="inValues">
        <xsl:call-template name="str:tokenize">
           <xsl:with-param name="string" select="$input" />
        </xsl:call-template>
     </xsl:variable>

I want to loop through the tokens checking for matches in my main input, an xml file. So I need nested for-each loops, the outer one looping through my tokens from str:tokenize and the inner one looping through <city>s in my doc.

The xml looks like this:

<sites>
  <site>
    <city>A City</city>
    <institution>Axxxxx Univ.</institution>
    <administers>to any student</administers>
    <schedule>2 times per month</schedule>
    <additional_costs>$15 admin. fee</additional_costs>
    <contact_information>(123) 123-1234</contact_information>
  </site>
  <site>
    <city>B City</city>
    <institution>Bxxxx College</institution>
    <administers/>
    <schedule/>
    <additional_costs/>
    <contact_information/>
  </site>
  <site>
    <city>C City</city>
    <institution>Cxxxxx College</institution>
    <administers>to any student</administers>
    <schedule>1 time per month</schedule>
    <additional_costs>$10 refundable deposit</additional_costs>
    <contact_information>(123) 123-1234</contact_information>
  </site>
  ...
</sites>

I'm not getting any output, so I think I have context issues, but I'm not sure how to fix it. I don't really understand the relationship between the str:tokenize results and my xml doc. It seems analogous to multiple input xml docs, but I'm not sure how to code it. This is what I have tried:

<xsl:template name="buildTable">
<xsl:param name="tokens"/>
<xsl:variable name="ns" select="msxsl:node-set($tokens)"/>
<xsl:for-each select="$ns/token">
<xsl:value-of select="text()" /><br /><!-- this works and proves the tokens are as expected -->
<xsl:for-each select="//city[text() = $ns/token/text()]">
<xsl:sort select="city"/>
<xsl:value-of select="text()" /><br /><!-- this produces no output -->
</xsl:for-each>
</xsl:for-each>
</xsl:template>


If I remove the token (outer) for-each, I get output, but only for the first token (obviously). The tokens get passed to this template just fine.

I'd really appreciate a nudge in the right direction. Thanks.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.