Мне нужно удалить любое значение, заканчивающееся на _ # (т. Е. _1, _2 и т. Д. c.). XSLT, который я сейчас написал, не самый лучший, так как мне нужно указать точный путь к узлу, который может содержать значения _1 и _2.
Как мне go узнать об обновлении любого узла в XML, который содержит _ #? На данный момент мне нужно создать логи c, чтобы специально искать узлы securityDisplayLabel и displayLabel
XML:
<trades>
<tradeBody>
<bond>
<securityId>
<securityAlternateCodes/>
<securityLabel>179965</securityLabel>
<securityMarket>CAD QC</securityMarket>
<securityDisplayLabel>Q 3.5 120148_1</securityDisplayLabel>
</securityId>
**<displayLabel>Q 3.5 120148_1</displayLabel>**
</bond>
</tradeBody>
</trades>
XSLT:
<xsl:variable name="secDispLab">
<xsl:value-of select="/MxML/trades/trade/tradeBody/*/securityId/securityDisplayLabel" />
</xsl:variable>
<xsl:variable name="stringAfterUnderscore">
<xsl:call-template name="lastUnderscore">
<xsl:with-param name="string" select="$secDispLab" />
<xsl:with-param name="delimiter" select="'_'" />
</xsl:call-template>
</xsl:variable>
<xsl:template match="/">
<xsl:copy>
<securities>
<xsl:apply-templates select="/MxML/trades/trade/tradeBody/*/securityId" />
</securities>
</xsl:copy>
</xsl:template>
<xsl:template match="trades/trade/tradeBody/*/securityId">
<xsl:call-template name="loadData">
<xsl:with-param name="dataClass" select="'security'" />
<xsl:with-param name="queryBy" select="'ID'" />
<xsl:with-param name="dataValue" select="concat(./securityMarket,';',./securityLabel)" />
</xsl:call-template>
</xsl:template>
<xsl:template match="securityId/securityDisplayLabel">
<securityDisplayLabel>
<xsl:choose>
<xsl:when test="number($stringAfterUnderscore)">
<xsl:variable name="numberLength">
<xsl:value-of select="string-length($stringAfterUnderscore)"/>
</xsl:variable>
<xsl:variable name="labelLength">
<xsl:value-of select="string-length($secDispLab)"/>
</xsl:variable>
<xsl:value-of select="substring($secDispLab, 1, ($labelLength - ($numberLength + 1))) "/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@stringAfterUnderscore"/>
</xsl:otherwise>
</xsl:choose>
</securityDisplayLabel>
</xsl:template>
<xsl:template name="lastUnderscore">
<xsl:param name="string" />
<xsl:param name="delimiter" />
<xsl:choose>
<xsl:when test="contains($string, $delimiter)">
<xsl:call-template name="lastUnderscore">
<xsl:with-param name="string" select="substring-after($string, $delimiter)" />
<xsl:with-param name="delimiter" select="$delimiter" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="$string" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>