Last active
June 29, 2017 10:46
-
-
Save nishantsingh1/5148401cea921c75b085daa77c7cc2a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
declare variable $xslt := | |
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> | |
<xsl:output method="xml" /> | |
<xsl:template match="@*|node()"> | |
<xsl:copy> | |
<xsl:apply-templates select="@*|node()"/> | |
</xsl:copy> | |
</xsl:template> | |
<!-- reduce the price by half --> | |
<xsl:template match="cd/price"> | |
<price> | |
<xsl:value-of select=". * 0.5"/> | |
</price> | |
</xsl:template> | |
</xsl:stylesheet>; | |
let $sourcexml := | |
<catalog> | |
<cd> | |
<title>Red</title> | |
<artist>The Communards</artist> | |
<company>London</company> | |
<price>7.80</price> | |
<year>1987</year> | |
</cd> | |
<cd> | |
<title>Unchain my heart</title> | |
<artist>Joe Cocker</artist> | |
<company>EMI</company> | |
<price>8.20</price> | |
<year>1987</year> | |
</cd> | |
</catalog> | |
return | |
xdmp:xslt-eval($xslt, $sourcexml) | |
(: OUTPUT: | |
<?xml version="1.0" encoding="UTF-8"?> | |
<catalog> | |
<cd> | |
<title>Red</title> | |
<artist>The Communards</artist> | |
<company>London</company> | |
<price xmlns:fo="http://www.w3.org/1999/XSL/Format">3.9</price> | |
<year>1987</year> | |
</cd> | |
<cd> | |
<title>Unchain my heart</title> | |
<artist>Joe Cocker</artist> | |
<company>EMI</company> | |
<price xmlns:fo="http://www.w3.org/1999/XSL/Format">4.1</price> | |
<year>1987</year> | |
</cd> | |
</catalog> :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment