I'm trying to use an XSLT stylesheet to transform some XML into another language, but need to select a node by matching one attribute with another attribute on another node elsewhere in the document.
Sounds a bit confusing, so I'll try and clarify with a simplistic example:
<node name="nodeA">
<output id="1212" />
</node>
<node name="nodeB">
<input id="3234" />
</node>
<link target="1212" source="3234" />
So what I want to do is select a link 'target' attribute, then get the corresponding 'node' name, and of course the same with the link 'source' attribute. This is so I can transform it into a representation something like
(nodeA->nodeB)
The point of it is to represent a workflow with edges to traverse (e.g. nodeA connects to nodeB).
So my problem is that I have yet to figure out how to match attributes to attributes using XSLT or XPath. I've tried it with predicates and 'if' statements, but it just returns with no results like that. From what I've read there aren't any examples where a right-hand-side of a predicate or test can be a node/attribute/variable/parameter, but they all seem to show fixed values.
Ideally I'd just give up using a stylesheet and hard-code it in Java, but I've been told XSLT is the preferred way for this project. Also the initial way the data is represented (with the <node>s and <link>s as described above) cannot be changed.
Any ideas?