How are you created the document in memory? Could you give us some example
code? Maybe its how you're setting the namespaces on the attributes...

James
-------
http://radio.weblogs.com/0112098/
----- Original Message -----
From: "Andreas Wille" <[EMAIL PROTECTED]>
To: "Mike Skells" <[EMAIL PROTECTED]>
Cc: "Dom4j-User@Lists. Sourceforge. Net" <[EMAIL PROTECTED]>
Sent: Thursday, August 29, 2002 9:43 AM
Subject: Re: [dom4j-user] Does XPath consider the namespace of attributes?


> Hi,
>
> you are rigth.
> The problem does only appear when I'm creating a new document in memory
and
> then execute the mentioned XPath query.
> If I read an existing XML document, like your example class b2, everything
> is all right.
>
> So, is this behaviour normal to newly-created documents and if yes, is the
> only alternative solution to store the document and then read it again
> before executing the XPath query ?
>
> --
> Andreas
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: Mike Skells [mailto:[EMAIL PROTECTED]]
> > Gesendet: Mittwoch, 28. August 2002 20:33
> > An: [EMAIL PROTECTED]
> > Cc: Dom4j-User@Lists. Sourceforge. Net
> > Betreff: RE: [dom4j-user] Does XPath consider the namespace of
> > attributes?
> >
> >
> > I cant reproduce the problem
> >
> > --- code ---
> > import org.dom4j.*;
> > import org.dom4j.io.*;
> >
> > public class b2  {
> >
> >     public static void main(java.lang.String[] args) throws  Exception {
> >         new bug();
> >     }
> >     private Document doc ;
> >     public b2() throws Exception{
> >         SAXReader sr = new SAXReader();
> >         Document doc =
sr.read(getClass().getResourceAsStream("b2.xml"));
> >         System.out.println(doc.asXML());
> >
> > System.out.println(doc.selectNodes("//ims:title[@ims:lang='de']"));
> >
> >     }
> > }
> > ---- output -----
> > <?xml version="1.0" encoding="UTF-8"?>
> > <kern xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > xmlns:ims="http://www.imsglobal.org/xsd/imsmd_v1p2";
> > xsi:noNamespaceSchemaLocation="movii-kern.xsd"
> > xsi:schemaLocation="http://www.imsglobal.org/xsd/imsmd_v1p2
> > imsmd_v1p2p2.xsd">
> >     <metadata>
> >         <ims:title ims:lang="de">...</ims:title>
> >     </metadata>
> > </kern>
> > [org.dom4j.tree.DefaultElement@908ca1 [Element: <ims:title uri:
> > http://www.imsglobal.org/xsd/imsmd_v1p2 attributes:
> > [org.dom4j.tree.DefaultAttribute@dd46f7 [Attribute: name ims:lang
> > value "de"]]/>]]
> > -- end ---
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED]] On Behalf Of
> > > Andreas Wille
> > > Sent: Wednesday 28 August 2002 15:24
> > > To: [EMAIL PROTECTED]
> > > Subject: [dom4j-user] Does XPath consider the namespace of attributes?
> > >
> > >
> > > Hello,
> > >
> > > my question is whether XPath does consider the namespace of
> > > attributes or not ?
> > >
> > > for example:
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <kern xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > >       xmlns:ims="http://www.imsglobal.org/xsd/imsmd_v1p2";
> > >       xsi:noNamespaceSchemaLocation="movii-kern.xsd"
> > >
> > > xsi:schemaLocation="http://www.imsglobal.org/xsd/imsmd_v1p2
> > > imsmd_v1p2p2.xsd"> ... <metadata>
> > >     <ims:title ims:lang="de">...</ims:title>
> > > </metadata>
> > > ...
> > > </kern>
> > >
> > > If I start the following XPath query
> > >
> > > rootElement.selectNodes("//ims:title[@ims:lang='de']")
> > >
> > > on the XML document below, I get an empty List.
> > > But if I remove the namespace for the 'lang' attribute in the
> > > document (<ims:title lang="de">...</ims:title>) and in the
> > > XPath query ("//ims:title[@lang='de']") I get the expected
> > > list of elements.
> > >
> > >
> > > Has somebody similar experiences or can tell me what XPath is doing?
> > >
> > > --
> > > Andreas
> > >
> > > --
> > > berlin.de - meine stadt im netz. Jetzt eigene eMail-adresse
> > > @berlin.de sichern! http://webmail.berlin.de
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > This sf.net email is sponsored by: Jabber - The world's
> > > fastest growing
> > > real-time communications platform! Don't just IM. Build it in!
> > > http://www.jabber.com/osdn/xim
> > > _______________________________________________
> > > dom4j-user mailing list
> > > [EMAIL PROTECTED]
> > > https://lists.sourceforge.net/lists/listinfo/d> om4j-user
> > >
> >
>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to