Tod,
It seems that you want the 'summary' elements and not their content
(as they may be empty). Drop the "/text()" from the end of your XPath
expression.
Hope this helps.
-- Santiago
On Oct 22, 2009, at 7:53 AM, Tod wrote:
On 10/21/2009 3:34 PM, kesh...@us.ibm.com wrote:
Insufficient data. What does the input document look like and what
is your XPath?
Tod <listac...@gmail.com> wrote on 10/21/2009 02:00:02 PM:
> Tod <listac...@gmail.com>
> 10/21/2009 02:00 PM
>
> To
>
> xalan-j-users@xml.apache.org
>
> cc
>
> Subject
>
> Problem evaluating XPath expression into a NodeList
>
> I have a class that evaluates an XPath expression against an XML
stream
> with multiple namespaces and returns a NodeList. I know by
looking at
> the XML that the node I am retrieving is composed of 20 elements,
called
> '<summary>'. I also know that two of those elements have no
value. The
> relevant code looks like this:
>
>
> XML2Doc xmldoc = new XML2Doc(getXmlFile());
> Document domTree = (Document) xmldoc.getDoc();
> domTree.getDocumentElement().normalize();
> NamespaceResolver myResolver = new NamespaceResolver();
> XObject xObj = XPathAPI.eval(domTree,getXpathExp(),myResolver);
> NodeList = xObj.nodelist();
>
>
>
>
>
> The problem I am running into is that of the 20 <summary>
elements some
> are empty (<summary type="html"></summary>). Upon evaluating the
XPath
> expression the NodeList returned only 18 items event though I
know there
> are twenty. It seems that the elements that weren't valued became
> insignificant as the NodeList was generated.
>
> Is this the correct behavior? I'm expecting my NodeList to have
the
> same number of <summary> elements because I'll be matching them
against
> their related <title> elements during presentation time. Perhaps
there
> is something I need to do in my code to establish the fact that
empty
> elements are significant and should be included in the NodeList? I
> tried removing the normalize() call but that didn't help.
>
> To make things more interesting I am developing this code using JDK
> 1.4.2 because that it is the development environment the customer
is
> using and requires.
>
>
> Thanks - Tod
>
AtomXML - http://tools.ietf.org/html/rfc4287, with a couple of extra
namespace definitions thrown in. On page two of the RFC there is an
example. To demonstrate the problem I'm running into just remove
the string "Some text." from the example XML.
You may be familiar with the XML document format as it is the format
returned by the IBM Omnifind Yahoo! Edition enterprise search.
My XPath expression is:
/default:feed/default:entry/default:summary/text()
Where 'default' is the AtomXML namespace "http://www.w3.org/2005/
Atom".
Thanks - Tod