Subject: Re: [xsl] Aligning/merging two sequences From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Thu, 30 Sep 2010 19:38:40 +0200 |
Suppose I have two inputs like so, where input1//w is always a subset of input2//w:
<input1> <w n="1">I</w> <w n="2">am</w> <w n="3">a</w> <w n="4">sequence</w> </input1>
<input2> <w>I</w> <w>am</w> <w>a</w> <w>longer</w> <w>longer</w> <w>sequence</w> </input2>
I'd like to get output like so:
<output> <w n="1">I</w> <w n="2">am</w> <w n="3">a</w> <w n="skipped">longer</w> <w n="skipped">longer</w> <w n="4">sequence</w> </output>
I.e., for each input1//w, @n should be copied to the nearest following sibling <w> in input2 that matches .; <w>s in input2 that aren't in input1 should be flagged as "skipped".
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
<xsl:template match="input2"> <output> <xsl:apply-templates select="w[1]"> <xsl:with-param name="skipped" select="0"/> </xsl:apply-templates> </output> </xsl:template>
Martin Honnen http://msmvps.com/blogs/martin_honnen/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Aligning/merging two sequ, Michael Kay | Thread | Re: [xsl] Aligning/merging two sequ, Martin Honnen |
Re: [xsl] Aligning/merging two sequ, Michael Kay | Date | Re: [xsl] Aligning/merging two sequ, Martin Honnen |
Month |