我有一个关于在我正在处理的项目上重构som XSLT代码的问题。在XSLT我现在我该如何重构这个XSLT
<pdf:sometext text="{$metadata/namespace:template
/namespace:template_collection
//namespace:option
[namespace:identificator
= $report_option_identifier]
/namespace:name}"/>
的问题是,XSLT需要扩展打更多的节点(在原著XML的新版本,以略低改变了命名空间和略有改变标签)。
我想出了这个代码:
<xsl:variable name="report_template_collection"
select="$metadata
/namespace:template
/namespace:template_collection
|
$metadata
/namespace2:templateV2
/namespace2:template_collectionV2" />
<xsl:variable name="current_report_option"
select="namespace:option | namespace2:optionV2" />
<xsl:variable name="incomplete_report_option_text"
select="$report_template_collection
//$current_report_option
[namespace:identificator
= $report_option_identifier]
/namespace:name"/>
<pdf:sometext text="{$incomplete_report_option_text}"/>
但是在编译时它带有的部份错误:
Unexpected token '$' in the expression. $report_template_collection// -->$<-- current_report_option[namespace:opt...
所以我的问题是:我如何重构XSLT占新的命名空间(命名为V2)和另一个命名空间。重要的是相同的XSLT符合XML的所有版本(包括旧版本和新版本)。
在此先感谢!
你的问题是相当无法回答的,因为它是现在。所有这些变量的目的是什么?您提到了不同版本的XML输入,但不显示任何内容。我建议您按照以下顺序编辑您的问题并显示以下内容:1个句子,解释您的目标是什么,出了什么问题,带有问题的_full_,最小XSLT样式表,XML输入以及您期望的XML输出。 – 2014-08-29 09:43:31
错误消息告诉你,其中一个'select'属性的值不是XPath表达式。你的问题出现在表达部分......'// current_report_option' ... - 因为只有你知道你在那里说什么,只有你可以修复它。 – 2014-08-29 14:35:13