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函数?_Xslt_Escaping - Fatal编程技术网

用于转义引号的XSLT函数?

用于转义引号的XSLT函数?,xslt,escaping,Xslt,Escaping,我有一些XSLT,它获取一个属性并将其作为URL的一部分发送到php$\u GET变量。看起来是这样的: <xsl:attribute name="href">search.php?subject="<xsl:value-of select="@level1"/>"</xsl:attribute> 问题是,当@level1的值包含引号时,如“bar”等无效。我明白了: search.php?subject=""bar" etc etc" 当然,它返回一个

我有一些XSLT,它获取一个属性并将其作为URL的一部分发送到php$\u GET变量。看起来是这样的:

<xsl:attribute name="href">search.php?subject="<xsl:value-of select="@level1"/>"</xsl:attribute> 
问题是,当
@level1
的值包含引号时,如
“bar”等
无效。我明白了:

search.php?subject=""bar" etc etc"
当然,它返回一个空的
主题
。如果我加上反斜杠,它会突然起作用。例如,如果我将URL编辑为:

search.php?subject="\"bar\" etc etc" 
然后,
$\u GET['subject]==“bar”等
!那么,如何让XSL添加反斜杠以避开这些恶意引号呢?我试过了

<xsl:attribute name="href">search.php?subject="<xsl:value-of select='replace(@level1,",\")'/>"</xsl:attribute> 
search.php?subject=“”
我试过了

<xsl:attribute name="href">search.php?subject="<xsl:value-of select="replace(@level1,&quot;,\&quot;"/>"</xsl:attribute>
search.php?subject=“”

但似乎什么都不管用

在XSLT2.0中使用
replace()
函数

XSLT1.0中,使用递归
exslt:replace
模板,您可以在

(不管怎样,当您询问有关XSLT的问题时,请告诉我们您使用的是哪个版本)

<xsl:attribute name="href">search.php?subject="<xsl:value-of select="replace(@level1,&quot;,\&quot;"/>"</xsl:attribute>