|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: best-technique for selective group and merge?
At 2004-03-02 08:43 -0800, James A. Robinson wrote:
The feature can contain multiple configs, each of which I want to merge across features: ... I want to be able to select /config_datastore/site/* and perform selective grouping (on feature @name) and merging (on the feature/config elements) to return: ... I found I could wrap my head around this problem using variables instead of keys. An example is below giving your desired results. Note how I take advantage of the node-set comparison of a single value to a set of values to get from all configs only those whose feature's name is in a set of names. I hope this helps. .................... Ken
T:\ftemp>type jim.xsl
<?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="/">
<result>
<xsl:variable name="configs"
select="/*/feature[@name=/*/site/has_feature/@name]/config"/>
<xsl:for-each select="$configs">
<xsl:if test="generate-id(.)=
generate-id($configs[@id=current()/@id])">
<config id="{@id}">
<xsl:copy-of select="$configs[@id=current()/@id]/*"/>
</config>
</xsl:if>
</xsl:for-each>
</result>
</xsl:template></xsl:stylesheet>
T:\ftemp>saxon jim.xml jim.xsl
<?xml version="1.0" encoding="utf-8"?>
<result>
<config id="1">
<param id="x">x</param>
<param id="z">z</param>
</config>
<config id="2">
<param id="xx">xx</param>
<param id="zz">zz</param>
</config>
<config id="3">
<param id="xxx">xxx</param>
</config>
</result>
T:\ftemp>rem Done!-- US XSL training: Washington,DC March 15; San Francisco,CA March 22 World-wide on-site corporate, government & user group XML training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








