I have two sample documents defined below. In module_meta.xml
only the effect nodes on xpath /mdata/effectivity
are relevant. As seen below, they contain a path
attribute and a effrg
attribute. The goal is now to evaluate the xpath (which is defined in the module_meta.xml
as the path
attribute) on the module.xml
and append the effrg
to it. See desired_output.xml
for the desired result. The xsl transformation is applied on module.xml
. I know that I have to use the document()
function to "include" module_meta.xml
, but so far I am at a loss.
module.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE proc>
<procbody>
<info>
<action lid="a">
</action>
<action lid="b">
</action>
<action lid="c">
</action>
</info>
</procbody>
module_meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mdata>
<mdata>
<metadata>
<metadata-item name="n1" value="v1" />
<metadata-item name="n2" value="v2" />
<metadata-item name="n3" value="v3" />
</metadata>
<effectivity>
<effect path="//*[@lid='a']" effrg="0074 0080 0087" />
<effect path="//*[@lid='b']" effrg="0136 0146 0174" />
</effectivity>
</mdata>
desired_output.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE proc>
<procbody>
<info>
<action lid="a" effrg="0074 0080 0087">
</action>
<action lid="b" effrg="0136 0146 0174">
</action>
<action lid="c">
</action>
</info>
</procbody>
xsl:evaluate
. Some older implementations provide extension functions or let you set one up for XPath evaluation. Or you can chain two stylesheets. – Martin Honnen