Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] Move (ascend) an element

From: Pieter Reint Siegers Kort <pieter.siegers@----------->
To:
Date: 7/1/2004 4:46:00 AM
Hi Naomi,

Using an excellent example of G. Ken Holman, posted by him a couple of days
ago, I modified it to the following:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output indent="yes"/>

<xsl:template match="/figure">
   <xsl:copy>
     <xsl:copy-of select="//indexterm"/>
     <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
</xsl:template>

<xsl:template match="indexterm"/>

<xsl:template match="@*|node()">
   <xsl:copy>
     <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
</xsl:template>

</xsl:stylesheet>

This produces (with your XML as input, I only added an extra element
<secterm>):

<?xml version="1.0" encoding="UTF-16"?>
<figure>
<indexterm>
<primary>special figure</primary>
<secterm>xxx</secterm>
</indexterm>
<title>
	This is the figure caption text
	</title>
</figure>

Cheers,
<prs/>

-----Original Message-----
From: Naomi Gronson [mailto:naomi_gronson@xxxxxxxxx] 
Sent: Thursday, July 01, 2004 9:23 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Move (ascend) an element

I'm trying to move the <indexterm> up in the tree,
from:

<figure>
	<title>
		<indexterm>
		<primary>special figure</primary>
		</indexterm>
	This is the figure caption text
	</title>
</figure>

to

<figure>
	<indexterm>
	<primary>special figure</primary>
	</indexterm>
	<title>This is the figure caption text</title> </figure>

I have code that does it part way, but won't handle any <secondary> elements
that might also be contained within the <indexterm>:

<xsl:template
match="figure[descendant::title[descendant::indexterm]]">
<xsl:copy><indexterm><primary>
<xsl:value-of
select="descendant::indexterm"/></primary></indexterm>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<!-- remove old indexterm -->
<xsl:template
match="indexterm[ancestor::title[ancestor::figure]]">
</xsl:template>

Is there some kind of value of select that will grab the <indexterm> and any
elements under it, instead of me recreating them in my xsl?  Any ideas.
Thanks!

Naomi




		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent