Quote:
Originally Posted by samjudson
Strange, I didn't ask IF you had tried, I asked WHAT you had tried...
Could you post examples of what you have tried, and we will try to work out what you are doing wrong (helping you learn).
|
oops, Sorry sam. Here is my example I tried to catch the email and phone number in between paras.
Please check my xslt and xml file below.
----MY XML-----
Code:
<?xml version="1.0" encoding="UTF-8"?>
<companygroup>
<para>This is the example code, this para contains emaid id [email protected] and contact phone is +9199999984521</para>
</companygroup>
----XSLT-----
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no"/>
<xsl:preserve-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="//para">
<!-- [email protected] +9199999984521 -->
<xsl:analyze-string select="." regex="\s+(\w*\.\d*_\d*@\w*.*)\s+(\d{{13}})\s?">
<xsl:matching-substring>
<email><xsl:value-of select="regex-group(1)"/></email>
<phone><xsl:value-of select="regex-group(1)"/></phone>
</xsl:matching-substring>
<xsl:non-matching-substring>
<para test="false"><xsl:value-of select="."/></para>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
</xsl:stylesheet>
My required output should like below
Code:
<?xml version="1.0" encoding="UTF-8"?>
<companygroup>
<para>This is the example code, this para contains emaid id <email>[email protected]</email> and contact phone is <phone>+9199999984521</phone></para>
</companygroup>
Hope I explained my queries...