0

文字列に英数字または「.」のみが含まれているかどうかを確認したい

これは私のコードです。ただし、$value が $allowed-characters と正確に一致する場合にのみ機能します。xslt 1.0 を使用しています。

<xsl:template name="GetLastSegment">
<xsl:param name="value" />
<xsl:param name="separator" select="'.'" />
<xsl:variable name="allowed-characters">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.</xsl:variable>
<xsl:choose>
  <xsl:when test="contains($value, $allowed-characters)">
    <xsl:call-template name="GetLastSegment">
      <xsl:with-param name="value" select="substring-after($value, $separator)" />
      <xsl:with-param name="separator" select="$separator" />
    </xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="$value" />
  </xsl:otherwise>
</xsl:choose>
</xsl:template>
4

1 に答える 1