xml-xindice-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Farrow <s.far...@umist.ac.uk>
Subject RE: Querying with namespaces
Date Wed, 11 Jun 2003 16:37:18 GMT
So I'm going to end up passing in an array of all of the namespaces used
in a particular query. I think that i may have a cunning plan ;-). I'm
thinking that I can grab all of the namespaces as documents are
submitted and then load them all in advance so they are there for any
querying. Is there any kind of limit on the number that i can have set
and any time?

Thanks for the rapid response.

Simon.

> You need to use the setNamespace method of the XPathQueryService, to specify
> any prefix to namespace mappings that you are going to use within your
> query. For example:
> 
> service =
> (XPathQueryService)collection.getService("XPathQueryService","1.0");
> service.setNamespace("ns1","Alma/ObsPrep/ObsProject");
> ResourceSet resultSet= service.query(query);
> 
> - Tom
> 
> -----Original Message-----
> From: Simon Farrow [mailto:s.farrow@umist.ac.uk]
> Sent: Wednesday, June 11, 2003 5:25 PM
> To: xindice users
> Subject: Querying with namespaces
> 
> 
> I realize that this was discussed a little while ago but I couldn't seem
> to find any final answer. I'm trying to query a document that uses
> namespaces throughout. Not using namespaces is not an option for us. An
> excerpt from the document is below:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <ns1:ObsProject xmlns:ns1="Alma/ObsPrep/ObsProject">
>     <ns1:ObsProjectEntity entityId="uid://X0000000000000001/X00000100"
>         entityIdEncrypted="-- id encryption not yet implemented --"
> entityTypeName="ObsProject"/>
>     <ns1:ObsProposalRef entityId="uid://X0000000000000001/X00000101"
>         entityTypeName="ObsProposal" entityVersion="latest"/>
>     <ns1:ObsProgram code="aaa">
> 
> the query I'm trying to perform is very simple
> 
> /ns1:ObsProject
> 
> This should select every document with this root node in the database.
> 
> all this is being done with code that looks like:
> 
> service = (XPathQueryService)collection.getService("XPathQueryService",
> "1.0");
> ResourceSet resultSet= service.query(query);
> 
> where query is the string obove.
> 
> this query causes an exception to be thrown:
> org.xmldb.api.base.XMLDBException: Query error
> 
> Does anyone have any clue how I can get this query to return something.
> The same query without the namespace returns no results.
> 
> Thanks,
> 
> Simon Farrow.
> 
> 
> 
> 



Mime
View raw message