[xslt] Concatenating blocks (and a bit more) with XSLT
- From: Raymond Wiker <Raymond Wiker fast no>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: [xslt] Concatenating blocks (and a bit more) with XSLT
- Date: Thu, 27 May 2004 13:02:09 +0200
Ilpide, Emmanuel writes:
> Hi!
>
> I get a XML document containing (at some level in the doc):
>
> <XXX action="delete">
>
> <old>
>
> old_data
>
> </old>
>
> </XXX>
>
> <XXX action="add">
>
> new_data
>
> </XXX>
>
>
>
> ... and I'd need to transform this into the following:
>
>
>
> <XXX action="modify">
>
> <old>
>
> old_data
>
> </old>
>
> new_data
>
> </XXX>
>
>
>
> I've been looking into what XSLT can provide but it's not very clear
> whether this is actually do-able or not...
>
> Any idea?
>
> Cheers!
It's doable. It's even quite straightforward. Assuming that
the original XXX tags are wrapped in an outer tag OUTER, you could use
something like the following:
<xsl:template match="OUTER">
<XXX action="modify">
<old>
<xsl:apply-templates select="XXX[ action='delete']/old"/>
</old>
<xsl:apply-templates select="XXX[ action='add']"/>
</XXX>
</xsl:template>
<xsl:template match="XXX">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="XXX/old">
<xsl:value-of select="."/>
</xsl:template>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]