我正在使用 Xsl,我試圖在 SSN 中添加 * 但不確定如何去做。我做了一些研究,concat() 可能是我的答案,但不確定如何在其中添加 *?有些 SSN 有 4 個字符長,有些有 9 個字符,有些只是空的。
示例 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>
示例 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>
我想讓它們看起來像這樣
SSN
771717771
*****9991
*********
我得到的是這個

uj5u.com熱心網友回復:
代替 :
<tr>
<xsl:value-of select="SSN"/>
</tr>
嘗試:
<tr>
<xsl:value-of select="substring('*********', string-length(SSN) 1)"/>
<xsl:value-of select="SSN"/>
</tr>
添加:
要僅輸出SSN值為 的Check值"Y",請更改:
<xsl:for-each select="/information/secondBranch">
至:
<xsl:for-each select="/information/secondBranch[Check='Y']">
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/536423.html
標籤:XMLxslt
