[ https://issues.apache.org/jira/browse/XMLBEANS-467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul Mak updated XMLBEANS-467: ------------------------------ Affects Version/s: Version 2.3 Version 2.2.1 Version 2 Have tried the following versions: Implementation-Version: 2.5.1-r884309 Implementation-Version: 2.2.1-r486413 Implementation-Version: 2.4.0-r670094 Implementation-Version: 2.3.0-r540734 Implementation-Version: 2.2.0-r413705 Implementation-Version: 2.0.0-r191560 > Unable to selectPath() on an element with a specific attribute value > -------------------------------------------------------------------- > > Key: XMLBEANS-467 > URL: https://issues.apache.org/jira/browse/XMLBEANS-467 > Project: XMLBeans > Issue Type: Bug > Components: XPath > Affects Versions: Version 2, Version 2.2, Version 2.2.1, Version 2.3, > Version 2.4 , Version 2.5.1 > Environment: Windows XP/AIX 5.3 > Java 1.6 32-bit on Windows / Java 6 64-bit on AIX > Reporter: Paul Mak > Priority: Minor > > As titled. Here's some sample code: > public static void main(String args[]) { > > XmlObject xml = XmlObject.Factory.newInstance(); > try { > /* > <Sample> > <path1>FirstValue</path1> > <list> > <param > name="number">123456789</param> > <param > name="status">Active</param> > </list> > </Sample> > * */ > xml = > XmlObject.Factory.parse("<Sample><path1>FirstValue</path1><list><param > name=\"number\">123456789</param><param > name=\"status\">Active</param></list></Sample>"); > } > catch (Exception e) {}; > System.out.println("XML = " + xml.xmlText()); > > String cacheXPath1 = "Sample/path1"; > String cacheXPath2 = "Sample/list/param[@name='status']"; > XmlCursor c = xml.newCursor(); > c.selectPath(cacheXPath1); > > String value = ""; > if (c.toNextSelection()) { > value = c.getTextValue(); > } > System.out.println("Value of " + cacheXPath1 + " is " + value); > > value = ""; > c.dispose(); > c = xml.newCursor(); > c.selectPath(cacheXPath2); > if (c.toNextSelection()) { > value = c.getTextValue(); > } > System.out.println("Value of " + cacheXPath2 + " is " + value); > > c.dispose(); > } > The output I get is > Value of Sample/path1 is FirstValue > Exception in thread "main" java.lang.RuntimeException: Trying XBeans path > engine... Trying XQRL... Trying delegated path engine... FAILED on > Sample/list/param[@name='status'] > at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:173) > at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:130) > at org.apache.xmlbeans.impl.store.Cursor._selectPath(Cursor.java:902) > at org.apache.xmlbeans.impl.store.Cursor._selectPath(Cursor.java:894) > at org.apache.xmlbeans.impl.store.Cursor.selectPath(Cursor.java:2616) > at test.Test1.main(Test1.java:49) > So it was not able to find the element <param> that has a value of "Active" > for the "status" attribute. I've tried XMLBeans 2.4 from Apache site, and > also versions 2.2 and 2.5.1 that come with Weblogic Server 10.3.3. Any help > would be appreciated. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org For additional commands, e-mail: dev-h...@xmlbeans.apache.org