Paul Lalonde wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi. I'm tring to use Xalan's XPath support to run queries on some
Collada documents I have. I've run into the issue that the documents
all declare themselves in an anonymous namespace:
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema"
version="1.4.0">
<asset>
...
</asset>
</COLLADA>
So I want my XPath expressions to refer through that namespace. I
thought I'd try using the XalanSimplePrefixResolver doing something like
this:
XalanSimplePrefixResolver thePrefixResolver(
XalanDOMString("c"),
XalanDOMString("http://www.collada.org/2005/11/COLLADASchema"),
XalanDOMString("http://www.collada.org/2005/11/COLLADASchema")
);
XalanSimplePrefixResolver holds references to existing XalanDOMString
instances, and you are passing in temporaries that are destroyed after the
constructor is called. As a result, the instance contains references to
three XalanDOMString instances that have already been destroyed. When the
XPath compiler attempts to use the PrefixResolver, it contains garbage data.
Declare the XalanDOMString instances on the stack, not as temporaries, and
your code will work.
Dave