Hi Juan,
your hint helped me solve the problem.
I tried many combinations of my XML (\r, \n, \t, spaces, BOM,...) and I couldn't get the digest that XMLSpy gets. But there is one combination that I haven't tried and it actually worked (see attached XMLSpy-test.xml).
Once I got the same unsigned XML and digest I compared signed XML of xmlseclibs and XMLSpy. There were many differences (XML declaration, namespace prefix, spaces and new lines,...). But the one that caused the problem was that XMLSpy added attribute URI="" to element <Reference> which xmlseclibs didn't.
In xmlseclibs.php after this line:
$refNode = $this->createNewSignNode('Reference');
I added this line:
$refNode->appendChild($this->sigNode->ownerDocument->createAttribute('URI'));