Re: [xsl] merging readings with children

Subject: Re: [xsl] merging readings with children
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 28 May 2003 15:11:17 +0100
> 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...


<xsl:stylesheet xmlns:xsl=""; version="1.0"
xmlns:saxon=""; extension-element-prefixes="saxon" >
<xsl:output indent="yes"/>
<xsl:variable name="wits">

<xsl:template match="foo">

<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:copy-of select="$x"/>

<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:attribute><xsl:copy-of select="node()"/></body>

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

<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:template mode="wit" match="note">
<xsl:copy-of select="."/>


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:

 XSL-List info and archive:

Current Thread