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

Re: Processing xsl within an included document

Subject: Re: Processing xsl within an included document
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 13 Oct 2004 14:21:29 -0400
xsl include header
Brooks,

It appears you may be confusing two different features offered by XSLT:

* when you need access to another document besides your primary source, you can access it by using the document() function

* if you want to modularize your stylesheet, you have two top-level instructions, xsl:import and xsl:include, that can be used

If header.xsl provides code (a set of templates) that you want your stylesheet to use, you should be using xsl:import or xsl:include. You'd use document() only if you wanted to query into it or process some or all of it as *input* to your process. Assuming your case falls into the former category, you could adjust your code as follows:

--- main.xsl ---
<xsl:include href="include/header.xsl"/>

...

[in your template]
<xsl:variable name="testvar" select="'hello'" />
<xsl:call-template name="make-header">
  <xsl:with-param name="value" select="$testvar"/>
</xsl:call-template>
Boring main stuff

--- include/header.xsl ---
<xsl:template name="make-header">
  <xsl:param name="value"/>
  <page>
    <header>
      <h1><xsl:value-of select="$value" /></h1>
    </header>
  </page>
</xsl:template>

I hope that helps,
Wendell

At 01:33 PM 10/13/2004, you wrote:
I know that this is something of a FAQ, and I apologize.  But I've
searched the list archives and googled until the "g" key on my keyboard
begged for mercy, and I'm still stuck.

I just can't get my head around processing XSL elements inside an
included document.

Here's what I've got now:

--- main.xsl ---
<xsl:variable name="testvar" select="'hello'" />
<xsl:copy-of select="document('include/header.xsl')//page/header" />
Boring main stuff

--- include/header.xsl ---
<page>
<header>
<h1><xsl:value-of select="$testvar" /></h1>
</header>
</page>

...clearly, that's not going to work because the copy-of deep copy
thing.  The <xsl:value-of...> element is just being included verbatim in
the output.

So here's where I'm stuck.  It seems like it should be a very
straightforward operation, and I've done gymnastics with <xsl:copy> and
<xsl:apply-templates/>, but I just can't seem to make it make sense.


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

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.