Here is a sample XSLT 2.0 stylesheet:
Code:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="body">
<POSMESSAGE>
<xsl:apply-templates/>
</POSMESSAGE>
</xsl:template>
<xsl:template match="p">
<TextMSG>
<xsl:copy-of select="@align"/>
<xsl:apply-templates/>
</TextMSG>
</xsl:template>
<xsl:template match="text()[normalize-space(.) = 'Sadd']">
<emph><xsl:value-of select="upper-case(.)"/></emph>
</xsl:template>
</xsl:stylesheet>
When applied to the input
Code:
<html>
<head>
</head>
<body>
<p>
This coupon is for a good guy whose first name is :
</p>
<p>
</p>
<p align="center">
Sadd
</p>
<p align="center">
</p>
<p align="right">
<b>also</b> whose <var>full_name</var> is Sadd Hossain
</p>
<p align="left">
</p>
<p align="left">
He is a <font size="3">software </font><font size="4">engineer for</font><font size="5">
S&H</font>
</p>
</body>
</html>
Saxon 9 creates the following output:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<POSMESSAGE>
<TextMSG>
This coupon is for a good guy whose first name is :
</TextMSG>
<TextMSG>
</TextMSG>
<TextMSG align="center"><emph>
SADD
</emph></TextMSG>
<TextMSG align="center">
</TextMSG>
<TextMSG align="right">
also whose full_name is Sadd Hossain
</TextMSG>
<TextMSG align="left">
</TextMSG>
<TextMSG align="left">
He is a software engineer for
S&H
</TextMSG>
</POSMESSAGE>