How can I refactor this XSLT



I have an issue regarding some refactoring of som XSLT code on a project i'm working on. The XSLT I have now



<pdf:sometext text="{$metadata/namespace:template/namespace:template_collection//namespace:option[namespace:identificator = $report_option_identifier]/namespace:name}"/>


The problem is that the XSLT needs to be extended to hit more nodes (a new version of the origianl XML, with slighty changed namespaces and slightly changed tags).


I came up with this code:



<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}"/>


But when compiled it comes with ths error:


Unexpected token '$' in the expression. $report_template_collection// -->$<-- current_report_option[namespace:opt...


So my question is: How can I refactor the XSLT to account for the new typs (named V2) and in another namespace. it's important that the same XSLT is compliant to all versions of the XML (both the old and the new version).


Thanks in advance!


No comments:

Post a Comment