XSLT is data-driven, that is, it goes through the single source XML file top to bottom looking for template matches in the XSL stylesheet. The templates don t really know where they are in the data, they just run their code when matched. You can reference another XML source, but the program will run according to the traversal of the original source.
So when you arrive at the nth child element of <blarg>
, for example, you could look up the nth child of <blarg>
in a second XML using the document()
function. But the usefulness of this depends on the structure of your XML and what comparisons you re trying to do.
This behavior is opposite of most traditional scripts, which run through the program code top to bottom, calling on the data file when instructed. The latter--pull processing--is what you probably need to compare two XML sources. XSLT will break down in comparison as soon as there is a difference.