[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

copying text into stylesheet using document(), with a

Subject: copying text into stylesheet using document(), with a twist
From: "Dunning, John" <JDunning@xxxxxxxxx>
Date: Tue, 7 May 2002 12:35:19 -0400
text in stylesheet
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.