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

Re: Perpetuating xsl instructions

Subject: Re: Perpetuating xsl instructions
From: Alan Gardner <scipiomedia@xxxxxxxxxxx>
Date: Mon, 12 May 2003 17:33:17 -0600
xsl copy replica
Lars - man you nailed it and didn't even know the whole purpose of the
project!!! In your honor we've named the stylesheet lars.xsl!

Thanks for the post, the solution is very elegant. Thanks again.

Alan


On 5/12/03 4:14 PM, "Lars Huttar" <lars_huttar@xxxxxxx> wrote:
> Do you really want your appended xml documents to go into the
> template that matches "*"??
> In other words do you want the result to be a stylesheet that
> will output all the so-far-appended XML documents once for every
> element of the new source document?
> 
> Maybe you really want the XML documents to be inserted somewhere
> else, perhaps after the end of the last template.
> (As your other email suggests.)
> 
> Maybe it would help if you explain your purpose... what are you trying
> to achieve by accumulating XML documents in your stylesheet?  What do you
> want to do with the stylesheet after you've run several xml documents
> through it?
> 
> Here is a stylesheet that does most of what (I think) you want:
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   xmlns:my="http://www.my-dummy-namespace.org/lars/dummy" >
> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
> 
> <!-- self-replicating stylesheet:
>   When run on a source file, this stylesheet should produce itself, with the
>   contents of the source file inserted into it at a certain point. -->
> 
> <xsl:template match="/">
>   <xsl:apply-templates select="document('')/*">
>     <xsl:with-param name="source-doc" select="/" />
>   </xsl:apply-templates>
> </xsl:template>
> 
> <xsl:template match="node()|@*">
>   <xsl:copy>
>     <xsl:apply-templates select="@*"/>
>     <xsl:apply-templates/>
>   </xsl:copy>
> </xsl:template>
> 
> <xsl:template match="xsl:stylesheet">
>   <xsl:param name="source-doc" />
>   <xsl:copy>
>     <xsl:apply-templates select="@*"/>
>     <xsl:apply-templates/>
>     <my:doc>
>       <xsl:copy-of select="$source-doc" />
>     </my:doc>
>   </xsl:copy>
> </xsl:template>
> 
> <!-- XML docs get inserted here -->
> 
> </xsl:stylesheet>
> 
> 
> It's not a perfect replica -- you get a lot of extra whitespace
> with each transformation.
> 
> The reason the XML docs get put into a <my:doc> element is
> that if you put a namespaceless top-level element into a stylesheet,
> you get an error.
> 
> Lars
> 
> 
> 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

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.