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

Re: seamless processing of multiple XML fragments

Subject: Re: seamless processing of multiple XML fragments
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Mon, 03 Sep 2001 20:22:27 +0100
xslt xml fragments
What a sweet little problem - it really shows off how well the features
of XSLT work together.

Here's what you can do - wrote a transform (below) with just two
templates. Make one of them a pure pass-through template for everything
else, and the other a template for include elements. Them make the
include template pass through the contents of the referenced file.

Results below - HTH

Francis.

C:\xml>type t.xslt t.xml t2.xml t3.xml

t.xslt


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="node() | @*">
                <xsl:copy>
                        <xsl:apply-templates select="node() | @*" />
                </xsl:copy>
        </xsl:template>
        <xsl:template match="include">
                <xsl:apply-templates select="document(@file)" />
        </xsl:template>
</xsl:stylesheet>

t.xml


<root>
        <a>
                <b>B</b>
                <include file="t2.xml"/>
        </a>
        <g>
                <h>H</h>
                <i>I</i>
        </g>
</root>

t2.xml


<c>
        <d>D</d>
        <e>E</e>
        <include file="t3.xml"/>
</c>

t3.xml


<f>F</f>

C:\xml>

C:\xml>saxon t.xml t.xslt
<?xml version="1.0" encoding="utf-8"?><root>
        <a>
                <b>B</b>
                <c>
        <d>D</d>
        <e>E</e>
        <f>F</f>
</c>
        </a>
        <g>
                <h>H</h>
                <i>I</i>
        </g>
</root>
C:\xml>

 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.