Subject: Re: [xsl] Inserting the value of a variable in a result-document From: "Spencer Tickner" <spencertickner@xxxxxxxxx> Date: Mon, 30 Apr 2007 15:49:22 -0700 |
Thanks for the advice on the document. I'll implement that part. The reason I'm doing it with a named template is that this is part of a larger transformation in which new files are created based on realtionships in other files. IE, the file and insertion string will change each time. Sorry but looking back my original example doesn't really get that across. It would have been more correct to have something like:
<xsl:call-template name="insert_node"> <xsl:with-param name="myNode" select="$Node"/> <xsl:with-param name="myInputDoc" select="document($File)"/> <!-- Thanks David --> <xsl:with-param name="myResultsFile" select="$newFile"/> </xsl:call-template>
Where the various variables are based on conditions the call-template is wrapped in.
Spencer On 4/30/07, David Carlisle <davidc@xxxxxxxxx> wrote:
don't do
<xsl:with-param name="myInputDoc">file:///c:/test.xml</xsl:with-param>
(which forces the system to (act as if it had to) generate a temporary tree with a new document node with a text node child, which is expensive to build if all you are going to do is coerce back to a string, instead do
<xsl:with-param name="myInputDoc" select="'file:///c:/test.xml'"/>
or just pass in the document rather than a string
<xsl:with-param name="myInputDoc" select="doc('file:///c:/test.xml')"/>
I wouldn't use named templates at all for this, just have an identity template
<xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template>
and a template for insert that inserts stuff:
<xsl:template match="insert"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> <xsl:text>the new insert</xsl:text> </xsl:template>
David
________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Inserting the value of a , David Carlisle | Thread | [xsl] disable-output-encoding with , Robert Capasso |
Re: [xsl] disable-output-encoding w, David Carlisle | Date | RE: [xsl] casting string as integer, Michael Kay |
Month |