Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
<?xml version="1.0" encoding="UTF-8"?> <!-- Identity transform with targeted override: Copy all nodes unchanged except <price> — multiply each price by 1.1 (10% price increase). --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" encoding="UTF-8"/> <!-- IDENTITY TRANSFORM: copy everything --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- Override: modify <price> elements only --> <xsl:template match="price"> <price> <xsl:copy-of select="@*"/> <xsl:value-of select="format-number(. * 1.1, '0.00')"/> </price> </xsl:template> <!-- Override: add a generated attribute to each <book> --> <xsl:template match="book"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:attribute name="priceIncreased">true</xsl:attribute> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> <!-- MODE EXAMPLE: generate a plain-text index in 'index' mode --> <xsl:template match="book" mode="index"> <xsl:value-of select="position()"/> <xsl:text>. </xsl:text> <xsl:value-of select="title"/> <xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet>
Result
Open