turugina #6567(2008/06/24 01:27 GMT) [ XSLT ] Rating0/0=0.00
XSLTでは変数は variable 要素で宣言します。 内容を指定しない場合は、指定した型によって 空の~~(空リスト、空文字列など)になります。 というわけで、変数は宣言と同時に必ず初期化されています。 というか、変数の内容を変更できないので、 宣言と同時に初期値を放り込まざるをえません。 一方、template 呼び出しなどで param 要素によるパラメタが利用できます。 パラメタは呼び出し側で指定されなかった場合のデフォルト値を指定できます。 (デフォルト値の指定がない場合は変数と同様、空の~~になります) パラメタも変数と同様、内容の変更はできません。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xsl:output method="text" /> <!-- global variable --> <xsl:variable name="hoge" as="xs:integer" select="5" /> <xsl:template match="/"> <!-- local variable --> <xsl:variable name="hige" as="element()"> <parent><child>baby</child></parent> </xsl:variable> <!-- call template without parameters --> <xsl:call-template name="func" /> <!-- call template with parameters --> <xsl:call-template name="func"> <xsl:with-param name="param1">6</xsl:with-param> <xsl:with-param name="param2" as="xs:string*"> <xsl:sequence select="('foo','bar','baz')" /> </xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template name="func"> <!-- parameters --> <xsl:param name="param1" as="xs:integer">7</xsl:param> <xsl:param name="param2" as="xs:string*" /> </xsl:template> </xsl:stylesheet>
Rating0/0=0.00-0+
[ reply ]
turugina
#6567()
[
XSLT
]
Rating0/0=0.00
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xsl:output method="text" /> <!-- global variable --> <xsl:variable name="hoge" as="xs:integer" select="5" /> <xsl:template match="/"> <!-- local variable --> <xsl:variable name="hige" as="element()"> <parent><child>baby</child></parent> </xsl:variable> <!-- call template without parameters --> <xsl:call-template name="func" /> <!-- call template with parameters --> <xsl:call-template name="func"> <xsl:with-param name="param1">6</xsl:with-param> <xsl:with-param name="param2" as="xs:string*"> <xsl:sequence select="('foo','bar','baz')" /> </xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template name="func"> <!-- parameters --> <xsl:param name="param1" as="xs:integer">7</xsl:param> <xsl:param name="param2" as="xs:string*" /> </xsl:template> </xsl:stylesheet>Rating0/0=0.00-0+
[ reply ]