Subject: RE: [xsl] copying text into stylesheet using document(), with a twist From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Tue, 7 May 2002 18:48:15 +0100 |
You seem to be making a meal of this. Put <inc href="file:///c:/text/en/boilerplateText.xml"/> at the place in the stylesheet where you want the XML file included, and then preprocess the stylesheet with another stylesheet containing two template rules: (a) the identity template rule, and (b) <xsl:template match="inc"> <xsl:copy-of select="document(@href)"/> </xsl:template> Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of > Dunning, John > Sent: 07 May 2002 17:35 > To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx' > Subject: [xsl] copying text into stylesheet using document(), with a > twist > > > 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='ti > tleText']"/> > > 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 > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] copying text into stylesheet , Dunning, John | Thread | [xsl] question about javascript and, Simon Choy |
[xsl] Re: Pad a string, Dimitre Novatchev | Date | Re: [xsl] question about javascript, Greg Faron |
Month |