You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Paul Lalonde <pl...@neoptica.com> on 2006/09/13 20:01:32 UTC

XalanNamespacesStack::PrefixResolverProxy persistence

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Do I have to build a new XalanNamespacesStack::PrefixResolverProxy  
every time the NamespacesStack changes, or does it remain synchronized?

Paul

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFFCEd9r7+oA6AsvAkRAuDgAJ0cPNdJwh/62zKEP3CuTisZna1BBACgvxOe
OpOGgxcMWRYA03sFZHXDbF4=
=hHnv
-----END PGP SIGNATURE-----

Re: XalanNamespacesStack::PrefixResolverProxy persistence

Posted by David Bertoni <db...@apache.org>.
Paul Lalonde wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> I will read the source in the future.  Point taken :-)
> 
> I'm just using it as a simple container right now, so this should be ok 
> for now, but I know it doesn't solve my problem in the general case.
> 
> I have a bunch of XML documents that I have to extract relatively simple 
> tables of data from using XPath queries.  My initial implementation used 
> a XalanDocumentPrefixResolver, but this fails in the presence of the 
> default namespace present in each of my documents.  To make it work my 
> XPath query has to explicitly name that default namespace, something 
> like "/c:COLLADA" instead of "/COLLADA".  I used the 
> XalanSimplePrefixResolver and made it work.  But this will fail when the 
> document refers to other namespaces.
> 
> I'm guessing my longer term answer will be to build a new improved 
> XalanDocumentPrefixResolver that also allows me to register new 
> namespaces a la XalanNamespacesStack.
> 
> Or does this functionality already exist?  I can't seem to find it.
> 

No, it doesn't exist by default.  Several years ago, I posted an 
implementation of a PrefixResolver that used a XalanMap internally.  That 
would probably be the easiest thing to use, but it really depends on how 
you discover namespace bindings to begin with.

XalanNamespaceStack is probably too heavyweight for your needs, since it 
doesn't seem like you need a stack of namespaces at all.

Dave

Re: XalanNamespacesStack::PrefixResolverProxy persistence

Posted by Paul Lalonde <pl...@neoptica.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I will read the source in the future.  Point taken :-)

I'm just using it as a simple container right now, so this should be  
ok for now, but I know it doesn't solve my problem in the general case.

I have a bunch of XML documents that I have to extract relatively  
simple tables of data from using XPath queries.  My initial  
implementation used a XalanDocumentPrefixResolver, but this fails in  
the presence of the default namespace present in each of my  
documents.  To make it work my XPath query has to explicitly name  
that default namespace, something like "/c:COLLADA" instead of "/ 
COLLADA".  I used the XalanSimplePrefixResolver and made it work.   
But this will fail when the document refers to other namespaces.

I'm guessing my longer term answer will be to build a new improved  
XalanDocumentPrefixResolver that also allows me to register new  
namespaces a la XalanNamespacesStack.

Or does this functionality already exist?  I can't seem to find it.

Thanks,
     Paul

>
> You didn't provide enough information about how you are using this  
> class to figure out if this will be a problem or not.
>
> Dave
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFFCFUzr7+oA6AsvAkRAjz1AKCNC5QUiZS4KSrabI0WwaolAfD+4QCfcQrX
32mq+/WkCxbcGyRCKbXDkwI=
=s2j4
-----END PGP SIGNATURE-----

Re: XalanNamespacesStack::PrefixResolverProxy persistence

Posted by David Bertoni <db...@apache.org>.
Paul Lalonde wrote:
> Do I have to build a new XalanNamespacesStack::PrefixResolverProxy every 
> time the NamespacesStack changes, or does it remain synchronized?

If you look at the source code, you'll see that PrefixResolverProxy only 
calls into the XalanNamespacesStack instance, so there's no need to 
synchronize anything:

const XalanDOMString*
XalanNamespacesStack::PrefixResolverProxy::getNamespaceForPrefix(const 
XalanDOMString&	prefix) const
{
	return m_stack.getNamespaceForPrefix(prefix);
}


However, you should be careful when using this class, as prefix bindings 
will go in and out of scope when the stack is pushed and popped.  When 
bindings go out of scope, the pointer returned from 
PrefixResolverProxy::getNamespaceForPrefix will point to an object that has 
been destroyed.

You didn't provide enough information about how you are using this class to 
figure out if this will be a problem or not.

Dave