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

AW: WG: How to reorder an XML tree?

Subject: AW: WG: How to reorder an XML tree?
From: "Griebel, Peer" <Peer.Griebel@xxxxxxxxx>
Date: Fri, 22 Jun 2001 10:30:50 +0200
reorder xml with xsl
> Von: Paul Prescod [mailto:paulp@xxxxxxxxxxxxxxx]
> 
> Perhaps you could be more explicit in the description of your problem.
> Are you saying that the element with the id "b" should always 
> be moed to
> be a child of the element with the id "d" and everything else should
> remain the same? Should it be the first child, the last 
> child, the only
> child?

Sorry for not being precise.
Yes "b" should always moved to "d", the rest should remain the same. For my
problem it makes no difference for "b" being the first or the last child.

In the meantime I came to a solution. I think it's quite complicated.
Perhaps it should be possible to make it shorter. Especially the definition
of the xsl:key is a problem. I didn't manage to get 
			<xsl:template match="match="id('b')">
work. What am I doing wrong?
Thank you for your help!


<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:output method="xml" indent="no"/>

  <xsl:key name="object" match="*" use="@id"/>

  <xsl:template match="key('object','b')">
  	<xsl:comment> Object b stripped </xsl:comment>
  </xsl:template>

  <xsl:template match="key('object','b')" mode="copy">
	<xsl:comment> Object b copied here </xsl:comment>
    <xsl:copy>
      <xsl:apply-templates
       select="*|@*|comment()|processing-instruction()|text()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="key('object','d')">
    <xsl:copy>
      <xsl:apply-templates 
       select="*|@*|comment()|processing-instruction()|text()"/>
      <xsl:apply-templates 
       select="key('object','b')" mode="copy"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="*|@*|comment()|processing-instruction()|text()">
    <xsl:copy>
      <xsl:apply-templates 
       select="*|@*|comment()|processing-instruction()|text()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>


connection reset by
  Peer

-- 
Dr. Peer Griebel                     Tel: +49(0) 731 / 9 74 95-0
Dipl. Inform.                       Fax: +49(0) 731 / 9 74 95-20
Entire Software AG                 mailto:Peer.Griebel@xxxxxxxxx
Pfarrer-Weiß-Weg 10 - 12
D-89077 Ulm                                 http://www.entire.de

 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.