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

RE: XSL and DOM

Subject: RE: XSL and DOM
From: "Jonathan M. Sprinkle" <Jonathan.Sprinkle@xxxxxxxxxxxxxx>
Date: Tue, 10 Jun 2003 15:10:38 -0500
apply xsl to dom
My apologies if something similar was posted, and I missed it.  :)

> >the changes should be done on the same tree instead of generating a
> >new
> tree
> 
> That's not how XSLT is defined to work.
> 
> I'm afraid the right answer would be to use an XPath engine to
> implement your own transform-in-place language.

Paramdeep,

I too am working on something like this (you can look for the hotly
debated and controversial "template match : node-set ..." thread).

I found that it is acceptable to generate a new file, but in addition to
the commands that manipulate the portion of your source tree, that you
copy in total the attributes and nodes that are not being modified.  For
example, 

        <xsl:template match="/">
                <xsl:apply-templates/>
        </xsl:template>
        <xsl:template match="@*|node()">
	<copy>
		<xsl:apply-templates select="@* | node()"/>
	</copy>
        </xsl:template>
        <xsl:template match="(the node you want to modify)">
	<!-- do modifications, then apply templates to all children -->
                <xsl:apply-templates/> 
        </xsl:template>

The only danger with this is that you,
 - must make modifications to attributes before you do anything to the
children (at least, this is how it seems to work for me)
 - must ensure that if you match a particular node to modify that any
conditions for its context are contained in the match, or that there is
a sort of "else" statement that will copy everything if these additional
contexts fail.
 - need to take care that you dn't modify the node AND copy it,
resulting in some very strange trees. :)

I am afraid that I can't help you with specifics, as these are going to
be related directly to your application.  However, I have found that
this is a "virtual" self-modification, and i have even succeeded at
keeping the filename the same before and after translation through
manipulation in my calling program (I am linking in Xalan for my CPP
files), so it is hidden from the caller.

Good luck,
Jonathan


 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.