您能告诉我如何访问XSLT中的变量吗?.i在 js
中使变量。我想打印其值。因此,我在xsl中分配了变量值:变量当我尝试打印可变值时,它会给我string
而不是评估这是我的代码http://xsltransform.net/ppj8lwb
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<hmtl>
<head>
<title>New Version!</title>
</head>
<script>
console.log('starte');
var start = 5;
'<xsl:variable name="start">{start}</xsl:variable>'
console.log('<xsl:value-of select="$start"/>')
</script>
</hmtl>
</xsl:template>
</xsl:transform>
预期输出 :: 5任何更新
好吧,我建议您喜欢这样做:
演示-https://jsfiddle.net/skyr99999/behf2h7t/
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<hmtl>
<head>
<title>New Version!</title>
</head>
<script>
console.log('starte');
var start = 5;
document.write('<xsl:variable name="start">'+start+'</xsl:variable>');
console.log("<xsl:value-of select='"+start+"'/>")
</script>
</hmtl>
</xsl:template>
</xsl:transform>