xsl-list
[Top] [All Lists]

[xsl] Re: Template for node-set parents

2012-11-05 10:08:24
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?

--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] Re: Template for node-set parents, Darren Oh <=