如何将XSLT变量传递给XSLT模板中的JavaScript函数? 我正在使用XSLT,需要将XSLT变量传递给JavaScript函数,以动态更新页面上的内容。具体来说,我的XSLT模板中有一个变量,我想让您...

问题描述 投票:0回答:1
here是样本xml:

<?xml version="1.0" encoding="UTF-8"?> <outline xmlns="http://wkhtmltopdf.org/outline"> <item title="" page="0"/> <!-- Note: I want to pass the substring of the item title (e.g. 'JPN') to JS --> <item title="language_title:JPN" page="1"> <item title="Table of Contents" page="2"/> </item> <item title="document" page="2"> <item title="introduction" page="1"> <item title="Chapter1" page="2"> <item title="Section1" page="3"/> </item> <item title="Chapter2" page="4"> <item title="Section2" page="5"/> </item> </item> </item> <item title="" page="20"/> </outline>

我认为您当前的代码在定义该函数之前试图调用该函数,将代码更改为例如。

<script type="text/javascript"> <!-- Note: call the following function to update the TOC header based on language title --> document.addEventListener('DOMContentLoaded', function(evt) { updateTOCHeader("<xsl:value-of select="$language_title"/>"); }); </script>

该函数首先定义,然后在加载DOM后稍后被调用。
    
javascript xslt wkhtmltopdf
1个回答
0
投票
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.