I am working with Xsl and I was trying to add * in SSNs and wasn't sure how to go about it. I have done some research and concat() might be my answer but not sure how I could add *'s in there? Some SSNs are 4 characters long and some are 9 characters and some are just empty.
Example XML
<information>
<secondBranch>
<xsl:if test="Check = N">
<SSN>771717771</SSN>
</secondBranch>
<secondBranch>
<xsl:if test="Check = Y">
<SSN>9991</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>
I am trying to make them look like this
SSN
771717771
*****9991
*********
What I am getting is this
CodePudding user response:
Instead of :
<tr>
<xsl:value-of select="SSN"/>
</tr>
try:
<tr>
<xsl:value-of select="substring('*********', string-length(SSN) 1)"/>
<xsl:value-of select="SSN"/>
</tr>
Added:
To output only SSN
values with Check
values of "Y"
, change:
<xsl:for-each select="/information/secondBranch">
to:
<xsl:for-each select="/information/secondBranch[Check='Y']">