You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stuart Roebuck <sr...@adolos.com> on 2000/04/10 17:20:45 UTC
RE: [Help!] Concatenating @attributes as parts of XSLT apply-temp late tags
Joe,
Thanks, just before you replied I managed to get it working by passing the
string as a parameter to a named template which did the apply-template
call. eg.:
<xsl:template name="pe:macro-select">
<xsl:apply-templates select="document($file)"/>
</xsl:template>
called with:
<xsl:call-template name="pe:macro-select">
<xsl:with-param name="file">
<xsl:text>mydirectory/</xsl:text>
<xsl:value-of select="@file"/>
</xsl:with-param>
</xsl:call-template>
But your solutions is an order of magnitude better!
You don't happen to have a similar solution to dealing with a combination
of filename and XPath where both are passed as attributes.
e.g. trying to do something like:
<xsl:apply-templates select="document(@file)//@mytag"/>
which doesn't work. It appears as though the @mytag is being replaced by
a quoted string.
Thanks again,
Stuart.
Begin forwarded message:
> I'm not 100% sure if this will work, but you might want to try XPaths
> "concat" function. Something like:
>
> <xsl:apply-templates select="document(concat("mydirectory/",@file))"
> />
>
> just might do the trick.
>
> Joe
>
>
> -----Original Message-----
> From: Stuart Roebuck [mailto:sr@adolos.com]
> Sent: Monday, April 10, 2000 6:43 AM
> To: cocoon-users@xml.apache.org
> Subject: [Help!] Concatenating @attributes as parts of XSLT
> apply-template tags
>
>
> This problem is really causing difficulties...any help very much
> appreciated.
>
> I'm having trouble trying to concatenate attributes in apply-template
> tags. I think the easiest way of explaining the problem is to give an
> example.
>
> I have the following <xsl:template match="..."> XSLT template that works
> well:
>
> <xsl:template match="include">
> <xsl:apply-templates select="document(@file)" />
> </xsl:template>
>
> Given an XML document with the construct:
>
> <include file="filename.xml" />
>
> It takes the content of the file 'filename.xml' and incorporates it into
> the document.
>
>
> However...
>
> I want to be able to put that file in a different directory without
> changing the <include...> tag entry.
>
> I therefore what to produce a template something like:
>
> <xsl:template match="include">
> <xsl:apply-templates select="document(mydirectory/@file)" /> <!-- THIS
> DOESN'T WORK -->
> </xsl:template>
>
> I don't seem to be able to concatenate the attribute reference '@file'
> onto the end of a root file URL.
>
> Am I trying to do something impossible, or is there a syntax to get round
> this kind of problem?
>
> For non-XSLT tags I think I could get away with: 'mydirectory/{@file}' but
> that doesn't seem to work with the <xsl apply-templates...> tag.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>