Code: Select all
<price>2411</price>
Code: Select all
<price>2652</price>
Post by levvusss » Sun Apr 04, 2021 3:25 pm
Code: Select all
<price>2411</price>
Code: Select all
<price>2652</price>
Post by Radu » Mon Apr 05, 2021 9:28 am
Code: Select all
<root>
<price>2411</price>
</root>
Code: Select all
<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="price">
<xsl:variable name="priceNumber" select="xs:integer(text())"/>
<xsl:value-of select="$priceNumber + ($priceNumber * 10) div 100"/>
</xsl:template>
</xsl:stylesheet>
Post by levvusss » Mon Apr 05, 2021 9:24 pm
Thank youRadu wrote: ↑Mon Apr 05, 2021 9:28 amHi,
If you have an XML document like this:
you can create an XSLT stylesheet which adds 10% to all price elements, it would look something like this:Code: Select all
<root> <price>2411</price> </root>
More about processing XML with XSLT:Code: Select all
<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="price"> <xsl:variable name="priceNumber" select="xs:integer(text())"/> <xsl:value-of select="$priceNumber + ($priceNumber * 10) div 100"/> </xsl:template> </xsl:stylesheet>
https://www.oxygenxml.com/doc/versions/ ... -xslt.html
Regards,
Radu
Return to “General XML Questions”
This website was created & generated with <oXygen/>®XML Editor