You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by Nicolai Wadström <ni...@yahoo.se> on 2002/11/03 18:48:53 UTC

XPath query broken in CVS (get's an Exception)?

Hi,

I used be able to perform XPath queries as follows (I am working with the
CVS sources, refreshed earlier today):

The queries look like this:

/contact:contact/attribute::entity:type='contact' also tried
/contact:contact[entity:type='contact']

What I get back is 25 StackTraces in the log (and result objects are
returned but are null)! 25 Is the number of
objects I have in the database. If I change to query slightly so it won't
match any objects, there is no exception
and of course an empty result set!

The calling query code used to work for this (and have not been changed for
a while, see end of message).



Log output ("Kan inte konvertera #BOOLEAN till en NodeList!" localized
message, probally from Xerces, for "Can not convert #BOOLEAN to a
NodeList!")


The 25 Stack traces are generated from inside Xindice, when the following
line is executed:
			org.xmldb.api.base.ResourceSet 		resultSet	= service.query( xpathquery );


Is this a namespace problem?
I know namespace handling changed (from reading this list, and also needed
to change from xmlns:prefix to prefix in the code). I got another error when
the namespace was wrong (the xmlns: thing) though.

Any help or pointer would be appreciated.


Regards,
Nicolai



---------------
XML Database info: org.apache.xindice.client.xmldb.embed.DatabaseImpl@289d2e
DataEngineAPIServer - objectQuery: collection = 'main', xpath =
'/contact:contact/attribute::entity:type='contact''.
DataEngineAPIServer - objectQuery: isOpen = true
DataEngineAPIServer - objectQuery: size = 25
DEBUG org.apache.xindice.core - No message
org.apache.xpath.XPathException: Kan inte konvertera #BOOLEAN till en
NodeList!
	at org.apache.xpath.objects.XObject.error(XObject.java:718)
	at org.apache.xpath.objects.XObject.nodeset(XObject.java:448)
	at
org.apache.xindice.core.query.XPathQueryResolver$ResultSet.prepareNextNode(X
PathQueryResolver.java:1069)
	at
org.apache.xindice.core.query.XPathQueryResolver$ResultSet.<init>(XPathQuery
Resolver.java:1043)
	at
org.apache.xindice.core.query.XPathQueryResolver$XPathQuery.execute(XPathQue
ryResolver.java:282)
	at
org.apache.xindice.core.query.XPathQueryResolver.query(XPathQueryResolver.ja
va:184)
	at org.apache.xindice.core.query.QueryEngine.query(QueryEngine.java:163)
	at org.apache.xindice.core.Collection.queryCollection(Collection.java:809)
	at
org.apache.xindice.client.xmldb.embed.CollectionImpl.query(CollectionImpl.ja
va:411)
	at
org.apache.xindice.client.xmldb.XindiceCollection.query(XindiceCollection.ja
va:279)
	at
org.apache.xindice.client.xmldb.services.QueryService.query(QueryService.jav
a:130)
	at
com.saguru.intelligence.data.internal.DataEngineAPIServer.queryObjects(DataE
ngineAPIServer.java:582)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at
com.saguru.sf.api.extension.APIServerExtensionReflection.invokeMethod(APISer
verExtensionReflection.java:309)
	at
com.saguru.sf.api.extension.APIServerExtensionReflection.invokeAPIMethod(API
ServerExtensionReflection.java:271)
	at
com.saguru.sf.api.internal.APIServerDefaultRouterImpl.invokeAPIMethod(APISer
verDefaultRouterImpl.java:194)
	at com.saguru.intelligence.api.APIReference.makecall(APIReference.java:154)
	at
com.saguru.intelligence.api.repository.Repository.objectQuery(Repository.jav
a:322)
	at
com.saguru.intelligence.api.data.DataSourceRepository.contactQuery(DataSourc
eRepository.java:183)
	at
com.saguru.intelligence.api.data.DataSourceRepository.contactQuery(DataSourc
eRepository.java:167)
	at
com.saguru.intelligence.inteliagent.agents.GoogleObservationAgent.run(Google
ObservationAgent.java:217)
	at
com.saguru.intelligence.inteliagent.ContextImpl.run(ContextImpl.java:204)
	at java.lang.Thread.run(Thread.java:536)

.
.
.
... and 24 more of these Stack Traces.
DataEngineAPIServer - Query result size = 0




Java code is below:



public java.util.Vector queryObjects(String collection, String xpathquery)
{
	org.xmldb.api.base.Collection			col			= null;
	try
	{
		col		= getCollection( collection );
		java.util.Vector		results		= new java.util.Vector();

		logger.debug( "objectQuery: collection = '" + col.getName() + "', xpath =
'" + xpathquery + "'." );
		logger.debug( "objectQuery: isOpen = " + col.isOpen() );
		logger.debug( "objectQuery: size = " + col.getResourceCount() );


		// Return all objects
		if ( xpathquery == null )
		{
			String		ids[]		= col.listResources();
			for( int i=0; i < ids.length; i++ )
			{
				String		id	= ids[ i ];
				results.addElement( id );
			}
		}

		// Process xpath query
		else
		{
			org.xmldb.api.modules.XPathQueryService 	service	=
getXPathQueryService( col );
			org.xmldb.api.base.ResourceSet 		resultSet	= service.query( xpathquery );

			logger.debug( "Query result size = " + resultSet.getSize() );

			//
			for ( org.xmldb.api.base.ResourceIterator i = resultSet.getIterator();
i.hasMoreResources(); )
			{
				org.xmldb.api.base.Resource		res = i.nextResource();
				logger.debug( "Query result element: " + res );
				results.addElement( res.getId() );
			}
		}

		return( results );
	}

	catch(Exception e )
	{
		logger.debug( "queryObjects error", e );
	}


	finally
	{
		returnCollection( col );
	}

	return( null );
}



Code for the getXPathQueryService():

/**
 *
 *
 */
protected org.xmldb.api.modules.XPathQueryService
getXPathQueryService(org.xmldb.api.base.Collection collection)
	throws
		org.xmldb.api.base.XMLDBException
{
	org.xmldb.api.modules.XPathQueryService 	service		=
(org.xmldb.api.modules.XPathQueryService)collection.getService("XPathQuerySe
rvice", "1.0");



	for ( java.util.Enumeration e = namespaces.keys(); e.hasMoreElements(); )
	{
		String			prefix		= (String)e.nextElement();
		String			uri			= (String)namespaces.get( prefix );

		service.setNamespace( prefix, uri );
	}


	return( service );
}

_____________________________________________________
Följ VM på nära håll på Yahoo!s officielle VM-sajt www.yahoo.se/vm2002
Håll dig ajour med nyheter och resultat, med vinnare och förlorare...

Re: XPath query broken in CVS (get's an Exception)?

Posted by Terry Rosenbaum <Te...@amicas.com>.
 > I used be able to perform XPath queries as follows (I am working with the
 > CVS sources, refreshed earlier today):

It would also be useful if you posted a
sample of the XML document you were
querying when the error occurred.

It's often difficult to debug XPath problems
without looking at the XML against which the
XPath is run.

-Terry

Nicolai Wadstrom wrote:

>I wanted to check/confirm with others on the list that this is infact a bug
>(I believe it is),
>anybody who could confirm that I am not doing something wrong here, or
>misssed something?
>
>Otherwise I'll keep diging and see if I could locate the bug, and I'll start
>by putting together
>som JUnit tests.
>
>Where/how do I sumbit them?
>
>// Nicolai
>
>-----Original Message-----
>From: Vladimir R. Bossicard [mailto:vladimir@bossicard.com]
>Sent: den 4 november 2002 18:01
>To: xindice-dev@xml.apache.org
>Subject: Re: XPath query broken in CVS (get's an Exception)?
>
>
>  
>
>>I used be able to perform XPath queries as follows (I am working with the
>>CVS sources, refreshed earlier today):
>>    
>>
>
>What really would help is some automatic tests.  If you know JUnit, you
>can write some tests under "integration" that reveal the bug.
>
>-Vladimir
>
>--
>Vladimir R. Bossicard
>www.bossicard.com
>
>_____________________________________________________
>
>Följ VM på nära håll på Yahoo!s officielle VM-sajt www.yahoo.se/vm2002
>
>Håll dig ajour med nyheter och resultat, med vinnare och förlorare...
>
>  
>



Re: XPath query broken in CVS (get's an Exception)?

Posted by Kevin Ross <Ke...@iVerticalLeap.com>.
bugzilla:

http://nagoya.apache.org/bugzilla/

Nicolai Wadstrom wrote:

>I wanted to check/confirm with others on the list that this is infact a bug
>(I believe it is),
>anybody who could confirm that I am not doing something wrong here, or
>misssed something?
>
>Otherwise I'll keep diging and see if I could locate the bug, and I'll start
>by putting together
>som JUnit tests.
>
>Where/how do I sumbit them?
>
>// Nicolai
>
>-----Original Message-----
>From: Vladimir R. Bossicard [mailto:vladimir@bossicard.com]
>Sent: den 4 november 2002 18:01
>To: xindice-dev@xml.apache.org
>Subject: Re: XPath query broken in CVS (get's an Exception)?
>
>
>  
>
>>I used be able to perform XPath queries as follows (I am working with the
>>CVS sources, refreshed earlier today):
>>    
>>
>
>What really would help is some automatic tests.  If you know JUnit, you
>can write some tests under "integration" that reveal the bug.
>
>-Vladimir
>
>--
>Vladimir R. Bossicard
>www.bossicard.com
>
>_____________________________________________________
>Följ VM på nära håll på Yahoo!s officielle VM-sajt www.yahoo.se/vm2002
>Håll dig ajour med nyheter och resultat, med vinnare och förlorare...
>
>  
>


RE: XPath query broken in CVS (get's an Exception)?

Posted by Nicolai Wadstrom <ni...@yahoo.se>.

I wanted to check/confirm with others on the list that this is infact a bug
(I believe it is),
anybody who could confirm that I am not doing something wrong here, or
misssed something?

Otherwise I'll keep diging and see if I could locate the bug, and I'll start
by putting together
som JUnit tests.

Where/how do I sumbit them?

// Nicolai

-----Original Message-----
From: Vladimir R. Bossicard [mailto:vladimir@bossicard.com]
Sent: den 4 november 2002 18:01
To: xindice-dev@xml.apache.org
Subject: Re: XPath query broken in CVS (get's an Exception)?


> I used be able to perform XPath queries as follows (I am working with the
> CVS sources, refreshed earlier today):

What really would help is some automatic tests.  If you know JUnit, you
can write some tests under "integration" that reveal the bug.

-Vladimir

--
Vladimir R. Bossicard
www.bossicard.com

_____________________________________________________
F�lj VM p� n�ra h�ll p� Yahoo!s officielle VM-sajt www.yahoo.se/vm2002
H�ll dig ajour med nyheter och resultat, med vinnare och f�rlorare...

Re: XPath query broken in CVS (get's an Exception)?

Posted by "Vladimir R. Bossicard" <vl...@bossicard.com>.
> I used be able to perform XPath queries as follows (I am working with the
> CVS sources, refreshed earlier today):

What really would help is some automatic tests.  If you know JUnit, you 
can write some tests under "integration" that reveal the bug.

-Vladimir

-- 
Vladimir R. Bossicard
www.bossicard.com