Q: Matching Elements

Write an XSLT stylesheet function that returns true if two elements “match”:

f:element-matches($srcElem, $targetElem)

Two elements match if:

  1. They have the same name (use the node-name function).

  2. Every attribute on $srcElem that is not in a namespace is also on $targetElem and has the same value.

  3. Namespace qualified attributes on $srcElem are ignored.

  4. Extra attributes are allowed on $targetElem.