Subject: [xsl] copying text into stylesheet using document(), with a twist From: "Dunning, John" <JDunning@xxxxxxxxx> Date: Tue, 7 May 2002 12:35:19 -0400 |
Hi, I'm trying to include boilerplate text from an XML document into an XSL stylesheet, for which I've found numerous examples that render document instances, but I have not been able to get this to work when the output is an XSL stylesheet. I have the text I want copied in XML files: <!-- file /text/en/boilerplateText.xml --> <boilerplate> <text name="addressText" output="Address: ">Address: </text> <text name="nameText">Name: </text> <text name="titleText">Title: </text> </boilerplate> The stylesheets include calls to the templates using document(); I've tried this using both a variable and by the document() function in each template: <xsl:variable name="textDoc" select="document('file:///c:/text/en/boilerplateText.xml')"/> ... <xsl:template match="title"> <xsl:value-of select="$textDoc//text[@name='titleText']"/> ... </xsl:template> and <xsl:value-of select="document('./text/boilerplateText.xml')//text[@name='titleText']"/> Both of these will render the document, but what I want to do is copy the *text*, not the instruction, to a final, compiled stylesheet. I create the 'full' (compiled) stylesheet by copying all template rules, etc. from the included templates: <!-- stylesheet to copy all referenced modules into one file --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo ="http://www.w3.org/1999/XSL/Format" version="1.0"> <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="xsl:include"> <xsl:copy-of select="document(@href)//xsl:template | document(@href)//xsl:stylesheet/xsl:variable | document(@href)//xsl:stylesheet/xsl:param | document(@href)//xsl:decimal-format" /> </xsl:template> <xsl:template match="*|@*|text()|comment()"> <xsl:copy><xsl:apply-templates select="*|@*|text()|comment()"/></xsl:copy> </xsl:template> </xsl:stylesheet> I imagine that I need a second step using another stylesheet to then process that stylesheet and copy the text from the named templates using document(), but I have not been able to get it to work. So far I've tried <xsl:template match="xsl:value-of[contains(@select,'document(')]"> <xsl:value-of select="."/> <!-- nothing --> <xsl:apply-templates select="@select"/> <!-- nothing --> <!--xsl:apply-templates select="."/--> <!-- '.' = stack overflow --> <xsl:value-of select="@select"/> <!-- copies document() arg --> <xsl:value-of select="@output"/> <xsl:copy-of select="."/> <!-- copies template rule --> </xsl:template> and <xsl:template match="xsl:value-of[contains(@select,'$textDoc')]"> <xsl:value-of select="."/> <!-- nothing --> <xsl:apply-templates select="@select"/> <!-- nothing --> <!--xsl:apply-templates select="."/--> <!-- '.' = stack overflow --> <xsl:value-of select="@select"/> <!-- copies document() arg --> <xsl:value-of select="@output"/> <xsl:copy-of select="."/> <!-- copies template rule --> </xsl:template> Any ideas (or solutions!) will be greatly appreicated, Thanks, John XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] find out if an attribute , Khan, Amir | Thread | RE: [xsl] copying text into stylesh, Michael Kay |
Re: [xsl] Pad a string, Manish M. Shah | Date | RE: [xsl] find out if an attribute , Khan, Amir |
Month |