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 > > >
<<attachment: winmail.dat>>