Home > Software design >  How could I remove * infront of digits in xsl?
How could I remove * infront of digits in xsl?

Time:12-27

I am working with xml and xsl to format the file and couldn't figure out how I could remove asterisk infront of the SSNs. Asterisks are there sometimes and sometimes its just digits. I want to make sure there is no asterisks in SSNs. How do I remove asterisk?

Example XML

<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="XSLAsterisk.xsl"?>
<information>
    <secondBranch>
        <xsl:if test="Check = N">
        <SSN>771717771</SSN>
    </secondBranch>
    <secondBranch>
        <xsl:if test="Check = Y">
        <SSN>*9111</SSN>
    </secondBranch>
    <secondBranch>
        <xsl:if test="Check = N">
        </SSN>
    </secondBranch>
</information>

Example XSL

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
    <xsl:output method="text"/>
    <xsl:template match="/">
        <table>
            <title>
            </title>
            <body>
                <tr>
                    <th>
                        SSN
                    </th>
                </tr>
                <td>
                    <xsl:for-each select="/information/secondBranch">
                        <tr>
                            <xsl:value-of select="SSN"/>
                        </tr>
                    </xsl:for-each>
                </td>
            </body>
        </table>
    </xsl:template>
</xsl:stylesheet>

CodePudding user response:

I want to make sure there is no asterisks in SSNs.

Try:

<xsl:value-of select="translate(SSN, '*', '')"/>
  • Related