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

Re: <xsl:insert> - Further Description - Simpler Example

  • From: tpassin@h...
  • To: "Xml-Dev@Xml. Org" <xml-dev@x...>
  • Date: Wed, 26 Jul 2000 00:16:46 -0400

xsl insert file
Jim,

Here is a way to put a (well-formed) part of an xml file into an output file
wherever you want.  I think this will do what you want.  It's essentially an
"xsl:insert" substitute.

The example has a "content.xml" file that contains some html markup.  There
is a configuration file that contains information about the header, footer,
and content.  The stylesheet inserts the various bits of information at
different points within the output file, including echoing the "content"
file into the output.

These examples are simple, but I think they do everything you want.  The
only place you have to make changes for any specific set of pages is in the
config file.  This is what you want to do, you shouldn't be making changes
to your stylesheet(s) if you don't absolutely have to.

Below are given the content file, the config file, the stylesheet, and the
transformed result.
I used XT.  The command line is:

xt content.xml main.xsl

Cheers,

Tom Passin


//////content.xml //////
<content><h1 class='c1'>Content of document 1</h1>
This is the content of document 1
</content>
///////////////////////

//////config.xml ///////
<config>
 <header><bgcolor>red</bgcolor><title>Red Header</title></header>
 <content>content.xml</content>
 <footer><bgcolor>yellow</bgcolor></footer>
</config>
///////////////////////

///////// main.xsl ////////
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:variable name="config-file" select="document('config.xml')"/>

 <xsl:template match="/">
  Header color: <xsl:value-of select="$config-file//header/bgcolor"/>.
  Header text: <xsl:value-of select="$config-file//header/title"/>.

======= Content: ==========

<xsl:copy-of select="/content/node()"/>
======= End of content =========

  Footer color: <xsl:value-of select="$config-file//footer/bgcolor"/>.
 </xsl:template>
</xsl:stylesheet>
///////////////////////////

////////// OUTPUT /////////
D:>xt content.xml main.xsl

                Header color: red.
                Header text: Red Header.

======= Content: ==========

<h1 class="c1">Content of document 1</h1>
This is the content of document 1

======= End of content =========

                Footer color: yellow.
//////////////////////////////





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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.