Pieper, Aaron
2011-05-23 22:19:58 UTC
Hello,
I am working on some unit tests which use XPath to draw assertions on a
document. I encountered some surprising behavior, when evaluating the
following document.
<endpoint>
<service>getData
<errors/>
</service>
</endpoint>
The XPath expression /endpoint/service[text()='getData'] returns a
single node in some XML frameworks (like Dom4J), but returns zero nodes
in Xom. This is because Xom preserves leading/trailing whitespace. I'm
able to work around this by embedding the NormalizingFactory sample code
into my tests. At first I was frustrated that Xom behaved differently
from other frameworks; but, experimenting a little, this behavior is
consistent with the XSD specification, where leading/trailing whitespace
will invalidate a document in some cases. So, I think Xom is doing the
right thing here.
It might make sense to streamline this NormalizingFactory and package it
with Xom.
- Aaron
I am working on some unit tests which use XPath to draw assertions on a
document. I encountered some surprising behavior, when evaluating the
following document.
<endpoint>
<service>getData
<errors/>
</service>
</endpoint>
The XPath expression /endpoint/service[text()='getData'] returns a
single node in some XML frameworks (like Dom4J), but returns zero nodes
in Xom. This is because Xom preserves leading/trailing whitespace. I'm
able to work around this by embedding the NormalizingFactory sample code
into my tests. At first I was frustrated that Xom behaved differently
from other frameworks; but, experimenting a little, this behavior is
consistent with the XSD specification, where leading/trailing whitespace
will invalidate a document in some cases. So, I think Xom is doing the
right thing here.
It might make sense to streamline this NormalizingFactory and package it
with Xom.
- Aaron