将动态字符串评估为 XPath 表达式? [英] Evaluate dynamic string as an XPath expression?

查看:31
本文介绍了将动态字符串评估为 XPath 表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在写一些东西来做 XSLT2 函数的单元测试,想法很简单:

Currently, I'm writing something to do Unit testing for XSLT2 functions, the idea is very simple:

  1. 创建一个 custom-library.xsl,其中包含一些自定义 XSLT2 函数.
  2. 创建包含测试用例的数据XML,如下XML Schema xslunit.xsd:

  1. Create a custom-library.xsl, which contains some custom XSLT2 functions.
  2. Create a data XML contains the test cases, as following XML Schema xslunit.xsd:

模式结构 http://xml.bodz.net/schema/xslunit/xslunit.png

通过转换运行测试用例,使用 xslunit-xslt2.xsl,并得到测试结果html.

Run the test cases by transform it, using xslunit-xslt2.xsl, and get the test result html.

现在,问题是,测试用例中有函数调用,我必须在 XSLT 中对其进行评估(文件 xslunit-xslt2.xsl).但我找不到评估 XPath 的方法.

Now, the question is, there is function-call in the test cases, and I have to evaluate it in the XSLT (file xslunit-xslt2.xsl). But I can't find a way to evaluate an XPath.

虽然,使用某种Java扩展可能很容易,但我真的不想再带来麻烦.我希望一切都只能在 XSLT2 中使用.

Though, it may be easy to using some kind of Java extensions, but I really don't want to bring in another trouble. I hope everything can just work with-in XSLT2 only.

推荐答案

不,纯 XSLT 2.0 不支持对 XML 数据中的 XPath 表达式求值.Saxon 9(在其商业版本中)有一个扩展功能:http://www.saxonica.com/documentation/extensions/functions/evaluate.xml.AltovaXML Tools 有一个类似的:http://manual.altova.com/AltovaXML/altovaxmlcommunity/index.html?xextaltova_general.htm

No, pure XSLT 2.0 does not have support do evaluate an XPath expression found in your XML data. Saxon 9 (in its commercial editions) however has an extension function: http://www.saxonica.com/documentation/extensions/functions/evaluate.xml. And AltovaXML Tools has a similar one: http://manual.altova.com/AltovaXML/altovaxmlcommunity/index.html?xextaltova_general.htm

这篇关于将动态字符串评估为 XPath 表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆