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... 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()<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(.,' ',' ')"/> </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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] merging readings with childre, James Cummings | Thread | Re: [xsl] merging readings with chi, James Cummings |
RE: [xsl] repetition, Onur Esnaf | Date | Re: [xsl] repetition, Vasu Chakkera |
Month |