xsl-list
[Top] [All Lists]

[xsl] Applying templates based upon param passed in and tokenized

2008-05-01 09:43:42
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[(_at_)id='$sID']" 
mode="goodSite"/>
                <xsl:apply-templates select="document[(_at_)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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>