Input:-
<?xml version="1.0" encoding="UTF-8"?>
<number-format>
<number>1</number>
<number>2</number>
<number>3</number>
<number>4</number>
<chapter-no>1</chapter-no>
<chapter-no>23</chapter-no>
<chapter-no>3</chapter-no>
<chap-no>1</chap-no>
<chap-no>23</chap-no>
<chap-no>3</chap-no>
</number-format>
Output:-
<number-format>
<number>1st</number>
<number>2nd</number>
<number>3rd</number>
<number>4th</number>
<chapter-no>First</chapter-no>
<chapter-no>Twenty-Third</chapter-no>
<chapter-no>Third</chapter-no>
<chap-no>One</chap-no>
<chap-no>Twenty Three</chap-no>
<chap-no>Three</chap-no>
</number-format>
XSLT CODE:-
<?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:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="number-format">
<xsl:element name="number-format">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="number">
<xsl:copy>
<!--TO RETURN AS <number>1st</number>-->
<xsl:number value="." format="1" ordinal="yes"/>
</xsl:copy>
</xsl:template>
<xsl:template match="chapter-no">
<xsl:element name="chapter-no">
<!--TO RETURN AS <chapter-no>First</chapter-no>-->
<xsl:number value="." format="Ww" ordinal="yes"/>
</xsl:element>
</xsl:template>
<xsl:template match="chap-no">
<xsl:element name="chap-no">
<!--TO RETURN AS<chap-no>One</chap-no>-->
<xsl:number value="." format="Ww"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<number-format>
<number>1</number>
<number>2</number>
<number>3</number>
<number>4</number>
<chapter-no>1</chapter-no>
<chapter-no>23</chapter-no>
<chapter-no>3</chapter-no>
<chap-no>1</chap-no>
<chap-no>23</chap-no>
<chap-no>3</chap-no>
</number-format>
Output:-
<number-format>
<number>1st</number>
<number>2nd</number>
<number>3rd</number>
<number>4th</number>
<chapter-no>First</chapter-no>
<chapter-no>Twenty-Third</chapter-no>
<chapter-no>Third</chapter-no>
<chap-no>One</chap-no>
<chap-no>Twenty Three</chap-no>
<chap-no>Three</chap-no>
</number-format>
XSLT CODE:-
<?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:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="number-format">
<xsl:element name="number-format">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="number">
<xsl:copy>
<!--TO RETURN AS <number>1st</number>-->
<xsl:number value="." format="1" ordinal="yes"/>
</xsl:copy>
</xsl:template>
<xsl:template match="chapter-no">
<xsl:element name="chapter-no">
<!--TO RETURN AS <chapter-no>First</chapter-no>-->
<xsl:number value="." format="Ww" ordinal="yes"/>
</xsl:element>
</xsl:template>
<xsl:template match="chap-no">
<xsl:element name="chap-no">
<!--TO RETURN AS<chap-no>One</chap-no>-->
<xsl:number value="." format="Ww"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
No comments:
Post a Comment