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

Re: merging readings with children

Subject: Re: merging readings with children
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 28 May 2003 15:11:17 +0100
readings for kids
> I'm assuming this is because of
> the programatic way the p template match uses value-of,

yes and also normalize-space.
By throwing away all the interior markup  and using normalize-space
you get a well defined meaning for when two elements are "equal" and
also get a respectable looking output.

If anyone from the WG is reading this they might like to explain how
(if:-) the xpath2 deep-equal function would (or wouldn't) help here.

the following modifies things so that the <note> element geths through
to the output, but whether its notion of equality agrees with your own
I'm not sure...

David

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:saxon="http://icl.com/saxon" extension-element-prefixes="saxon" >
<xsl:output indent="yes"/>
<xsl:variable name="wits">
<x>A</x><x>B</x><x>C</x><x>D</x><x>E</x><x>F</x>
</xsl:variable>

<xsl:template match="foo">
<foo><xsl:apply-templates/></foo>
</xsl:template>

<xsl:key name="k" match="body" use="."/>

<xsl:template match="p"><p id="{@id}">
<xsl:variable name="p" select="."/>
<xsl:variable name="one">
 <xsl:for-each select="saxon:node-set($wits)/*">
 <body wit="{.}">
  <xsl:variable name="x">
   <xsl:apply-templates mode="wit" select="$p/node()">
   <xsl:with-param name="wit" select="."/>
   </xsl:apply-templates>
  </xsl:variable>
 <xsl:copy-of select="$x"/>
 </body>
 </xsl:for-each>
</xsl:variable>

<xsl:for-each select="saxon:node-set($one)/*">
<xsl:if test="generate-id(.)=generate-id(key('k',.))">
<body><xsl:attribute name="wit">
   <xsl:for-each select="key('k',.)">
   <xsl:value-of select="@wit"/>
   <xsl:if test="position()&lt;last()"><xsl:text> </xsl:text></xsl:if>
   </xsl:for-each>
   </xsl:attribute><xsl:copy-of select="node()"/></body>
   </xsl:if>
</xsl:for-each>
</p>
</xsl:template>

<xsl:template mode="wit" match="text()">
<xsl:value-of select="translate(.,'&#10;',' ')"/>
</xsl:template>

<xsl:template mode="wit" match="*">
 <xsl:param name="wit"/>
 <xsl:if test="not(@wit) or (@wit and contains(@wit,$wit))">
  <xsl:apply-templates mode="wit">
    <xsl:with-param name="wit" select="$wit"/>
  </xsl:apply-templates>
 </xsl:if>
 </xsl:template>


<xsl:template mode="wit" match="note">
<xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.