Im using this merge.xslt script to merge several different XML files into one. This tool is very useful and includes a dontmerge
command-line parameter so that certain XML elements wont be merged. The problem is that only one XML element can be specified, and I need to be able to specify multiple XML elements that shouldnt be merged. I could just add more command-line parameters to the script, like dontmerge2
, dontmerge3
, etc but this isnt an elegant solution.
While studying the particular XML elements that should not be merged, I realized that they are all of the same XML schema type, as follows:
<xs:element name="doCliCommand" type="cliParametersT">
</xs:element>
<xs:element name="undoCliCommand" type="cliParametersT">
</xs:element>
So, instead of using dontmerge
for both doCliCommand
and undoCliCommand
, I would like to be able to do something like dontmergetype=cliParametersT
The relevant part of the merge.xslt
is the following:
<xslt:param name="dontmerge" />
...
<xslt:when test="$type1='element' and $type2='element' and
local-name($node1)=local-name($node2) and
namespace-uri($node1)=namespace-uri($node2) and
name($node1)!=$dontmerge and name($node2)!=$dontmerge">
So here is the question: How do I modify this particular xslt test condition to be able to test for the XML schema type? I havent found any appropriate XPath, XQuery, or XSLT functions to get the schema type.
There is a somewhat related question where they mention that this cant be done unless using Saxon extensions. Im using SaxonHE9-5-1-3J.