<html>
<head>
<title>substring() ֐</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() ֐</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">
w肳ꂽ̈ꕔԂ܂B2 Ԗڂ 3 Ԗڂ̃p[^́AԂ镶̕w肵܂B2 Ԗڂ̃p[^́A̍ŏ̈̕ʒuw肵Aȗ\ 3 Ԗڂ̃p[^́AԂw肵܂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><span class="LITERAL">substring()</span> ֐́AƁA1 ܂ 2 ̐lp[^ƂĎ󂯎܂B́̕A̒oƂȂ镶łB2 Ԗڂ̃p[^́AԂ镔̊JnʒuƂĎgpAȗ\ 3 Ԗڂ̃p[^ł́AԂp[^w肵܂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><span class="LITERAL">substring()</span> ֐́A2 ̃p[^ (ƊJnʒu) ɂAJnʒun܂镶ׂ̂Ă̕Ԃ܂BXPath ̍ŏ͈̕ʒu 0 ł͂ȂAʒu 1 ɂ܂B</p>
<p>3 ̃p[^ (AJnʒuAђ) ɂA<span class="LITERAL">substring()</span> ֐́AJnʒuʒu傫ƁAJnʒuƒ𑫂̂ʒûׂĂ̕Ԃ܂B</p>
<p>ʏA<span class="LITERAL">substring()</span> ֐̃p[^͐lłA蕡GȎłꍇ܂BOIȃP[XɂẮA̗QƂĂ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> XML hLggpāA<span class="LITERAL">substring()</span> ֐̓܂B</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;test&gt;
  &lt;p&gt;This is a test XML document used by several 
    of our sample stylesheets.&lt;/p&gt;
  &lt;question&gt;
    &lt;text&gt;When completed, the Eiffel Tower was the 
    tallest building in the world.&lt;/text&gt;
    &lt;true&gt;You're correct!  The Eiffel Tower was the 
    world's tallest building until 1930.&lt;/true&gt;
<!--<?troff .Nd 10?>-->
    &lt;false&gt;No, the Eiffel Tower was the world's 
    tallest building for over 30 years.&lt;/false&gt;
  &lt;/question&gt;
  &lt;question&gt;
    &lt;text&gt;New York's Empire State Building knocked the 
    Eiffel Tower from its pedestal.&lt;/text&gt;
    &lt;true&gt;No, that's not correct.&lt;/true&gt;
    &lt;false&gt;Correct!  New York's Chrysler Building, 
    completed in 1930, became the world's tallest.&lt;/false&gt;
  &lt;/question&gt;
&lt;/test&gt;</pre></span>
<p>gpX^CV[ĝ͎ƂłB</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xml version="1.0"?&gt;
&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

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

  &lt;xsl:variable name="newline"&gt;
&lt;xsl:text&gt;
&lt;/xsl:text&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:template match="/"&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;Tests of the substring() function:&lt;/xsl:text&gt;

    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   substring('Now is the time', 4)="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="substring('Now is the time', 4)"/&gt;
    &lt;xsl:text&gt;"&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   substring('Now is the time', 4, 6)="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="substring('Now is the time', 4, 6)"/&gt;
    &lt;xsl:text&gt;"&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   substring('Now is the time', 4, -6)="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="substring('Now is the time', 4, -6)"/&gt;
    &lt;xsl:text&gt;"&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   substring('Now is the time', -3, 6)="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="substring('Now is the time', -3, 6)"/&gt;
    &lt;xsl:text&gt;"&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   substring('Now is the time', 54, 6)="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="substring('Now is the time', 54, 6)"/&gt;
    &lt;xsl:text&gt;"&lt;/xsl:text&gt;
<!--<?troff .Nd 10?>-->
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   count(//*)=&lt;/xsl:text&gt;
    &lt;xsl:value-of select="count(//*)"/&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   substring('Here is a really long string', &lt;/xsl:text&gt; 
    &lt;:xsl:text&gt;count(//*))="&lt;/xsl:text&gt;
    &lt;xsl:value-of 
      select="substring('Here is a really long string', count(//*))"/&gt;
    &lt;xsl:text&gt;"&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   substring('Here is a less long string', &lt;/xsl:text&gt;
    &lt;xsl:text&gt;count(//*) mod 7, 7)="&lt;/xsl:text&gt;
    &lt;xsl:value-of 
      select="substring('Here is a less long string', count(//*) mod 7, 7)"/&gt;
    &lt;xsl:text&gt;"&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;   substring(/test/question[1]/text, 3, 7)="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="substring(//*, 3, 7)"/&gt;
    &lt;xsl:text&gt;"&lt;/xsl:text&gt;
    &lt;xsl:value-of select="$newline"/&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;</pre></span>
<p>Saxon vZbTgpꍇ̌ʂ͎̂ƂłB</p>
<span class="PROGRAMLISTING"><pre>

Tests of the substring() function:

   substring('Now is the time', 4)=" is the time"
   substring('Now is the time', 4, 6)=" is th"
   substring('Now is the time', 4, -6)="
   substring('Now is the time', -3, 6)="No"
   substring('Now is the time', 54, 6)="

   count(//*)=10
   substring('Here is a really long string', count(//*))=" really long string"
   substring('Here is a less long string', count(//*) mod 7, 7)="re is a"
   substring(/test/question[1]/text, 3, 7)=" This i"
</pre></span>
<p>Xalan gpēϊsƁA^CG[܂B</p>
<span class="PROGRAMLISTING"><pre>
file:///D:/O'Reilly/XSLT/bookSamples/AppendixC/substringfunction.xsl; Line 26;
  Column 65;
Tests of the substring() function:

<!--<?troff .Nd 10?>-->
   substring('Now is the time', 4)=" is the time"
   substring('Now is the time', 4, 6)=" is th"
   substring('Now is the time', 4, -6)="
XSLT Error (javax.xml.transform.TransformerException): String index out of range
: -3</pre></span>
<p>_ł́AXTASaxonA Oracle ̊evZbTׂ͂Đʂ܂BXalan  Microsoft  XSLT c[ł̓^C̗O܂Bł́A<span class="LITERAL">substring()</span> ֐̓K؂ȃp[^gpāAقȂĂȂ悤ɂ邱ƂړIƂĂ܂B </p>
</td>
</tr>
</table>
</div>
</body>
</html>
