Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 132 invoked from network); 21 Jun 2007 15:36:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Jun 2007 15:36:00 -0000 Received: (qmail 92023 invoked by uid 500); 21 Jun 2007 15:35:53 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 91990 invoked by uid 500); 21 Jun 2007 15:35:53 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 91950 invoked by uid 99); 21 Jun 2007 15:35:53 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jun 2007 08:35:53 -0700 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: 32.97.110.149 is neither permitted nor denied by domain of qozinx@gmail.com) Received: from [32.97.110.149] (HELO e31.co.us.ibm.com) (32.97.110.149) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jun 2007 08:35:45 -0700 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e31.co.us.ibm.com (8.13.8/8.13.8) with ESMTP id l5LFZKLf022734 for ; Thu, 21 Jun 2007 11:35:20 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v8.3) with ESMTP id l5LFZJ5Y204800 for ; Thu, 21 Jun 2007 09:35:19 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l5LFZJEp004350 for ; Thu, 21 Jun 2007 09:35:19 -0600 Received: from [127.0.0.1] (svl-arbrown.svl.ibm.com [9.30.38.148]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l5LFZFrQ004083 for ; Thu, 21 Jun 2007 09:35:19 -0600 Message-ID: <467A9AB2.6040802@gmail.com> Date: Thu, 21 Jun 2007 08:35:14 -0700 From: Army User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Discussion Subject: Re: Derby XMLQUERY XPATH References: <200706211058.52824.douglas.russell@comlab.ox.ac.uk> In-Reply-To: <200706211058.52824.douglas.russell@comlab.ox.ac.uk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Douglas Russell wrote: > I've got some XML with namespaces and I just can't find a way to set the > namespace in my query. > The XPATH '/' gets all the XML in Definition, that works. If I try and search > for '//Name' however, I get nothing. Presumably this is because Name is > actually in a namespace. How do I construct my XPATH to look for this? I think that in order to get this to work you have to query for "Name" as the *local* name, i.e. search for elements named "Name" in any namespace. One way to do this is with an XPath expression like: //child::*[local-name()="Name"] which should (I think?) return all Name elements. If you want to restrict the Name elements to a specific namespace, then you could do something like: //child::*[local-name()="Name" and namespace::*[string()="http://www.myproject.ox.ac.uk/MyProject"]] I realize this is pretty (very) ugly, but I can't think of any better way at the moment. It is of course very possible that there *is* a better way and I just don't know about it... > I've tried: > '//myns:Name' and that would seem to be correct, but I can find no way of > setting myns to resolve to "http://www.myproject.ox.ac.uk/MyProject" in > Derby. When I do that I just get the error: > > Caused by: org.apache.derby.client.am.SqlException: Encountered error while > evaluating XML query expression for XMLQUERY operator: Prefix must resolve to > a namespace: myns SQLSTATE: XJ001: Java exception: 'Prefix must resolve to a > namespace: myns: org.apache.xpath.domapi.XPathStylesheetDOM3Exception'. This error comes from the underlying Xalan engine, so perhaps you can find a way around this by searching Xalan documentation and/or help files? If it is possible to set namespaces within an XPath query in Xalan, then hopefully it is documented somewhere. And if it is, then feeding that into Derby as part of the query should (hopefully) return the desired results, since Derby ultimately just passes the query on to Xalan for evaluation... Army