concat() 関数 | |
すべてのパラメータを受け取り、それらを連結します。文字列以外のパラメータは、string() 関数によって処理されたかのように文字列に変換されます。 | |
入力 | |
複数の文字列。 |
|
出力 | |
すべての入力文字列の連結。 |
|
定義先 | |
XPath 4.2 節「文字列関数」 |
|
例 | |
この XML ファイルを使用して、concat() の動作を示します。 <?xml version="1.0"?> <list> <title>A few of my favorite albums</title> <listitem>A Love Supreme</listitem> <listitem>Beat Crazy</listitem> <listitem>Here Come the Warm Jets</listitem> <listitem>Kind of Blue</listitem> <listitem>London Calling</listitem> <listitem>Remain in Light</listitem> <listitem>The Joshua Tree</listitem> <listitem>The Indestructible Beat of Soweto</listitem> </list> 例のスタイルシートでは、concat() 関数を使用してさまざまな JPEG ファイルのファイル名を作成します。ファイル名は、concat() 関数によって連結されたいくつかの情報で構成されます。 <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:variable name="newline"> <xsl:text> </xsl:text> </xsl:variable> <xsl:template match="/"> <xsl:value-of select="$newline"/> <xsl:for-each select="list/listitem"> <xsl:text>See the file </xsl:text> <xsl:value-of select="concat('album', position(), '.jpg')"/> <xsl:text> to see the title of album #</xsl:text> <xsl:value-of select="position()"/> <xsl:value-of select="$newline"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> スタイルシートからは、次のような結果が生成されます。 See the file album1.jpg to see the title of album #1 See the file album2.jpg to see the title of album #2 See the file album3.jpg to see the title of album #3 See the file album4.jpg to see the title of album #4 See the file album5.jpg to see the title of album #5 See the file album6.jpg to see the title of album #6 See the file album7.jpg to see the title of album #7 See the file album8.jpg to see the title of album #8 |