Project

Profile

Help

Bug #5916 » sheet1.xsl

Martin Honnen, 2023-03-12 13:39

 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="3.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>

<xsl:template name="xsl:initial-template">
<list>
<xsl:merge>
<xsl:merge-source name="master" for-each-source="'input1.xml'" sort-before-merge="yes" select="/list/item">
<xsl:merge-key select="@id" order="ascending"/>
</xsl:merge-source>
<xsl:merge-source name="update" for-each-source="'input2.xml'" sort-before-merge="yes" select="/list/item">
<xsl:merge-key select="@id" order="ascending"/>
</xsl:merge-source>
<xsl:merge-action>
<xsl:choose>
<xsl:when test="empty(current-merge-group('update'))">
<xsl:copy-of select="current-merge-group('master')"/>
<xsl:message>master!</xsl:message>
</xsl:when>
<xsl:when test="empty(current-merge-group('master'))">
<xsl:copy-of select="current-merge-group('update')"/>
<xsl:message>update!</xsl:message>
</xsl:when>
<xsl:otherwise>
<item>
<xsl:merge>
<xsl:merge-source name="descr-master" sort-before-merge="yes" select="current-merge-group('master')/descr">
<xsl:merge-key select="@ref" order="ascending"/>
</xsl:merge-source>
<xsl:merge-source name="descr-update" sort-before-merge="yes" select="current-merge-group('update')/descr">
<xsl:merge-key select="@ref" order="ascending"/>
</xsl:merge-source>
<xsl:merge-action>
<xsl:choose>
<xsl:when test="empty(current-merge-group('descr-update'))">
<xsl:copy-of select="current-merge-group('descr-master')"/>
<xsl:message>descr master!</xsl:message>
</xsl:when>
<xsl:when test="empty(current-merge-group('descr-master'))">
<xsl:copy-of select="current-merge-group('descr-update')"/>
<xsl:message>descr update!</xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="current-merge-group('descr-update')"/>
<xsl:message>present in both: kept update!</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:merge-action>
</xsl:merge>
</item>
</xsl:otherwise>
</xsl:choose>
</xsl:merge-action>
</xsl:merge>
</list>
</xsl:template>
</xsl:stylesheet>
(3-3/4)