我有一个applescript,它使用xmltransform 来转换使用外部xlst 文件的xml。我想在 applescript 中添加一个变量以供 xslt 文件拾取。satimage 字典谈到使用 xsl 参数作为 xmltransform 的一部分,但我找不到任何示例。
使用模板XMLTransform xmlFile with xsltFile in outputpath
我将如何在 applescript 和以下 xsl 文件示例中定义变量。
<xsl:stylesheet version="1.0">
<xsl:param name="vb1" value="'unknown'"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xmeml/list/name">
<xsl:value-of select="{$vb1}"/>
</xsl:template>
</xsl:stylesheet>
Applescript 片段
set vb1 to "Hello" as string
XMLTransform xmlFile with xsltFile1 in outputpathtemp xsl params vb1
当前的小程序返回“无法使 vb1 进入记录”。
我现在正在考虑使用以下内容,但它在 XML 中返回 NULL
set vb1 to {s:"'hello'"}
XMLTransform xmlFile with xsltFile1 in outputpathtemp xsl string params vb1
输入是
<xmeml>
<list>
<name>IMaName</name>
<!-- other nodes -->
</list>
</xmeml>
当前输出为
<xmeml>
<list>
<name/>
<!-- other nodes -->
</list>
</xmeml>
任何人都可以帮忙吗?非常感谢。