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

Applying templates based upon param passed in and tok

Subject: Applying templates based upon param passed in and tokenized
From: "Calvados Boulard" <calvados.boulard@xxxxxxxxx>
Date: Thu, 1 May 2008 09:43:13 -0700
 Applying templates based upon param passed in and  tok
Hi there...I'm trying to apply templates based upon a param that I've
passed in, tokenised and split via substring...

<xsl:param name="siteIDString"
select="'11111111~00000008,11111111~00000002,11111111~00000005,11111111~11111114,11111111~14564444,11111111~14564442,11111111~00000004,1~1,1~22,'"/>

    <xsl:template match="/">
        <xsl:apply-templates select="aspect"/>
    </xsl:template>

    <xsl:template match="aspect">
        <favorite>
            <xsl:for-each select="tokenize($siteIDString, ',')">
                <xsl:variable name="sID"><xsl:value-of
select="substring-before(.,'~')"/></xsl:variable>
                <xsl:variable name="dID"><xsl:value-of
select="substring-after(.,'~')"/></xsl:variable>
                <xsl:apply-templates select="site[@id='$sID']" mode="goodSite"/>
                <xsl:apply-templates select="document[@id='$dID']"
mode="goodDoc"/>
            </xsl:for-each>
        </favorite>
    </xsl:template>

<xsl:template match="site" mode="goodSite">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="document" mode="goodDoc">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
        </xsl:copy>
    </xsl:template>

But I keep getting an error "Axis step child::element(site,xs:anyType)
cannot be used here: the context item is an atomic value;

My source xml looks as follows:

<root>
     <site id='11111111' otherAttributes='otherValues'>
        <dir id='00000001' otherAttributes='otherValues'>
          <document id='00000008' otherAttributes='otherValues'/>
        </dir>
    </site>
    <site id='11111112' otherAttributes='otherValues'>
        <dir id='00000002' otherAttributes='otherValues'>
          <document id='00000028' otherAttributes='otherValues'/>
        </dir>
    </site>
</root>


Basically i'm trying to strip out all <dir> and <document> nodes that
do not have an site-document id found in the passed in param.

Any help with this would be greatly appreciated.

Thanks...Cal.

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