This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: questions.
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] questions.
- From: "Christopher R. Maden" <crism at maden dot org>
- Date: Fri, 28 Sep 2001 02:31:40 -0700
- Reply-To: xsl-list at lists dot mulberrytech dot com
At 02:06 28-09-2001, Mihir D. Gore wrote:
>I am trying to write a diff-patch tool for xml data in which i will be doing
>the patching using xslt. I have some questions regarding this.
>
>consider the two xml files as
>
> a a
> | / | \
> b m b n
> | / |
> c z c
A minor tip: Many people still read e-mail in a non-proportional
font. Those that use proportional fonts may not have the same proportions
as you do; try making ASCII art with a non-proportional font chosen.
>The edit script that i will be generating will be
>
>1. Add subtree at m as first child of a
>2. Add node n as the third child of n
>
>How i can i achieve this in xslt ? (I know that xslt will generate a
>completely new file. )
Another way to think of these instructions, that may be of more help, is:
1. Copy a. Within a:
2. Create m.
3. Copy the first child of a.
4. Create n.
5. Copy the 2nd and following children of a.
Translating that into XSLT (assuming a default template that copies nodes):
<xsl:template match="a">
<xsl:copy>
<xsl:copy-of select="@*"/>
<m/>
<xsl:apply-templates select="*[1]"/>
<n/>
<xsl:apply-templates select="*[position() >= 2]"/>
</xsl:copy>
</xsl:template>
Note that this neglects any text nodes within a.
HTH,
Chris
--
Christopher R. Maden, Principal Consultant, HMM Consulting Int'l, Inc.
DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
<URL: http://www.hmmci.com/ > <URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4 5DFC AC52 F825 AFEC 58DA
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list