You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Satishkumar Ganesan <kg...@yahoo.com> on 2002/10/18 20:28:23 UTC
XUpdate problem when using namespaces.
Hi
I created two documents under collection /db/Configuration. One with namespace and the other without namespace. Xupdate works for the document without namespace but doesn't work for document with namespace
Document without namespace
<RunNum>
<currentRun>1</currentRun>
</RunNum>
Xupdate
<xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate">
<xu:update select=/RunNum/currentRun> 4 </xu:update>
</xu:modifications>
The above xupdate worked
Document with namespace
<prA:RunNum xmlns:prA="http://www.partsriver.com/ProAnalyze">
<prA:currentRun>1</prA:currentRun>
</prA:RunNum>
XUpdate
<xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate">
<xu:update select=/prA:RunNum/prA:currentRun> 4 </xu:update>
</xu:modifications>
The above xupdate didn't work.
Any clues towards solving this issue are welcome
Satish
Re: XUpdate problem when using namespaces.
Posted by Satishkumar Ganesan <kg...@yahoo.com>.
Hi Tom
Thanks for your response. I added the namespace to <xu:modifications> tag
and the update started working.
<xu:modifications version="1.0"
xmlns:xu="http://www.xmldb.org/xupdate"
xmlns:prA="http://www.partsriver.com/ProAnalyze">
<xu:update select=/prA:RunNum/prA:currentRun> 4 </xu:update>
</xu:modifications>
I wanted to try out your second suggestion setting the namespace thru
XUpdateQueryService. But that is not working. I am gettting APIException
I have removed namespace declarations from the <xu:modifications> tag.
String xupdate = "<xu:modifications version=\"1.0\">" +
" <xu:update
select=\"/prA:RunNum/prA:currentRun\">4</xu:update>"
</xu:modifications>";
XUpdateQueryServiceImpl service =
(XUpdateQueryServiceImpl) col.getService("XUpdateQueryService",
"1.0");
service.clearNamespaces();
service.setNamespace(
"prA","\"http://www.partsriver.com/ProAnalyze\"" );
service.setNamespace("xu", "\"http://www.xmldb.org/xupdate\"");
long count = service.update(xupdate);
Any pointers towards problems in the code block would be useful
Thanks
Satish
----- Original Message -----
From: "Tom Bradford" <br...@dbxmlgroup.com>
To: <xi...@xml.apache.org>
Sent: Friday, October 18, 2002 12:16 PM
Subject: Re: XUpdate problem when using namespaces.
On Friday, October 18, 2002, at 11:28 AM, Satishkumar Ganesan wrote:
> I created two documents under collection /db/Configuration. One with
> namespace and the other without namespace. Xupdate works for the
> document without namespace but doesn't work for document with > namespace
> Document with namespace
> <prA:RunNum xmlns:prA="http://www.partsriver.com/ProAnalyze">
> <prA:currentRun>1</prA:currentRun>
> </prA:RunNum>
>
> XUpdate
> <xu:modifications version="1.0"
> xmlns:xu="http://www.xmldb.org/xupdate">
> <xu:update select=/prA:RunNum/prA:currentRun> 4 </xu:update>
> </xu:modifications>
> The above xupdate didn't work.
From what it looks like, you're just referring to prefixes in the
XUpdate query, which are insufficient as they have no meaning unless
bound to a namespace. So the namespaces have to be declared in the
XUpdate query as well, or possibly as part of a namespace mapping in
the XUpdateQueryService.
--
Tom Bradford - http://www.tbradford.org/
CTO - The dbXML Group - http://www.dbxml.com/
Apache Xindice - http://xml.apache.org/xindice
Re: XUpdate problem when using namespaces.
Posted by Tom Bradford <br...@dbxmlgroup.com>.
On Friday, October 18, 2002, at 11:28 AM, Satishkumar Ganesan wrote:
> I created two documents under collection /db/Configuration. One with
> namespace and the other without namespace. Xupdate works for the
> document without namespace but doesn't work for document with > namespace
> Document with namespace
> <prA:RunNum xmlns:prA="http://www.partsriver.com/ProAnalyze">
> <prA:currentRun>1</prA:currentRun>
> </prA:RunNum>
>
> XUpdate
> <xu:modifications version="1.0"
> xmlns:xu="http://www.xmldb.org/xupdate">
> <xu:update select=/prA:RunNum/prA:currentRun> 4 </xu:update>
> </xu:modifications>
> The above xupdate didn't work.
From what it looks like, you're just referring to prefixes in the
XUpdate query, which are insufficient as they have no meaning unless
bound to a namespace. So the namespaces have to be declared in the
XUpdate query as well, or possibly as part of a namespace mapping in
the XUpdateQueryService.
--
Tom Bradford - http://www.tbradford.org/
CTO - The dbXML Group - http://www.dbxml.com/
Apache Xindice - http://xml.apache.org/xindice