<html>
<head>
<title>substring-after() ֐</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
<tr>
<td valign="top" class="NAME">substring-after() ֐</td>
<td valign="top" class="COMPATIBILITY">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
</tr>
<tr>
<td valign="top" colspan="2" class="description">
ŏ̃p[^ 2 Ԗڂ̃p[^ŏɏoɁAŏ̃p[^̕Ԃ܂Bŏ̃p[^ 2 Ԗڂ̃p[^oȂꍇA<span class="LITERAL">substring-after()</span> ֐͋̕Ԃ܂B </td></tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE"></td>
</tr>
<tr>
<td colspan="2" class="description">
<p>2 ̕Bŏ͌̕镶ŁA2 Ԗڂ͍̕ŏ̕Ō镶łB </p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">o</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>2 Ԗڂ̃p[^ŏɏoɏoAŏ̃p[^̕Bŏ̃p[^ 2 Ԗڂ̃p[^oȂꍇÅ֐͋̕Ԃ܂B </p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">`</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>XPath 4.2 ߁u֐v </p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE"></td>
</tr>
<tr>
<td colspan="2" class="description">
<p>̃X^CV[gł́A<span class="LITERAL">replace-substring</span> ƂÕev[ggp܂B܂A3 ̃p[^ (̕A̕Ō镔Aь̕őΏۂƂȂ镔u镔)  <span class="LITERAL">replace-substring</span> ev[gɓn܂B<span class="LITERAL">replace-substring</span> ev[ǵA<span class="LITERAL">contains()</span>A<span class="LITERAL">substring-after()</span>A <span class="LITERAL">substring-before()</span> ֐gĎgp܂B </p>

<!--<?troff .Nd 15?>-->
<p>TvX^CV[gɎ܂B̃X^CV[ǵA<span class="LITERAL">World</span> ׂĕ "Mundo" ɒu܂B</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;

  &lt;xsl:output method="text"/&gt;

  &lt;xsl:template match="/"&gt;
    &lt;xsl:variable name="test"&gt;
      &lt;xsl:call-template name="replace-substring"&gt;
        &lt;xsl:with-param name="original"&gt;Hello World!&lt;/xsl:with-param&gt;
        &lt;xsl:with-param name="substring"&gt;World&lt;/xsl:with-param&gt;
        &lt;xsl:with-param name="replacement"&gt;Mundo&lt;/xsl:with-param&gt;
      &lt;/xsl:call-template&gt;
    &lt;/xsl:variable&gt;
    &lt;xsl:value-of select="$test"/&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template name="replace-substring"&gt;
    &lt;xsl:param name="original"/&gt;
    &lt;xsl:param name="substring"/&gt;
    &lt;xsl:param name="replacement" select="''"/&gt;
    &lt;xsl:variable name="first"&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test="contains($original, $substring)"&gt;
          &lt;xsl:value-of select="substring-before($original, $substring)"/&gt;
        &lt;/xsl:when&gt;
        &lt;xsl:otherwise&gt;
          &lt;xsl:value-of select="$original"/&gt;
        &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
    &lt;/xsl:variable&gt;
<!--<?troff .Nd 10?>-->
    &lt;xsl:variable name="middle"&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test="contains($original, $substring)"&gt;
          &lt;xsl:value-of select="$replacement"/&gt;
        &lt;/xsl:when&gt;
        &lt;xsl:otherwise&gt;
          &lt;xsl:text&gt;&lt;/xsl:text&gt;
        &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
    &lt;/xsl:variable&gt;
    &lt;xsl:variable name="last"&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test="contains($original, $substring)"&gt;
          &lt;xsl:choose&gt;
            &lt;xsl:when test="contains(substring-after($original, $substring), 
                             $substring)"&gt;
<!--<?troff .Nd 10?>-->
              &lt;xsl:call-template name="replace-substring"&gt;
                &lt;xsl:with-param name="original"&gt;
                  &lt;xsl:value-of 
                    select="substring-after($original, $substring)"/&gt;
                &lt;/xsl:with-param&gt;
                &lt;xsl:with-param name="substring"&gt;
                  &lt;xsl:value-of select="$substring"/&gt;
                &lt;/xsl:with-param&gt;
                &lt;xsl:with-param name="replacement"&gt;
                  &lt;xsl:value-of select="$replacement"/&gt;
                &lt;/xsl:with-param&gt;
              &lt;/xsl:call-template&gt;
            &lt;/xsl:when&gt;
            &lt;xsl:otherwise&gt;
              &lt;xsl:value-of select="substring-after($original, $substring)"/&gt;
            &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
        &lt;/xsl:when&gt;
        &lt;xsl:otherwise&gt;
          &lt;xsl:text&gt;&lt;/xsl:text&gt;
        &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
    &lt;/xsl:variable&gt;
    &lt;xsl:value-of select="concat($first, $middle, $last)"/&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;</pre></span>
<p>̃X^CV[ǵA͂ƂĎgp XML hLgƂ͖֌WɁǍʂ܂B</p>
<span class="PROGRAMLISTING"><pre>
Hello Mundo!
</pre></span>
</td>
</tr>
</table>
</div>
</body>
</html>
