Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: "Calvados Boulard" <calvados.boulard@--------->
To:
Date: 5/1/2008 4:44:00 PM
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.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent