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

Re: Template for node-set parents

Subject: Re: Template for node-set parents
From: Darren Oh <darren@xxxxxxx>
Date: Mon, 5 Nov 2012 11:07:33 -0500
 Re: Template for node-set parents
Thanks for all the suggestions. I succeeded by using an EXSL extension
function. I am writing code for PHP, so I have to use what PHP supports. Here
is my toy code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"
version="1.0">
 <xsl:output method="xml"/>
 <xsl:strip-space elements="*"/>
 <xsl:variable name="sorted">
   <xsl:for-each select="/response/data/result">
     <xsl:sort select="COMPANY_SORT" data-type="text" order="descending"/>
     <xsl:copy-of select="."/>
   </xsl:for-each>
 </xsl:variable>
 <xsl:template match="*">
   <xsl:copy>
     <xsl:apply-templates/>
   </xsl:copy>
 </xsl:template>
 <xsl:template match="/response/data/result">
   <xsl:variable name="position" select="position()"/>
   <xsl:copy-of select="exsl:node-set($sorted)/*[$position]"/>
 </xsl:template>
</xsl:stylesheet>

On Oct 19, 2012, at 1:03 PM, Darren Oh wrote:

> I am trying to generate a stylesheet that copies an XML source document. The
only change should be that nodes selected by an XPath expression are sorted. I
want this to work for any XML source document. The only information available
to generate the stylesheet is the XPath expression and the sort criteria. I
think this requires creating a template for the parents of the nodes selected
by the XPath expression. How can I do this?

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.