Project

Profile

Help

Mixed up order in temporary node sequences as function re... ยป Saxon_issue_order_of_temp_tree.xslt

Complete stylesheet to reproduce it - Nico Kutscherauer, 2017-07-27 12:34

 
<?xml version="1.0" encoding="UTF-8"?>
<!--
***************************************************
**
** Version: 0.1 ##
** Iteration:
** Date: 26.07.2017 ##
** Author: kutscherauer@data2type.de ##
**
***************************************************
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:d2t="http://data2type.de/" exclude-result-prefixes="xs saxon d2t" version="2.0">


<xsl:output indent="yes"/>


<xsl:template match="/">
<!--
Call a function, which should return w:r elements
-->
<xsl:variable name="wrs" select="d2t:prepareWRs()"/>
<root>
<copy-wr>
<!--
Copy the w:r elements
-->
<xsl:copy-of select="$wrs"/>
</copy-wr>
<copy-wt>
<!--
Copy only the w:t elements inside of <w:r>
-->
<xsl:copy-of select="$wrs/w:t"/>
</copy-wt>
</root>
</xsl:template>

<xsl:function name="d2t:prepareWRs" as="element(w:r)*">

<!-- doing something,
result is:
-->
<xsl:variable name="tempWr">
<w:r>
<w:t d2t:marker="true">###</w:t>
</w:r>
<w:r>
<w:t>text</w:t>
</w:r>
<w:r>
<w:t d2t:marker="true">###</w:t>
</w:r>
</xsl:variable>
<!--
Loop over temporary w:r's
-->
<xsl:for-each select="$tempWr/w:r">
<!--
Make a condition... I think it happens here:
-->
<xsl:choose>
<xsl:when test="not(w:t/@d2t:marker = 'true')">
<xsl:copy>
<w:t>
<xsl:value-of select="."/>
</w:t>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>

</xsl:function>

</xsl:stylesheet>
    (1-1/1)