xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
[XOM-interest] unexpected xpath result with default namespace part 2
- From: T Benjamins <davidbowie2nl AT yahoo.com>
- To: xom-interest AT lists.ibiblio.org
- Subject: [XOM-interest] unexpected xpath result with default namespace part 2
- Date: Sat, 8 Aug 2009 13:35:00 -0700 (PDT)
Hello all,
suppose i have an xml plant_catalog.xml like this:
<CATALOGxmlns="http://www.blabla.nl/namespace"><PLANT><COMMON>Bloodroot</COMMON><BOTANICAL>Sanguinaria
canadensis</BOTANICAL><ZONE>4</ZONE><LIGHT>Mostly
Shady</LIGHT><PRICE>$2.44</PRICE><AVAILABILITY>031599</AVAILABILITY>
</CATALOG>
while running the following code in xom 1.2.1 (depending on jaxen 1.1.2)
i get an empty Nodes object while running the following xpath query.
Builder parser =
Document doc = parser.build(
Element root = doc.getRootElement();
XPathContext con = XPathContext.makeNamespaceContext(root);
Nodes n =root.query(
so it is aware of the namespace applied to the document, but jaxen produces
an empy result.
Is this a bug or not??
when the xml does not contain a default namespace declaration it returns a
list of all the PLANT nodes in the Nodes object with the same code.
greetings Tom newBuilder();"plant_catalog.xml");"//PLANT", con);
</PLANT>....the namespace context object contains an xpath entry for "" =
http://....
>From elharo AT ibiblio.org Sat Aug 8 20:22:32 2009
Return-Path: <elharo AT ibiblio.org>
X-Original-To: xom-interest AT lists.ibiblio.org
Delivered-To: xom-interest AT lists.ibiblio.org
Received: by lists.ibiblio.org (Postfix, from userid 3002)
id 326C34C020; Sat, 8 Aug 2009 20:22:32 -0400 (EDT)
X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on malecky
X-Spam-Level:
X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled
version=3.2.3
Received: from an-out-0708.google.com (an-out-0708.google.com
[209.85.132.249])
by lists.ibiblio.org (Postfix) with ESMTP id D2D154C01E
for <xom-interest AT lists.ibiblio.org>;
Sat, 8 Aug 2009 20:22:31 -0400 (EDT)
Received: by an-out-0708.google.com with SMTP id c2so1197110anc.15
for <xom-interest AT lists.ibiblio.org>;
Sat, 08 Aug 2009 17:22:31 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.100.248.4 with SMTP id v4mr2076623anh.57.1249777351426; Sat,
08 Aug 2009 17:22:31 -0700 (PDT)
In-Reply-To: <664722.10874.qm AT web50906.mail.re2.yahoo.com>
References: <664722.10874.qm AT web50906.mail.re2.yahoo.com>
Date: Sat, 8 Aug 2009 17:22:31 -0700
Message-ID: <654a2bb30908081722r4c5fef51y522ca5e014dd107a AT mail.gmail.com>
From: Elliotte Rusty Harold <elharo AT ibiblio.org>
To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Subject: Re: [XOM-interest] unexpected xpath result with default namespace
part 2
X-BeenThere: xom-interest AT lists.ibiblio.org
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: XOM API for Processing XML with Java
<xom-interest AT lists.ibiblio.org>
List-Id: XOM API for Processing XML with Java <xom-interest.lists.ibiblio.org>
List-Unsubscribe: <http://lists.ibiblio.org/mailman/listinfo/xom-interest>,
<mailto:xom-interest-request AT lists.ibiblio.org?subject=unsubscribe>
List-Archive: <https://lists.ibiblio.org/sympa/arc/xom-interest>
List-Post: <mailto:xom-interest AT lists.ibiblio.org>
List-Help: <mailto:sympa AT lists.ibiblio.org?subject=HELP>
List-Subscribe: <http://lists.ibiblio.org/mailman/listinfo/xom-interest>,
<mailto:xom-interest-request AT lists.ibiblio.org?subject=subscribe>
X-List-Received-Date: Sun, 09 Aug 2009 00:22:32 -0000
You didn't specify your XPath, but remember that in an XPath
expression unqualified names never match any name in a namespace. All
qualified names in an XPath expression MUST be prefixed, regardless of
the what prefix is or is not used in the document you're querying.
--
Elliotte Rusty Harold
elharo AT ibiblio.org
- [XOM-interest] unexpected xpath result with default namespace part 2, T Benjamins, 08/08/2009
Archive powered by MHonArc 2.6.24.