Re: How to add attribute with value
Posted: Thu Apr 23, 2020 12:48 pm
Hi,
Maybe you can do that with an XSLT stylesheet like this:
Regards,
Radu
Maybe you can do that with an XSLT stylesheet like this:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*:text[not(@end)]">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:if test="preceding-sibling::*:text[@start]">
<xsl:attribute name="end">
<xsl:value-of select="xs:integer((preceding-sibling::*:text[@start])[last()]/@start) + 1"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Radu