Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 如何在xsl:text元素中引用变量?_Xslt - Fatal编程技术网

Xslt 如何在xsl:text元素中引用变量?

Xslt 如何在xsl:text元素中引用变量?,xslt,Xslt,我有一个样式表,我希望在xsl文本元素中插入预定义的字符串变量,但在搜索web时找不到任何指针 例如: <xsl:variable name="var" select="node()/ref/text()"/> ... <xsl:text>Some text where I want to append $var variable desperately</xsl:text> ... ... 我想在其中添加$var变量的一些文本 ... 我尝试使用$va

我有一个样式表,我希望在xsl文本元素中插入预定义的字符串变量,但在搜索web时找不到任何指针

例如:

<xsl:variable name="var" select="node()/ref/text()"/>
...
<xsl:text>Some text where I want to append $var variable desperately</xsl:text>
...

...
我想在其中添加$var变量的一些文本
...

我尝试使用$var,($var),{$var}…

xsl:text
仅用于输出固定文本,它不能包含嵌套指令。输出变量文本的指令是
xsl:value of

以下是另一种方法:

Some text where I want to include the value of <xsl:value-of select='$var'/>.
<xsl:value-of select="concat(
    'Some text where I want to append ', 
    $var, 
    ' variable desperately')" />


虽然这有点难看,但它可以让您完全控制文本和变量文本之间的空白。

我做了类似的事情,创建了一个带有字符串的变量和另一个变量

<xsl:variable name="imgsrc">http://mirrors.creativecommons.org/presskit/buttons/<xsl:value-of select='$iconSize' />/<xsl:value-of select="substring-before($licenceTypeAndText, '|')" /></xsl:variable>

是的,我将其用于空格(LF),实际上我想插入的变量也是预定义的格式化空间:D,因此可以使用
进行变通,但不能在
元素内进行,因为这是不允许的。我会等着看是否用其他方法确实不可能,然后我会把你的答案标记为正确。谢谢。@theta:你是说
元素内不允许
吗?哇,你说得对。我忘了,这才是真正的答案。
<xsl:variable name="imgsrc">http://mirrors.creativecommons.org/presskit/buttons/<xsl:value-of select='$iconSize' />/<xsl:value-of select="substring-before($licenceTypeAndText, '|')" /></xsl:variable>
http://mirrors.creativecommons.org/presskit/buttons/80x15/png/by.png