Re: [jxpath] was: [all] Status of components
Hi, I just wanted to express my immense gratitude to Matt Benson for stepping in as the new curator of JXPath. I am happy that it will be in such capable hands. BTW, JXPath does not really have to be dormant. If somebody were interested in taking it further, there are several things that could still be done, e.g. XPath 2.0 conformance, some level of integration with java.xml.xpath, also perhaps some new SPI, which would allow an alternate engine to step in and provide an optimized implementation for some object model (think Jaxen for DOM). Of course, I wanted to do all those things myself, but I have been very busy on other projects lately. Best regards, - Dmitri Plotnikov - Original Message - From: Dion Gillard [EMAIL PROTECTED] To: Jakarta Commons Developers List commons-dev@jakarta.apache.org Sent: Friday, February 09, 2007 12:53 AM Subject: Re: [all] Status of components On 2/7/07, Henri Yandell [EMAIL PROTECTED] wrote: I made a stab of defining the current status for Commons for the Jakarta board report: http://wiki.apache.org/jakarta/JakartaBoardReport-current Here's the summary. Any thoughts on the ?? marks and the dormancy candidates? Feel free to add things to the wiki page. I've not added all of this yet. Attributes - Needs a new release, after that a dormancy candidate. BeanUtils - Inactive. 1.8.0 slowly being worked on. Betwixt - Just released. Chain - ?? CLI - Inactive. Dormancy candidate? Codec - Inactive. Collections - Inactive - new releases discussed but not much movement. Configuration - Active. Daemon - ?? Dormancy candidate? DBCP - 1.2.2 release in the works. DbUtils - 1.1 release made. No plans for 1.2. Digester - ?? Discovery - 0.4 release made, nothing new planned. Dormancy candidate. EL - ?? Dormancy candidate? Email - Maybe a 1.1 release in the works. Not much activity yet. FileUpload - 1.2 release in the works. IO - 1.3 just released. Jelly - ?? Dormancy candidate? Again, little ongoing hard core development, but a little fix work and experimentation happens. Jexl - ?? Dormancy candidate? Jexl gets a little bit of development here and there and has been reasonably stable recently. We keep threatening to start Jexl 2. JXPath - ?? Dormancy candidate? Lang - 2.3 release in the works. Launcher - Inactive. Dormancy candidate. Logging - Needs a 1.1.1 release, no plans beyond that. Math - Slow activity. Modeler - Inactive - dormancy? Net - New JDK 1.5 version in the works. Pool - New version in the works. Primitives - Inactive. Dormancy candidate? SCXML - Active, just released. Transaction - Release being discussed. Validator - Active. VFS - Active and releasing. Dormant - Nothing likely to leave dormancy. Sandbox - Nothing that looks like moving to proper anytime soon. Some for dormancy (finder, id). - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- http://www.multitask.com.au/people/dion/ Rule of Acquisition #91: Hear all, trust nothing. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jxpath] was: [all] Status of components
Matt, I fully agree. As you can see from the thread on JXPATH-61, the discussion was quite heated, so in the end I decided to just let it simmer and neither release nor revert the changes for a while. It's years and no new arguments have been added to the discussion. The prevailing opinion appears to be to keep things as they were in 1.2. Thus we should revert the changes (which are not too extensive anyway). Thank you, - Dmitri - Original Message - From: Matt Benson [EMAIL PROTECTED] To: Jakarta Commons Developers List commons-dev@jakarta.apache.org Sent: Monday, February 19, 2007 2:25 PM Subject: Re: [jxpath] was: [all] Status of components Hi Dmitri... glad to see you got your apache.org mail back working again (saw it on infra@). ;) If you're in the neighborhood for the moment, I'd like to gauge your opinion RE https://issues.apache.org/jira/browse/JXPATH-61 . The final consensus seems to have been that the entire thing should be forgotten, as Elliotte Rusty H so vehemently pushed for, but your final changes were never reverted. Based on my very limited understanding of the issue my personal inclination would have been to take ERH at his word, given the rather large collection of XML-related books he has to his name (I'll acknowledge that's perhaps a lazy attitude, but I have lots of other projects to look at too). Since it has been awhile, I'd like your current thoughts on whether this change should indeed appear in the 1.3 release. :) Thanks, Matt --- Dmitri Plotnikov [EMAIL PROTECTED] wrote: Hi, I just wanted to express my immense gratitude to Matt Benson for stepping in as the new curator of JXPath. I am happy that it will be in such capable hands. BTW, JXPath does not really have to be dormant. If somebody were interested in taking it further, there are several things that could still be done, e.g. XPath 2.0 conformance, some level of integration with java.xml.xpath, also perhaps some new SPI, which would allow an alternate engine to step in and provide an optimized implementation for some object model (think Jaxen for DOM). Of course, I wanted to do all those things myself, but I have been very busy on other projects lately. Best regards, - Dmitri Plotnikov - Original Message - From: Dion Gillard [EMAIL PROTECTED] To: Jakarta Commons Developers List commons-dev@jakarta.apache.org Sent: Friday, February 09, 2007 12:53 AM Subject: Re: [all] Status of components On 2/7/07, Henri Yandell [EMAIL PROTECTED] wrote: I made a stab of defining the current status for Commons for the Jakarta board report: http://wiki.apache.org/jakarta/JakartaBoardReport-current Here's the summary. Any thoughts on the ?? marks and the dormancy candidates? Feel free to add things to the wiki page. I've not added all of this yet. Attributes - Needs a new release, after that a dormancy candidate. BeanUtils - Inactive. 1.8.0 slowly being worked on. Betwixt - Just released. Chain - ?? CLI - Inactive. Dormancy candidate? Codec - Inactive. Collections - Inactive - new releases discussed but not much movement. Configuration - Active. Daemon - ?? Dormancy candidate? DBCP - 1.2.2 release in the works. DbUtils - 1.1 release made. No plans for 1.2. Digester - ?? Discovery - 0.4 release made, nothing new planned. Dormancy candidate. EL - ?? Dormancy candidate? Email - Maybe a 1.1 release in the works. Not much activity yet. FileUpload - 1.2 release in the works. IO - 1.3 just released. Jelly - ?? Dormancy candidate? Again, little ongoing hard core development, but a little fix work and experimentation happens. Jexl - ?? Dormancy candidate? Jexl gets a little bit of development here and there and has been reasonably stable recently. We keep threatening to start Jexl 2. JXPath - ?? Dormancy candidate? Lang - 2.3 release in the works. Launcher - Inactive. Dormancy candidate. Logging - Needs a 1.1.1 release, no plans beyond that. Math - Slow activity. Modeler - Inactive - dormancy? Net - New JDK 1.5 version in the works. Pool - New version in the works. Primitives - Inactive. Dormancy candidate? SCXML - Active, just released. Transaction - Release being discussed. Validator - Active. VFS - Active and releasing. Dormant - Nothing likely to leave dormancy. Sandbox - Nothing that looks like moving to proper anytime soon. Some for dormancy (finder, id). - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- http://www.multitask.com.au/people/dion/ Rule of Acquisition #91: Hear all, trust nothing. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands
Re: [jira] Created: (JXPATH-71) Ponter.asPath() return values not always correct
John, A similar bug was reported and fixed a long time ago. Are you sure this is still an issue with the current build of JXPath? Thank you, - Dmitri - Original Message - From: John Attwood (JIRA) [EMAIL PROTECTED] To: commons-dev@jakarta.apache.org Sent: Monday, October 09, 2006 9:57 AM Subject: [jira] Created: (JXPATH-71) Ponter.asPath() return values not always correct Ponter.asPath() return values not always correct Key: JXPATH-71 URL: http://issues.apache.org/jira/browse/JXPATH-71 Project: Commons JXPath Issue Type: Bug Affects Versions: 1.2 Final Environment: WInXP, Java 1.5, Eclipse 3.2 Reporter: John Attwood String returned by Pointer.asPath() is incorrect when path starts with '//' and target is a collection. The path returned always has a final subscript equal to the size of the collection, although Pointer.getValue() still returns the correct element in each case. Below are two classes and a JUnit testcase which reproduce the bug and isolate it to the case where the path starts with '//' and the target is a collection. I found this problem whilst trying to write the equivalent of XPathExplorer for my JXPath-based object trees. It does't affect the main app, as getValue() always returns the correct node, but in my explorer it only ever highlights the last element in any collection (the objects in my trees aren't always unique so the path is only way to identify them individually and allow the matching nodes to be highlighted). Otherwise an excellent, easy-to-use and really useful package. /// Parent.java // package test; import java.util.ArrayList; public class Parent { private int id; private ArrayListChild kids; public Parent(int id) { this.id = id; this.kids = new ArrayListChild(); } public int getId() { return id; } public ArrayListChild getKids() { return kids; } public void addKid(Child kid) { kids.add(kid); } public void setId(int id) { this.id = id; } public void setKids(ArrayListChild kids) { this.kids = kids; } } /// Child.java / package test; public class Child { private int id; public Child(int id) { this.id = id; } public int getId() { return id; } public void setId(int id) { this.id = id; } } /// TestPointerToPath.java /// package test; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import junit.framework.TestCase; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.Pointer; public class TestPonterToPath extends TestCase { private Parent parent; private SetString expectedPaths, actualPaths; private SetObject actualObjects, expectedObjects; private JXPathContext ctx; private static final int SIZE = 4; public void setUp() { parent = new Parent(1); for (int i = 1; i = SIZE; i++) { parent.addKid(new Child(i)); } expectedPaths = new HashSetString(); expectedObjects = new HashSetObject(); actualPaths = new HashSetString(); actualObjects = new HashSetObject(); ctx = JXPathContext.newContext(parent); } private void doExpected(String path1, String path2) { for (int i = 1; i = SIZE; i++) { Pointer p = ctx.getPointer(path1 + i + path2); expectedPaths.add(p.asPath()); expectedObjects.add(p.getValue()); } assertEquals(SIZE, expectedPaths.size()); assertEquals(SIZE, expectedObjects.size()); } private void doActual(String path) { Iterator it = ctx.iteratePointers(path); while (it.hasNext()) { Pointer p = (Pointer) it.next(); actualPaths.add(p.asPath()); actualObjects.add(p.getValue()); } assertEquals(SIZE, actualObjects.size()); } public void testToPathLeafAbs() { doExpected(/kids[, ]/id); doActual(/kids/id); assertEquals(expectedObjects, actualObjects); assertEquals(expectedPaths, actualPaths); } public void testToPathLeafRel() { doExpected(//kids[, ]/id); doActual(//kids/id); assertEquals(expectedObjects, actualObjects); assertEquals(expectedPaths, actualPaths); } public void testToPathCollectionAbs() { doExpected(/kids[, ]); doActual(/kids); assertEquals(expectedObjects, actualObjects); assertEquals(expectedPaths, actualPaths); } public void testToPathCollectionRel() { doExpected(//kids[, ]); doActual(//kids); assertEquals(expectedObjects, actualObjects); /* next test fails as all actualPaths are /kids[SIZE] */ assertEquals(expectedPaths, actualPaths); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
Re: JXPath query
Mumtaz, I would try companies[department/name='xyz'] Cheers, - Dmitri - Original Message - From: Mumtaz Siddiqui [EMAIL PROTECTED] To: commons-dev@jakarta.apache.org Sent: Thursday, August 17, 2006 8:40 AM Subject: JXPath query Is it possible to get iteration of root obejects for which XPath expression is true instead of having only the iteration of the leaf-objects according the the XPath? e.g. in case of companies/department[name='xyz'] I am interested in companies having departments with name='xyz' mumtaz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JXPath, beans and the count function
Simone, Feel free to try out the proposed change. If it works (and does not break anything else), let me know and I will be happy to incorporate it in the JXPath codebase. Unfortunately, I am currently very busy on several other projects and don't have time to investigate the issue myself. Thank you very much for your help. - Dmitri - Original Message From: Simone Gianni [EMAIL PROTECTED] To: Jakarta Commons Developers List commons-dev@jakarta.apache.org Sent: Friday, July 28, 2006 6:03:29 AM Subject: Re: JXPath, beans and the count function Hi Dmitri, thanks for your answer. We currently made a work around to check ourselves if the path is actually pointing to a collection (invoking the getValue() ) before invoking the evaluation of a count(path). Amyway, we think this could be a bug in JXPath. In fact the count function calls the expression.compute(context) which states in its javadoc Evaluates the expression. If the result is a node set, returns the first element of the node set. .. so IIUC it will never actually return a java.util.Collection. Wouldn't it be better to try to retrieve the simple value before, check if it is a Collection, and if it's not proceed with the rest of the actual code? It's not a suggestion, is a real question :) I've been using JXPath for long time inside cocoon, but never examined the code in depth. Regards, Simone Dmitri Plotnikov wrote: Simone, Perhaps a custom extension function could be used instead of count(list) to resolve the issue. - Dmitri - Original Message - From: Simone Gianni [EMAIL PROTECTED] To: commons-dev@jakarta.apache.org Sent: Thursday, July 27, 2006 1:47 PM Subject: JXPath, beans and the count function Hi there, we are developing paginated repeater for Cocoon. The cocoon repeaters uses JXPath in their binding so that they can work on beans and XML documents. The goal for us is to display a very long list of elements from a collection not fetching the entire content of the collection. This is expecially useful when the collection is backed by a persistence layer like hibernate or similar, and you have a very big rowset (we are testing on an application with a list with 11000 elements in it). Now, one key element for every pagination system is to retrieve the total amount of items in the list. We tried to accomplish this with a count(pathToList). Actually we have a bean having a getList method returning a java.util.List instance, so we try count(list/*) , count(list), count(list/something), and we would expect JXPath to call getList().size(). This is quite critical, because the list implementation knows how to retrieve the number of rows without actually fetching all the rows from the underlying dataset. Unfortunately, what hapens is different. The CoreFunction.functionCount() method does not recognize it as a Collection, but as a EvalContext instead, and iterates on all the lines to count the items (actually is the EvalContext.hasNext() method that iterates on the entire collection). What's strange is that there is a check in CoreFunction.functionCount() to see if a Collection is in place and eventually call the Collection.size() method, but this seems like it's never happening. Could you please help us? Is it a JXPath bug or are we completely missing something? TIA, regards, Simone Gianni, Matthias Epheser - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Simone Gianni - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JXPath, beans and the count function
Simone, Perhaps a custom extension function could be used instead of count(list) to resolve the issue. - Dmitri - Original Message - From: Simone Gianni [EMAIL PROTECTED] To: commons-dev@jakarta.apache.org Sent: Thursday, July 27, 2006 1:47 PM Subject: JXPath, beans and the count function Hi there, we are developing paginated repeater for Cocoon. The cocoon repeaters uses JXPath in their binding so that they can work on beans and XML documents. The goal for us is to display a very long list of elements from a collection not fetching the entire content of the collection. This is expecially useful when the collection is backed by a persistence layer like hibernate or similar, and you have a very big rowset (we are testing on an application with a list with 11000 elements in it). Now, one key element for every pagination system is to retrieve the total amount of items in the list. We tried to accomplish this with a count(pathToList). Actually we have a bean having a getList method returning a java.util.List instance, so we try count(list/*) , count(list), count(list/something), and we would expect JXPath to call getList().size(). This is quite critical, because the list implementation knows how to retrieve the number of rows without actually fetching all the rows from the underlying dataset. Unfortunately, what hapens is different. The CoreFunction.functionCount() method does not recognize it as a Collection, but as a EvalContext instead, and iterates on all the lines to count the items (actually is the EvalContext.hasNext() method that iterates on the entire collection). What's strange is that there is a check in CoreFunction.functionCount() to see if a Collection is in place and eventually call the Collection.size() method, but this seems like it's never happening. Could you please help us? Is it a JXPath bug or are we completely missing something? TIA, regards, Simone Gianni, Matthias Epheser - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r387363 - in /jakarta/commons/proper/jxpath/trunk/src: java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java
Author: dmitri Date: Mon Mar 20 16:48:07 2006 New Revision: 387363 URL: http://svn.apache.org/viewcvs?rev=387363view=rev Log: Fixed a problem caused by from index greater than the string s length. Thanks to Barzilai Spinak Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java?rev=387363r1=387362r2=387363view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java Mon Mar 20 16:48:07 2006 @@ -473,6 +473,9 @@ } from = Math.round(from); +if (from s1.length() + 1) { +return ; +} if (ac == 2) { if (from 1) { from = 1; Modified: jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java?rev=387363r1=387362r2=387363view=diff == --- jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java Mon Mar 20 16:48:07 2006 @@ -82,6 +82,9 @@ assertXPathValue(context, substring('12345', 1, 0 div 0), ); assertXPathValue(context, substring('12345', -42, 1 div 0), 12345); assertXPathValue(context, substring('12345', -1 div 0, 1 div 0), ); +assertXPathValue(context, substring('12345', 6, 6), ); +assertXPathValue(context, substring('12345', 7, 8), ); +assertXPathValue(context, substring('12345', 7), ); assertXPathValue(context, string-length('12345'), new Double(5)); assertXPathValue(context, normalize-space(' abc def '), abc def); assertXPathValue(context, normalize-space('abc def'), abc def); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r330424 - in /jakarta/commons/proper/jxpath/trunk: build.xml project.xml src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java
Author: dmitri Date: Wed Nov 2 19:10:30 2005 New Revision: 330424 URL: http://svn.apache.org/viewcvs?rev=330424view=rev Log: Upgraded to JDOM 1.0 Modified: jakarta/commons/proper/jxpath/trunk/build.xml jakarta/commons/proper/jxpath/trunk/project.xml jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java Modified: jakarta/commons/proper/jxpath/trunk/build.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/build.xml?rev=330424r1=330423r2=330424view=diff == --- jakarta/commons/proper/jxpath/trunk/build.xml (original) +++ jakarta/commons/proper/jxpath/trunk/build.xml Wed Nov 2 19:10:30 2005 @@ -161,7 +161,7 @@ /get get dest=${libdir}/xml-apis-2.0.2.jar usetimestamp=true ignoreerrors=true src=http://www.ibiblio.org/maven/xml-apis/jars/xml-apis-2.0.2.jar; /get -get dest=${libdir}/jdom-b9.jar usetimestamp=true ignoreerrors=true src=http://www.ibiblio.org/maven/jdom/jars/jdom-b9.jar; +get dest=${libdir}/jdom-1.0.jar usetimestamp=true ignoreerrors=true src=http://www.ibiblio.org/maven/jdom/jars/jdom-1.0.jar; /get get dest=${libdir}/commons-beanutils-1.4.jar usetimestamp=true ignoreerrors=true src=http://www.ibiblio.org/maven/commons-beanutils/jars/commons-beanutils-1.4.jar; /get Modified: jakarta/commons/proper/jxpath/trunk/project.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/project.xml?rev=330424r1=330423r2=330424view=diff == --- jakarta/commons/proper/jxpath/trunk/project.xml (original) +++ jakarta/commons/proper/jxpath/trunk/project.xml Wed Nov 2 19:10:30 2005 @@ -114,7 +114,7 @@ /dependency dependency idjdom/id - versionb9/version + version1.0/version urlhttp://www.jdom.org/url /dependency dependency Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java?rev=330424r1=330423r2=330424view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java Wed Nov 2 19:10:30 2005 @@ -668,11 +668,17 @@ } private int getRelativePositionOfElement() { -Element parent = (Element) ((Element) node).getParent(); +Object parent = ((Element) node).getParent(); if (parent == null) { return 1; } -List children = parent.getContent(); +List children; +if (parent instanceof Element) { +children = ((Element) parent).getContent(); +} +else { +children = ((Document) parent).getContent(); +} int count = 0; for (int i = 0; i children.size(); i++) { Object child = children.get(i); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r329964 - in /jakarta/commons/proper/jxpath/trunk/src: java/org/apache/commons/jxpath/ java/org/apache/commons/jxpath/ri/ java/org/apache/commons/jxpath/ri/axes/ java/org/apache/commons/jx
Author: dmitri Date: Mon Oct 31 19:25:32 2005 New Revision: 329964 URL: http://svn.apache.org/viewcvs?rev=329964view=rev Log: Another attempt at closing bug 32360. See http://issues.apache.org/bugzilla/show_bug.cgi?id=32360 Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodeIterator.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodeIterator.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/Vendor.xml jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java?rev=329964r1=329963r2=329964view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java Mon Oct 31 19:25:32 2005 @@ -862,32 +862,29 @@ } /** - * If true, default namespace declarations in XML are ignored. Thus, if you - * have this XML: + * Binds a namespace URI for XPath QNames that are missing the prefix. + * If you have this XML: * pre * lt;a xmlns=mynsgt; * lt;bgt;109lt;/bgt; * lt;/agt; - * /pos - * you can use the path /a/b to retrieve the contents of the nested element. - * p - * If false (default), you have to do the default thing, which is this: + * /pre + * and * pre - * context.registerNamespace(ns, myns); - * context.getValue(/ns:a/ns:b); + * context.setDefaultNamespaceURI(myns); * /pre - */ -public boolean isDefaultNamespaceIgnored() { -return false; -} - - -/** - * Changing this flag to true makes jxpath forgive missing default namespace specification. - * @see #isDefaultNamespaceIgnored(boolean) - */ -public void setDefaultNamespaceIgnored(boolean flag) { + * you can use the path /a/b instead of /foo:a/foo:b (the assumption + * here is that the prefix foo is bound to myns by calling + * registerNamespace). + */ +public void registerDefaultNamespace(String uri) { throw new UnsupportedOperationException( Namespace registration is not implemented by + getClass()); } + +/** +*/ +public String getDefaultNamespaceURI() { +return null; +} } Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java?rev=329964r1=329963r2=329964view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java Mon Oct 31 19:25:32 2005 @@ -112,7 +112,7 @@ private Pointer contextPointer; protected NamespaceResolver namespaceResolver; -private boolean defaultNamespaceIgnored; +private String defaultNamespaceURI; // The frequency of the cache cleanup private static final int CLEANUP_THRESHOLD = 500; @@ -683,23 +683,23 @@ public NamespaceResolver getNamespaceResolver() { namespaceResolver.seal(); - namespaceResolver.setDefaultNamespaceIgnored(isDefaultNamespaceIgnored()); + namespaceResolver.registerDefaultNamespaceURI(getDefaultNamespaceURI()); return namespaceResolver; } -public boolean isDefaultNamespaceIgnored() { -if (defaultNamespaceIgnored) { -return true; +public String getDefaultNamespaceURI() { +if (defaultNamespaceURI != null) { +return
svn commit: r329444 - /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/parser/XPath.jj
Author: dmitri Date: Sat Oct 29 09:54:45 2005 New Revision: 329444 URL: http://svn.apache.org/viewcvs?rev=329444view=rev Log: Updated license with permission of Gerald Huck Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/parser/XPath.jj Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/parser/XPath.jj URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/parser/XPath.jj?rev=329444r1=329443r2=329444view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/parser/XPath.jj (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/parser/XPath.jj Sat Oct 29 09:54:45 2005 @@ -1,13 +1,18 @@ /* -JavaCC Grammar for XSLT/XPath expressions (http://www.w3.org/TR/xpath) -Authors: Ingo Macherius, Gerald Huck {macherius, [EMAIL PROTECTED] -Refactoring and actions: Dmitri Plotnikov -Version: 0.02 -(c) 1999 GMD -(c) 2001 PLOTNIX, Inc -No warranties, use at your own risk. -*/ - + * Copyright 1999-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* JavaCC 1.1 Options - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r329468 - in /jakarta/commons/proper/jxpath/trunk/src: java/org/apache/commons/jxpath/ java/org/apache/commons/jxpath/ri/ java/org/apache/commons/jxpath/ri/axes/ java/org/apache/commons/jx
Author: dmitri Date: Sat Oct 29 12:02:38 2005 New Revision: 329468 URL: http://svn.apache.org/viewcvs?rev=329468view=rev Log: Fixes for bug 32360. Please follow discussions at: http://issues.apache.org/bugzilla/show_bug.cgi?id=32360 Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/RootContext.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodeIterator.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodeIterator.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java?rev=329468r1=329467r2=329468view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java Sat Oct 29 12:02:38 2005 @@ -860,4 +860,34 @@ throw new UnsupportedOperationException( Namespace registration is not implemented by + getClass()); } + +/** + * If true, default namespace declarations in XML are ignored. Thus, if you + * have this XML: + * pre + * lt;a xmlns=mynsgt; + * lt;bgt;109lt;/bgt; + * lt;/agt; + * /pos + * you can use the path /a/b to retrieve the contents of the nested element. + * p + * If false (default), you have to do the default thing, which is this: + * pre + * context.registerNamespace(ns, myns); + * context.getValue(/ns:a/ns:b); + * /pre + */ +public boolean isDefaultNamespaceIgnored() { +return false; +} + + +/** + * Changing this flag to true makes jxpath forgive missing default namespace specification. + * @see #isDefaultNamespaceIgnored(boolean) + */ +public void setDefaultNamespaceIgnored(boolean flag) { +throw new UnsupportedOperationException( +Namespace registration is not implemented by + getClass()); +} } Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java?rev=329468r1=329467r2=329468view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java Sat Oct 29 12:02:38 2005 @@ -108,6 +108,7 @@ private Pointer contextPointer; protected NamespaceResolver namespaceResolver; +private boolean defaultNamespaceIgnored; // The frequency of the cache cleanup private static final int CLEANUP_THRESHOLD = 500; @@ -674,9 +675,25 @@ public NamespaceResolver getNamespaceResolver() { namespaceResolver.seal(); + namespaceResolver.setDefaultNamespaceIgnored(isDefaultNamespaceIgnored()); return namespaceResolver; } +public boolean isDefaultNamespaceIgnored() { +if (defaultNamespaceIgnored) { +return true; +} +if (parentContext != null) { +return parentContext.isDefaultNamespaceIgnored(); +} + +return false; +} + +public void setDefaultNamespaceIgnored(boolean flag) { +defaultNamespaceIgnored = flag; +} + /** * Checks if existenceCheckClass exists on the class path. If so, allocates * an instance of the specified class, otherwise returns null. Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java?rev=329468r1=329467r2=329468view=diff == --- jakarta/commons/proper
svn commit: r329470 - /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java
Author: dmitri Date: Sat Oct 29 12:11:37 2005 New Revision: 329470 URL: http://svn.apache.org/viewcvs?rev=329470view=rev Log: Fixed a synchronization issue described in this bug report: http://issues.apache.org/bugzilla/show_bug.cgi?id=34552 Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java?rev=329470r1=329469r2=329470view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java Sat Oct 29 12:11:37 2005 @@ -80,14 +80,15 @@ bi = Introspector.getBeanInfo(clazz, Object.class); } PropertyDescriptor[] pds = bi.getPropertyDescriptors(); -propertyDescriptors = new PropertyDescriptor[pds.length]; -System.arraycopy(pds, 0, propertyDescriptors, 0, pds.length); -Arrays.sort(propertyDescriptors, new Comparator() { +PropertyDescriptor[] descriptors = new PropertyDescriptor[pds.length]; +System.arraycopy(pds, 0, descriptors, 0, pds.length); +Arrays.sort(descriptors, new Comparator() { public int compare(Object left, Object right) { return ((PropertyDescriptor) left).getName().compareTo( ((PropertyDescriptor) right).getName()); } }); +propertyDescriptors = descriptors; } catch (IntrospectionException ex) { ex.printStackTrace(); @@ -99,10 +100,11 @@ public PropertyDescriptor getPropertyDescriptor(String propertyName) { if (propertyNames == null) { PropertyDescriptor[] pds = getPropertyDescriptors(); -propertyNames = new String[pds.length]; +String[] names = new String[pds.length]; for (int i = 0; i pds.length; i++) { -propertyNames[i] = pds[i].getName(); +names[i] = pds[i].getName(); } +propertyNames = names; } for (int i = 0; i propertyNames.length; i++) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r329481 - in /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath: ./ functions/ ri/ ri/axes/ ri/compiler/ ri/model/ ri/model/beans/ ri/model/dom/ ri/model/dynabeans/ ri
Author: dmitri Date: Sat Oct 29 14:07:19 2005 New Revision: 329481 URL: http://svn.apache.org/viewcvs?rev=329481view=rev Log: Introduced specialized exceptions Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathException.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/functions/ConstructorFunction.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/functions/MethodFunction.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/Parser.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExtensionFunction.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/VariablePointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPropertyPointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPropertyPointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPropertyPointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathException.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathException.java?rev=329481r1=329480r2=329481view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathException.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathException.java Sat Oct 29 14:07:19 2005 @@ -23,7 +23,8 @@ */ public class JXPathException extends RuntimeException { - +private static final long serialVersionUID = 4306409701468017766L; + /** @serial */ private Throwable exception; @@ -116,4 +117,12 @@ public Throwable getException() { return exception; } + +/** + * Same as [EMAIL PROTECTED] #getException() getException()} + */ +public Throwable getCause() { +return exception; +} + } Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/functions/ConstructorFunction.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/functions/ConstructorFunction.java?rev=329481r1=329480r2=329481view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/functions/ConstructorFunction.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/functions/ConstructorFunction.java Sat Oct 29 14:07:19 2005 @@ -20,7 +20,7 @@ import org.apache.commons.jxpath.ExpressionContext; import org.apache.commons.jxpath.Function; -import org.apache.commons.jxpath.JXPathException; +import org.apache.commons.jxpath.JXPathInvalidAccessException; import org.apache.commons.jxpath.util.TypeUtils; /** @@ -66,7 +66,7 @@ if (ex instanceof InvocationTargetException) { ex = ((InvocationTargetException) ex).getTargetException(); } -throw new JXPathException( +throw new JXPathInvalidAccessException( Cannot invoke constructor + constructor, ex); } Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/functions/MethodFunction.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/functions/MethodFunction.java?rev=329481r1=329480r2=329481view=diff == --- jakarta/commons/proper/jxpath/trunk
svn commit: r329482 - /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/
Author: dmitri Date: Sat Oct 29 14:08:36 2005 New Revision: 329482 URL: http://svn.apache.org/viewcvs?rev=329482view=rev Log: Introduced specialized exceptions Added: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathAbstractFactoryException.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathFunctionNotFoundException.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathInvalidAccessException.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathInvalidSyntaxException.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathNotFoundException.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathTypeConversionException.java Added: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathAbstractFactoryException.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathAbstractFactoryException.java?rev=329482view=auto == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathAbstractFactoryException.java (added) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathAbstractFactoryException.java Sat Oct 29 14:08:36 2005 @@ -0,0 +1,33 @@ +/* + * Copyright 1999-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.jxpath; + +/** + * Thrown when an AbstractFactory cannot generate an object for the requested + * path. + * + * @author Dmitri Plotnikov + * @version $Revision: 155422 $ $Date: 2005-02-26 08:07:46 -0500 (Sat, 26 Feb 2005) $ + */ + +public class JXPathAbstractFactoryException extends JXPathException { + +private static final long serialVersionUID = -4403564377958943239L; + +public JXPathAbstractFactoryException(String message) { +super(message); +} +} \ No newline at end of file Added: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathFunctionNotFoundException.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathFunctionNotFoundException.java?rev=329482view=auto == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathFunctionNotFoundException.java (added) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathFunctionNotFoundException.java Sat Oct 29 14:08:36 2005 @@ -0,0 +1,32 @@ +/* + * Copyright 1999-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.jxpath; + +/** + * Thrown when JXPath encounters an unknown extension function. + * + * @author Dmitri Plotnikov + * @version $Revision: 155422 $ $Date: 2005-02-26 08:07:46 -0500 (Sat, 26 Feb 2005) $ + */ + +public class JXPathFunctionNotFoundException extends JXPathException { + +private static final long serialVersionUID = -8875537628056117241L; + +public JXPathFunctionNotFoundException(String message) { +super(message); +} +} \ No newline at end of file Added: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathInvalidAccessException.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathInvalidAccessException.java?rev=329482view=auto == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathInvalidAccessException.java (added) +++ jakarta/commons/proper/jxpath/trunk/src/java
svn commit: r329488 - /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
Author: dmitri Date: Sat Oct 29 14:55:53 2005 New Revision: 329488 URL: http://svn.apache.org/viewcvs?rev=329488view=rev Log: Fixed a problem that lead to paths with empty prefixes Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java?rev=329488r1=329487r2=329488view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java Sat Oct 29 14:55:53 2005 @@ -96,8 +96,11 @@ if (ni != null) { for (int position = 1; ni.setPosition(position); position++) { NodePointer nsPointer = ni.getNodePointer(); -reverseMap.put(nsPointer.getNamespaceURI(), -nsPointer.getName().getName()); +String uri = nsPointer.getNamespaceURI(); +String prefix = nsPointer.getName().getName(); +if (!.equals(prefix)) { +reverseMap.put(uri, prefix); +} } } Iterator it = namespaceMap.entrySet().iterator(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r329489 - /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java
Author: dmitri Date: Sat Oct 29 14:56:46 2005 New Revision: 329489 URL: http://svn.apache.org/viewcvs?rev=329489view=rev Log: Fixed bug 35911, with broke function last() in some cases http://issues.apache.org/bugzilla/show_bug.cgi?id=35911 Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java?rev=329489r1=329488r2=329489view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java Sat Oct 29 14:56:46 2005 @@ -164,6 +164,7 @@ public void reset() { super.reset(); +parentContext.reset(); done = false; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r329513 - in /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri: axes/UnionContext.java compiler/ExpressionPath.java compiler/Path.java
Author: dmitri Date: Sat Oct 29 20:07:12 2005 New Revision: 329513 URL: http://svn.apache.org/viewcvs?rev=329513view=rev Log: Corrected behavior of chained predicates. Each predicate is supposed to form its own node set. Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExpressionPath.java jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java?rev=329513r1=329512r2=329513view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java Sat Oct 29 20:07:12 2005 @@ -29,7 +29,6 @@ * @version $Revision$ $Date$ */ public class UnionContext extends NodeSetContext { -private boolean startedSet = false; private EvalContext contexts[]; private boolean prepared = false; Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExpressionPath.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExpressionPath.java?rev=329513r1=329512r2=329513view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExpressionPath.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExpressionPath.java Sat Oct 29 20:07:12 2005 @@ -15,6 +15,7 @@ */ package org.apache.commons.jxpath.ri.compiler; +import org.apache.commons.jxpath.BasicNodeSet; import org.apache.commons.jxpath.ri.EvalContext; import org.apache.commons.jxpath.ri.axes.InitialContext; import org.apache.commons.jxpath.ri.axes.NodeSetContext; @@ -173,6 +174,9 @@ } if (predicates != null) { for (int j = 0; j predicates.length; j++) { +if (j != 0) { +context = new UnionContext(context, new EvalContext[]{context}); +} context = new PredicateContext(context, predicates[j]); } } Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java?rev=329513r1=329512r2=329513view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java Sat Oct 29 20:07:12 2005 @@ -30,6 +30,7 @@ import org.apache.commons.jxpath.ri.axes.PredicateContext; import org.apache.commons.jxpath.ri.axes.SelfContext; import org.apache.commons.jxpath.ri.axes.SimplePathInterpreter; +import org.apache.commons.jxpath.ri.axes.UnionContext; import org.apache.commons.jxpath.ri.model.NodePointer; /** @@ -238,6 +239,9 @@ Expression predicates[] = steps[i].getPredicates(); if (predicates != null) { for (int j = 0; j predicates.length; j++) { +if (j != 0) { +context = new UnionContext(context, new EvalContext[]{context}); +} context = new PredicateContext(context, predicates[j]); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r329518 - /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPropertyPointer.java
Author: dmitri Date: Sat Oct 29 21:35:50 2005 New Revision: 329518 URL: http://svn.apache.org/viewcvs?rev=329518view=rev Log: Fixed bug 37299. Atomic values should declare that they have 0 properties. http://issues.apache.org/bugzilla/show_bug.cgi?id=37299 Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPropertyPointer.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPropertyPointer.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPropertyPointer.java?rev=329518r1=329517r2=329518view=diff == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPropertyPointer.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPropertyPointer.java Sat Oct 29 21:35:50 2005 @@ -40,7 +40,6 @@ private Object baseValue = UNINITIALIZED; private Object value = UNINITIALIZED; -private static final int UNKNOWN_LENGTH_MAX_COUNT = 1; public BeanPropertyPointer(NodePointer parent, JXPathBeanInfo beanInfo) { super(parent); @@ -58,6 +57,9 @@ * Number of the bean's properties. */ public int getPropertyCount() { +if (beanInfo.isAtomic()) { +return 0; +} return getPropertyDescriptors().length; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Extending Apache Commons Functor
Hello! I want to extend Apache Commons Functor by some additional functionality, which is described at the URL below. http://dapissarenko.com/resources/2005_09_18_apacheFunctor/ What can I do in order for these functionalities to be included in the Apache Commons Functor library? TIA Dmitri Pissarenko -- Dmitri Pissarenko Software Engineer http://dapissarenko.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Extending Apache Commons Functor
Hello! Some of that stuff looks like it would be better suited for Commons Collections rather than Commons Functor, since it's merely dealing with Iterators (especially the reverse method). OK, you are probably right. But the question remains: what should I to put these routines into Apache Commons Collections? TIA Dmitri Pissarenko -- Dmitri Pissarenko Software Engineer http://dapissarenko.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jxpath] Feature-Request: JXPathIntrospector and Thread Context Classloader
Stephan, Great proposal. I'll be happy to make the change. - Dmitri --- Stephan Markwalder [EMAIL PROTECTED] wrote: Dear JXPath Develpers, I have a feature request for JXPathIntrospector regardings its strategy to find/load ...XBeanInfo classes: Currenty, JXPathIntrospector tries to load the bean info (e.g. ClientRelationshipXBeanInfo) classes through the classloader defining the bean class (e.g. ClientRelationship) or through the classloader defining JXPathIntrospector itself. By the way: the source code comments in JXPathIntrospector state that the bootstrap or system classloader is used, which is wrong. As far as I know, Class.forName(...) uses the caller's classloader which is JXPathIntrospector.class.getClassloader(). I think it would be nice to try the current thread's context classloader as well. Argument 1: This would allow us to place the JXPath library into the lib/ext directory of the JRE, the bean classes into a common jar archive (for instance together with my J2EE beans) and the bean info classe into the WEB-INF/classes directory of my web application. Argument 2: The J2EE specification states, that J2EE 1.3 containers must provide a per thread context classloader which can be used by system or library classes (like JXPath) to load custom application classes. So, if the containers support this feature, why not using it? Argument 3: The class java.beans.Introspector is implementing this startegy as well. But ... Perhaps there is a reason why this is not implemented until today. As far as I can see it, Digester is also not using the current thread's context classloader but instead allows to set the classloader explicitly by calling digester.setClassloader(...). Is there a drawback in using the context classloader? In the meantime, we do not use bean info objects but register DynamicPropertyHandlers in JXPathIntrospector. Regards, Stephan -- Stephan Markwalder, Numcom Software AG Hardturmstrasse 66, CH-8005 Zürich Tel +41 (0)43 204 06 08, Direct +41 (0)43 204 06 03 Fax +41 (0)43 204 06 09, Mobile +41 (0)79 349 66 40 mailto:[EMAIL PROTECTED], http://www.numcom.ch - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jxpath ?
Ricardo, Very good questions. Do you believe such integration would be useful? The JAXP 1.3 spec allows for non-DOM object models to be supported, so I don't see a technical reason why we could not integrate JXPath with it. Do you see JXPath adding a compatibility module to map JAXP 1.3 APIs to JXPath APIs? Or, alternatively, should JXPath itself morph to adapt to the JAXP APIs. If we did that, would we preserve compatibility with JXPath 1.2, or go straight to JXPath 2? Or, better, skip a version and go to JXPath 3.0 to avoid confusion with XPath 2? Thank you, - Dmitri - Original Message - From: Ricardo [EMAIL PROTECTED] To: commons-dev@jakarta.apache.org Sent: Tuesday, June 14, 2005 11:52 AM Subject: jxpath ? hi, is this project dead? no need for integration with jaxp1.3? ciao ricky - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JXPath cycles
Elliotte, While traversing the graph of model objects, JXPath maintains a trace of nodes it's visited. If it encouters a node that has already been visited, it simply skips it. That's how it avoids the infinite loop in a situation like the one you are describing. I hope this helps, - Dmitri - Original Message - From: Elliotte Harold [EMAIL PROTECTED] To: commons-dev@jakarta.apache.org Sent: Wednesday, May 04, 2005 9:05 AM Subject: JXPath cycles How does Commons JXPath handle cycles when querying JavaBeans? For instance suppose bean A has a property X whose value is a reference to bean B. Suppose also bean B has a property Y whose value is a reference to bean A. Then suppose, starting with bean A as the context node, we make the query .//*. What happens and why? Is it an infinite loop? This is a simple case, but clearly the cycle could be longer than length 2. -- Elliotte Rusty Harold [EMAIL PROTECTED] XML in a Nutshell 3rd Edition Just Published! http://www.cafeconleche.org/books/xian3/ http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r158299 - in jakarta/commons/proper/jxpath/trunk/src: java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java test/org/apache/commons/jxpath/ri/model/MixedModelTest.java
Author: dmitri Date: Sat Mar 19 20:25:13 2005 New Revision: 158299 URL: http://svn.apache.org/viewcvs?view=revrev=158299 Log: Fixed Scott Heaberlin's StackOverflow bug. Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/MixedModelTest.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java?view=diffr1=158298r2=158299 == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java Sat Mar 19 20:25:13 2005 @@ -19,8 +19,11 @@ import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathIntrospector; +import org.apache.commons.jxpath.ri.Compiler; import org.apache.commons.jxpath.ri.QName; +import org.apache.commons.jxpath.ri.compiler.NodeNameTest; import org.apache.commons.jxpath.ri.compiler.NodeTest; +import org.apache.commons.jxpath.ri.compiler.NodeTypeTest; import org.apache.commons.jxpath.ri.model.NodeIterator; import org.apache.commons.jxpath.ri.model.NodePointer; import org.apache.commons.jxpath.util.ValueUtils; @@ -196,10 +199,22 @@ return getValuePointer().namespacePointer(namespace); } -public boolean testNode(NodeTest nodeTest) { -//if (index -/** @todo: infinite loop here */ -return getValuePointer().testNode(nodeTest); +public boolean testNode(NodeTest test) { +if (index == WHOLE_COLLECTION) { +if (test == null) { +return true; +} +else if (test instanceof NodeNameTest) { +return false; +} +else if (test instanceof NodeTypeTest) { +if (((NodeTypeTest) test).getNodeType() == Compiler.NODE_TYPE_NODE) { +return true; +} +} +return false; +} +return getValuePointer().testNode(test); } public int compareChildNodePointers( Modified: jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/MixedModelTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/MixedModelTest.java?view=diffr1=158298r2=158299 == --- jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/MixedModelTest.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/model/MixedModelTest.java Sat Mar 19 20:25:13 2005 @@ -529,4 +529,35 @@ new Integer(4), /matrix[1]/.[1]); } + +/** + * Scott Heaberlin's test - collection of collections + */ +public void testCollectionPointer() { +List list = new ArrayList(); +Map map = new HashMap(); +map.put(KeyOne, SomeStringOne); +map.put(KeyTwo, SomeStringTwo); + +Map map2 = new HashMap(); +map2.put(KeyA, StringA); +map2.put(KeyB, StringB); + +map.put(KeyThree, map2); +list.add(map); + +List list2 = new ArrayList(); +list2.add(foo); +list2.add(map); +list2.add(map); +list.add(list2); + +context = JXPathContext.newContext(list); + +assertEquals(SomeStringOne, context.getValue(.[1]/KeyOne)); +assertEquals(StringA, context.getValue(.[1]/KeyThree/KeyA)); +assertEquals(new Integer(3), context.getValue(size(.[1]/KeyThree))); +assertEquals(new Double(6.0), context.getValue(count(.[1]/KeyThree/*))); +assertEquals(new Double(3.0), context.getValue(count(.[1]/KeyThree/KeyA))); +} } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r158012 - jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java
Author: dmitri Date: Thu Mar 17 19:03:32 2005 New Revision: 158012 URL: http://svn.apache.org/viewcvs?view=revrev=158012 Log: Correctly re-applied Vasiliy Stashuk's patch. Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java?view=diffr1=158011r2=158012 == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java Thu Mar 17 19:03:32 2005 @@ -549,18 +549,29 @@ // If the declaring class is public, we are done Class clazz = method.getDeclaringClass(); -while (clazz != null) { -if (Modifier.isPublic(clazz.getModifiers())) { -return (method); -} +if (Modifier.isPublic(clazz.getModifiers())) { +return (method); +} +String name = method.getName(); +Class[] parameterTypes = method.getParameterTypes(); +while (clazz != null) { // Check the implemented interfaces and subinterfaces Method aMethod = getAccessibleMethodFromInterfaceNest(clazz, -method.getName(), method.getParameterTypes()); +name, parameterTypes); if (aMethod != null) { return aMethod; } + clazz = clazz.getSuperclass(); +if (Modifier.isPublic(clazz.getModifiers())) { +try { +return clazz.getDeclaredMethod(name, parameterTypes); +} +catch (NoSuchMethodException e) { +; +} +} } return null; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r158013 - jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java
Author: dmitri Date: Thu Mar 17 19:08:39 2005 New Revision: 158013 URL: http://svn.apache.org/viewcvs?view=revrev=158013 Log: Correctly re-applied Vasiliy Stashuk's patch. Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java?view=diffr1=158012r2=158013 == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java Thu Mar 17 19:08:39 2005 @@ -564,7 +564,7 @@ } clazz = clazz.getSuperclass(); -if (Modifier.isPublic(clazz.getModifiers())) { +if (clazz != null Modifier.isPublic(clazz.getModifiers())) { try { return clazz.getDeclaredMethod(name, parameterTypes); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r157432 - jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java
Author: dmitri Date: Mon Mar 14 08:31:14 2005 New Revision: 157432 URL: http://svn.apache.org/viewcvs?view=revrev=157432 Log: Applied Vasiliy Stashuk's patch. Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java?view=diffr1=157431r2=157432 == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java Mon Mar 14 08:31:14 2005 @@ -549,11 +549,11 @@ // If the declaring class is public, we are done Class clazz = method.getDeclaringClass(); -if (Modifier.isPublic(clazz.getModifiers())) { -return (method); -} - while (clazz != null) { +if (Modifier.isPublic(clazz.getModifiers())) { +return (method); +} + // Check the implemented interfaces and subinterfaces Method aMethod = getAccessibleMethodFromInterfaceNest(clazz, method.getName(), method.getParameterTypes()); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r156386 - jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java
Author: dmitri Date: Sun Mar 6 19:50:06 2005 New Revision: 156386 URL: http://svn.apache.org/viewcvs?view=revrev=156386 Log: Fixed bug 33377. See http://issues.apache.org/bugzilla/show_bug.cgi?id=33377 Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java?view=diffr1=156385r2=156386 == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java Sun Mar 6 19:50:06 2005 @@ -125,7 +125,7 @@ */ public NodePointer getImmediateValuePointer() { return NodePointer.newChildNodePointer( -this, +(NodePointer) this.clone(), getName(), getImmediateNode()); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jxpath] org.apache.commons.jxpath.JXPathException: no read method
Vasiliy, You need to change the visibility of class B from default to public. JXPath only supports access to public classes. Let me know if this helps. - Dmitri Vasiliy Stashuk [EMAIL PROTECTED] wrote: Hi! I have problem while accessing java bean properties via JXPath. Consider following example. puvlic class BlaBla { public static interface Provider { public String getName(); } public static abstract class A implements Provider { } static class B extends A { public String getName() { return theName; } } public static void main(String[] args) throws Exception { B b = new B(); JXPathContext ctx = JXPathContext.newContext(b); System.out.println(ctx.getValue(name)); } } JXPath fails with: org.apache.commons.jxpath.JXPathException: Cannot access property: BlaBla$B.name; No read method This is may be a bug in the ValueUtils.getAccessibleMethodFromInterfaceNest method. It doesn't get down thru class hierarchy when looking for public accessor method. -- All the best, Vasyl Stashuk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jxpath] org.apache.commons.jxpath.JXPathException: no read method
Vasiliy, Very good point. I will commit a fix to getAccessibleMethodFromInterfaceNest tonight. Thank you very much for pointing this out. - Dmitri Vasiliy Stashuk [EMAIL PROTECTED] wrote: Making B public will help. But what if I'm using anonymous class instead of B, like this: JXPathContext ctx = JXPathContext.newContext(new A() { public String getName() { return theName; } }); ? Thanks for the help. On Fri, 04 Mar 2005 16:40:55 +0200, Dmitri Plotnikov wrote: Vasiliy, You need to change the visibility of class B from default to public. JXPath only supports access to public classes. Let me know if this helps. - Dmitri Vasiliy Stashuk wrote: Hi! I have problem while accessing java bean properties via JXPath. Consider following example. puvlic class BlaBla { public static interface Provider { public String getName(); } public static abstract class A implements Provider { } static class B extends A { public String getName() { return theName; } } public static void main(String[] args) throws Exception { B b = new B(); JXPathContext ctx = JXPathContext.newContext(b); System.out.println(ctx.getValue(name)); } } JXPath fails with: org.apache.commons.jxpath.JXPathException: Cannot access property: BlaBla$B.name; No read method This is may be a bug in the ValueUtils.getAccessibleMethodFromInterfaceNest method. It doesn't get down thru class hierarchy when looking for public accessor method. -- All the best, Vasyl Stashuk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r156189 - jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java
Author: dmitri Date: Fri Mar 4 09:51:50 2005 New Revision: 156189 URL: http://svn.apache.org/viewcvs?view=revrev=156189 Log: Made getAccessibleMethod recurse through the hierarchy. Great thanks to Vasiliy Stashuk. Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java?view=diffr1=156188r2=156189 == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java Fri Mar 4 09:51:50 2005 @@ -553,13 +553,16 @@ return (method); } -// Check the implemented interfaces and subinterfaces -method = -getAccessibleMethodFromInterfaceNest( -clazz, -method.getName(), -method.getParameterTypes()); -return (method); +while (clazz != null) { +// Check the implemented interfaces and subinterfaces +Method aMethod = getAccessibleMethodFromInterfaceNest(clazz, +method.getName(), method.getParameterTypes()); +if (aMethod != null) { +return aMethod; +} +clazz = clazz.getSuperclass(); +} +return null; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jxpath] org.apache.commons.jxpath.JXPathException: no read method
The fix is in, but I have not uploaded anything to ibiblio. Isn't that done automatically by their build process? - Dmitri - Original Message - From: Vasiliy Stashuk [EMAIL PROTECTED] To: commons-dev@jakarta.apache.org Sent: Friday, March 04, 2005 12:01 PM Subject: Re: [jxpath] org.apache.commons.jxpath.JXPathException: no read method Thanks for quick replies :) Could you also please upload new jars to ibiblio.org ? On Fri, 04 Mar 2005 17:51:22 +0200, Dmitri Plotnikov [EMAIL PROTECTED] wrote: Vasiliy, Very good point. I will commit a fix to getAccessibleMethodFromInterfaceNest tonight. Thank you very much for pointing this out. - Dmitri Vasiliy Stashuk [EMAIL PROTECTED] wrote: Making B public will help. But what if I'm using anonymous class instead of B, like this: JXPathContext ctx = JXPathContext.newContext(new A() { public String getName() { return theName; } }); ? Thanks for the help. On Fri, 04 Mar 2005 16:40:55 +0200, Dmitri Plotnikov wrote: Vasiliy, You need to change the visibility of class B from default to public. JXPath only supports access to public classes. Let me know if this helps. - Dmitri Vasiliy Stashuk wrote: Hi! I have problem while accessing java bean properties via JXPath. Consider following example. puvlic class BlaBla { public static interface Provider { public String getName(); } public static abstract class A implements Provider { } static class B extends A { public String getName() { return theName; } } public static void main(String[] args) throws Exception { B b = new B(); JXPathContext ctx = JXPathContext.newContext(b); System.out.println(ctx.getValue(name)); } } JXPath fails with: org.apache.commons.jxpath.JXPathException: Cannot access property: BlaBla$B.name; No read method This is may be a bug in the ValueUtils.getAccessibleMethodFromInterfaceNest method. It doesn't get down thru class hierarchy when looking for public accessor method. -- All the best, Vasyl Stashuk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jxpath] Future of JXPath and DOM???
Jess, First of all, this discussion is probably better suited to the commons-user mailing list. As far as your specific questions are concerned, getValue() will always return a primitive value (Number, Boolean or String) when applied to DOM. selectSingleNode() will return either a primitive value or a DOM Node. Regards, - Dmitri Jess Holle [EMAIL PROTECTED] wrote: Dmitri Plotnikov wrote: Jess, JXPath has always supported Xalan through JAXP DOM APIs. What you may have seen in the source code of JXPath is some attempts to optimize JXPath when it is used specifically in combination with Xalan. You would not be interested in that optimization, because it would only be applied to static DOM and take advantage of DTM. Try using JXPath and let us know how it works out. Dumb question (which I probably figured out last time I tried this stuff, but have no notes/recollection of): Is there an equivalent of Xalan's one-size-fits-all XObject xobj = xpath.execute(...) mechanism in JXPath? I'm looking for a CompiledExpression.getValue() that returns an Object for which: 1. I know the various possible return types when this is applied to a DOM. 2. The result is the most appropriate (as per the XPath standard) of the following: * NodeList or NodeIterator -- or something from which I can easily implement one or both of these interfaces * Boolean * Number * String [I assume callers will apply includes castes within their XPath expressions as necessary where they expect a non-node result.] Is there such a beast? The one-API fits all (beans, JDOM, DOM, etc) approach makes this a bit hard for me to decipher. -- Jess Holle
Re: [jxpath] Future of JXPath and DOM???
Jess, JXPath has always supported Xalan through JAXP DOM APIs. What you may have seen in the source code of JXPath is some attempts to optimize JXPath when it is used specifically in combination with Xalan. You would not be interested in that optimization, because it would only be applied to static DOM and take advantage of DTM. Try using JXPath and let us know how it works out. - Dmitri Jess Holle [EMAIL PROTECTED] wrote: P.S. Also, I must admit this message is somewhat of a test. If no one responds, then I can assume the JXPath community is not active enough to be worth considering over sticking with an old version of Xalan for the forseeable future. Jess Holle wrote: I am using Xalan 2.1.0 for XPath coverage presently -- behind a skinny wrapper API so we can change implementations fairly painlessly. I'd like to use something more recent and was looking at JXPath, but I note that the sources contain TO_DO comments about using Xalan as the backing XPath implementation -- for the DOM case presumably. Is this the plan? If not, what is? If this is the plan, then there is no reason for me to switch from Xalan to JXPath -- as I only care about XPath usage against DOMs (not JDOM, other beans, etc). You may ask why I'm on such an old Xalan or why I'm looking for something other than Xalan -- which are good questions... Essentially, recent versions of Xalan are missing the boat on some important XPath use cases. Xalan 2.1.0 is the last version of Xalan which does not have immense performance penalties for my use cases. Specifically, my use case is: 1. Parse/compile XPath expressions. 2. Use these expressions against many different DOMs. * I /rarely /use a given XPath against the same DOM (without intervening changes) twice. o I /often /use a given XPath against many, many different DOMs. * I /even more rarely /know that when I use an XPath on a DOM it will not be changing prior to it being used again. * I /often /need to use XPath to retrieve a list of DOM nodes to be edited or deleted -- followed by edits directly via DOM APIs and more use of other XPaths ad nauseum (e.g. based on GUI picks). After Xalan 2.1.0, the XPath portion of Xalan was optimized for the antithesis of this use case, i.e. it builds a DTM (document table model) for each DOM an XPath is used against -- which is a tremendous waste of time and memory if the XPath is all but certainly not going to be used against the given DOM (without intervening changes) more than once. I found cases of 500% performance improvement by moving back from more recent Xalan versions to 2.1.0 for these use cases! The Xalan team knows about this issue, but despite the fact that this directly affects the XPath API exposed in Java 1.5 this issue seems unimportant/uninteresting to them as compared to optimizing for the XSLT use case -- where the DTM approach makes sense since the DTM is formed once and acted upon by many XPaths many times. Some time ago I looked at both JXPath and Jaxen as possible replacements for Xalan 2.1.0. Unfortunately, both of these XPath libraries had major issues with evaluating some rather simple XPath expressions at the time -- and I need good fidelity to the XPath standard (at least as good as Xalan 2.1.0). I believe Jaxen is at the same version now as it was when I last tested it, but JXPath has had an update or two since then -- so I was going to try again until I saw the aforementioned TO_DO in the source code. If JXPath is not going to be a long-term contender for the my use cases, then I just have to continue using Xalan 2.1.0 (which I've move to another package using Ant -- similar to what Sun has done in Java 1.5 -- so as not to conflict with any other Xalan versions). So all that said, I'd appreciate any feedback as to: * the intended direction of JXPath, * the level of commitment to the XPath standard, and * the level of commitment to supporting the non-XSLT DOM use case outlined above. -- Jess Holle - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jxpath] Future of JXPath and DOM???
Jess, Sorry, I misspoke. Of course, what I wanted to say was that JXPath has always supported Xerces, which is the XML parser bundled with Xalan. Thus, it can work side-by-side with Xalan. - Dmitri Dmitri Plotnikov [EMAIL PROTECTED] wrote: Jess, JXPath has always supported Xalan through JAXP DOM APIs. What you may have seen in the source code of JXPath is some attempts to optimize JXPath when it is used specifically in combination with Xalan. You would not be interested in that optimization, because it would only be applied to static DOM and take advantage of DTM. Try using JXPath and let us know how it works out. - Dmitri Jess Holle wrote: P.S. Also, I must admit this message is somewhat of a test. If no one responds, then I can assume the JXPath community is not active enough to be worth considering over sticking with an old version of Xalan for the forseeable future. Jess Holle wrote: I am using Xalan 2.1.0 for XPath coverage presently -- behind a skinny wrapper API so we can change implementations fairly painlessly. I'd like to use something more recent and was looking at JXPath, but I note that the sources contain TO_DO comments about using Xalan as the backing XPath implementation -- for the DOM case presumably. Is this the plan? If not, what is? If this is the plan, then there is no reason for me to switch from Xalan to JXPath -- as I only care about XPath usage against DOMs (not JDOM, other beans, etc). You may ask why I'm on such an old Xalan or why I'm looking for something other than Xalan -- which are good questions... Essentially, recent versions of Xalan are missing the boat on some important XPath use cases. Xalan 2.1.0 is the last version of Xalan which does not have immense performance penalties for my use cases. Specifically, my use case is: 1. Parse/compile XPath expressions. 2. Use these expressions against many different DOMs. * I /rarely /use a given XPath against the same DOM (without intervening changes) twice. o I /often /use a given XPath against many, many different DOMs. * I /even more rarely /know that when I use an XPath on a DOM it will not be changing prior to it being used again. * I /often /need to use XPath to retrieve a list of DOM nodes to be edited or deleted -- followed by edits directly via DOM APIs and more use of other XPaths ad nauseum (e.g. based on GUI picks). After Xalan 2.1.0, the XPath portion of Xalan was optimized for the antithesis of this use case, i.e. it builds a DTM (document table model) for each DOM an XPath is used against -- which is a tremendous waste of time and memory if the XPath is all but certainly not going to be used against the given DOM (without intervening changes) more than once. I found cases of 500% performance improvement by moving back from more recent Xalan versions to 2.1.0 for these use cases! The Xalan team knows about this issue, but despite the fact that this directly affects the XPath API exposed in Java 1.5 this issue seems unimportant/uninteresting to them as compared to optimizing for the XSLT use case -- where the DTM approach makes sense since the DTM is formed once and acted upon by many XPaths many times. Some time ago I looked at both JXPath and Jaxen as possible replacements for Xalan 2.1.0. Unfortunately, both of these XPath libraries had major issues with evaluating some rather simple XPath expressions at the time -- and I need good fidelity to the XPath standard (at least as good as Xalan 2.1.0). I believe Jaxen is at the same version now as it was when I last tested it, but JXPath has had an update or two since then -- so I was going to try again until I saw the aforementioned TO_DO in the source code. If JXPath is not going to be a long-term contender for the my use cases, then I just have to continue using Xalan 2.1.0 (which I've move to another package using Ant -- similar to what Sun has done in Java 1.5 -- so as not to conflict with any other Xalan versions). So all that said, I'd appreciate any feedback as to: * the intended direction of JXPath, * the level of commitment to the XPath standard, and * the level of commitment to supporting the non-XSLT DOM use case outlined above. -- Jess Holle - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r151301 - jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java
Author: dmitri Date: Thu Feb 3 18:59:24 2005 New Revision: 151301 URL: http://svn.apache.org/viewcvs?view=revrev=151301 Log: Applied patch submitted by Emond Papegaaij. Thank you very much. Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java?view=diffr1=151300r2=151301 == --- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java (original) +++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java Thu Feb 3 18:59:24 2005 @@ -46,7 +46,7 @@ * A Pointer that points to a DOM node. * * @author Dmitri Plotnikov - * @version $Revision: 1.26 $ $Date: 2004/12/30 21:59:36 $ + * @version $Revision: 1.26 $ $Date$ */ public class DOMNodePointer extends NodePointer { private Node node; @@ -256,6 +256,9 @@ public String getDefaultNamespaceURI() { if (defaultNamespace == null) { Node aNode = node; +if (aNode instanceof Document) { +aNode = ((Document) aNode).getDocumentElement(); +} while (aNode != null) { if (aNode.getNodeType() == Node.ELEMENT_NODE) { Attr attr = ((Element) aNode).getAttributeNode(xmlns); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jxpath] Pre-commit check failed - Help needed
I was trying to commit a patch provided by Emond Papegaaij, but got a Pre-commit check failed message from CVS. I haven't done any commits since December. Has something changed? Is it possible that I somehow lost my karma? Thank you, - Dmitri
Re: [jxpath] Pre-commit check failed - Help needed
Thanks, Dion, I did not realize this has happened. I'll read up on it. - Dmitri - Original Message - From: Dion Gillard [EMAIL PROTECTED] To: Jakarta Commons Developers List commons-dev@jakarta.apache.org Sent: Wednesday, February 02, 2005 12:19 AM Subject: Re: [jxpath] Pre-commit check failed - Help needed We've moved over to subversion for jakarta commons. CVS is read only. On Wed, 2 Feb 2005 00:12:44 -0500, Dmitri Plotnikov [EMAIL PROTECTED] wrote: I was trying to commit a patch provided by Emond Papegaaij, but got a Pre-commit check failed message from CVS. I haven't done any commits since December. Has something changed? Is it possible that I somehow lost my karma? Thank you, - Dmitri -- http://www.multitask.com.au/people/dion/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jxpath] optimize xpath query on xpath enabled containers
Michael, I believe, adding this type of delegation for query evaluation would require quite significant refactoring of JXPath. However, I could be wrong. Do you have a particular fix in mind? Thank you, - Dmitri - Original Message - From: Michael Homeijer [EMAIL PROTECTED] To: Jakarta Commons Developers List commons-dev@jakarta.apache.org Sent: Monday, January 31, 2005 2:43 PM Subject: [jxpath] optimize xpath query on xpath enabled containers Hi, Im am looking at executing jxpath queries against a model that supports lazy loading and queries. Queries like [EMAIL PROTECTED] = ''test'] will be executed by looping through all nodes and testing if the expression is true for a node. Because my model supports queries itself, It would be much faster to query the model and have the model itself execute the query that will load only the nodes for which the expression is true. I saw a xalan integration in the code, possibly for the same purpose. Is there a way to extend jxpath with functionality that uses the model (or the nodepointer) itself to execute the rest of the query? TIA, Michael - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [JXPath] On contributing XOM-support
Torsten, Just to clarify the issue: we are not talking about including XOM with JXPath, we only need it to build against. We would not actually commit any non-Apache licensed code to the Apache repository. Is that equally bad? Thanks, - Dmitri Torsten Curdt [EMAIL PROTECTED] wrote: Dmitri Plotnikov wrote: Dear Shirasu, Congratulations on this wonderful piece of work and thank you very much for your decision to contribute it to Apache! Great stuff! 2. Do we have any licensing issues with XOM? I believe we can use it, it is covered by LGPL. If it's LGPL it's not ok as for the current policy :( ...unfortunately. On legal-discuss there is a discussion whether an additional clause to the LGPL will make it acceptable for the ASF. (like Hybernate did) Sorry for the bad news... -- Torsten - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [JXPath] unordered node-sets
Knut, Knut Wannheden [EMAIL PROTECTED] wrote: Dmitri, Dmitri Plotnikov apache.org writes: You are right - I am starting to forget everything. The node set does not have to be ordered, but if I want to implement axes like preceding and following, I have to impose some order on the object properties. What does this mean for JXPath? Does the ordering only ever have to take place in PredicateContext? I don't think there is any ordering in PredicateContext. The ordering of properties is done by JXPathBasicBeanInfo, the ordering of keys in maps is done by DynamicPropertyPointer. The advice I have given in similar situations before was always the same: You have at least three options: 1. Provide custom BeanInfo that excludes upward going links, e.g. keep the link from Window to Widget, but hide the link from Widget to Window. 2. Create custom implementations of NodePointer and NodePointerFactory (which seems to be exactly what you are doing) 3. (IMO, the best) avoid using JXPath for extensive searches altogether - it is not designed to handle them. It can show horrific performance, which is exactly what you are observing. Systems like Xalan do much better because they work with static structures that they index prior to the evaluation of XPaths. Try either using specific paths like /a/b/c or utilize indexing with IdentityManager or KeyManager; or use a custom extension function to perform the search. I will try to go with option 2 as I don't think 3 really is an option; or what other tool would let me evaluate XPaths against Java object graphs? I don't worry about the performance too much as the queries will be run by a user through a GUI. What is problematic is the fact that the call to Iterator#hasNext(), depending on the expression and object graph, is potentially long running and can't be interrupted. Long running not because JXPath couldn't yet determine if there is a next node or not, but because it decided to prefetch and order *all* nodes which will be returned by subsequent calls to Iterator#next(). In my case I found that this prefetching and ordering takes place in ChildContext#constructIterator(). This method is called by EvalContext#hasNext(), because it determined that the nodes need to be prefetched since the ChildContext's parent context is a DescendantContext, which requires child ordering (in document order). Now I hope you can see where my problem lies and why I initially asked about the interpretation of XPath node-sets. After browsing the source code I think I now understand why it works the way it works. What if the ordering (forward and backward) were entirely left up to the NodeIterators? Would that solve the problem? Meanwhile, to be able to interrupt JXPath, I will implement my own NodePointer throwing an unchecked exception to abort JXPath. (I tried this in the NodePointerFactory, but there the exception is caught and ignored.) Ok, I think I now get it. Sorry about having been so obtuse. To make the search interruptable, we should eliminate the isChildOrderingRequired method. Actually I don't even know why we have it. Paths like //foo would produce results in the right order even without it. Try this: comment out the DescendantContext#isChildOrderingRequired method. Let me know if it makes a difference. If it does without breaking anything else, I will make the change permanent. Regards, --knut Best, - Dmitri
Re: [JXPath] On contributing XOM-support
Torsten, Thank you for the clarification. Shirasu, I think we will have to wait 'till the issues around the licenses are resolved. I am very sorry about that. For now I could put a link on the JXPath home page pointing to your site. Sorry, - Dmitri Torsten Curdt [EMAIL PROTECTED] wrote: Dmitri Plotnikov wrote: Torsten, Just to clarify the issue: we are not talking about including XOM with JXPath, we only need it to build against. We would not actually commit any non-Apache licensed code to the Apache repository. Is that equally bad? AFAIK currently even just a simple import statement to any GPL or even LGPL code is being considered not acceptable. see http://wiki.apache.org/jakarta/Using_20LGPL_27d_20code ...unfortunately! *sigh* -- Torsten - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [JXPath] On contributing XOM-support
Dear Shirasu, Congratulations on this wonderful piece of work and thank you very much for your decision to contribute it to Apache! I will be happy to assist you with making this contribution happen. But first we need to resolve a couple of issues: 1. Will this be a separate module under commons or an integral part of JXPath? I recommend that we make it an integral part of JXPath 2. Do we have any licensing issues with XOM? I believe we can use it, it is covered by LGPL. Does anybody know of a reason we would not be able to use XOM in our build? Once again, thank you. - Dmitri - Original Message - From: shirasu hiroyuki [EMAIL PROTECTED] To: commons-dev@jakarta.apache.org Sent: Monday, January 17, 2005 10:55 PM Subject: [JXPath] On contributing XOM-support Dear Commons Developpers, I tried to implement custom Pointers and Iterators of the object model XOM for the Commons JXPath. So JXPath supports access to XOM nodes by using my work. I would like to contribute my code to the JXPath project. You can see the details at http://www.k2.dion.ne.jp/~hirsh/xpath/jxpathOverXOM-en.html Thanking you in advance, -- shirasu hiroyuki([EMAIL PROTECTED]) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jxpath] Array Creation Problem
Dear Puneet, JXPath is designed to support both null and empty arrays. If there is a problem, I cannot glean the what it is from the explanations you provided. Could you post a test case that illustrates the issue? Thank you, - Dmitri - Original Message - From: puneet sharma [EMAIL PROTECTED] To: Jakarta Commons Developers List commons-dev@jakarta.apache.org Sent: Thursday, January 13, 2005 7:10 AM Subject: [jxpath] Array Creation Problem Hi All, I am trying to call createPath to create array type of bean. I have registered my own AbstractFactory to the context. I am calling jxPathContext.createPath(secondBeanArray[1]/thirdBean). I have created the context using FirstBean. Method getSecondBeanArray() of FirstBean never returns null it always return a array (may be blank if no child bean i.e. SecondBean is added). Problem is createObject() method of my factory is not getting called in this scenario even though there is no SecondBean already added to FirstBean. I debugged the problem and found that if getSecondBeanArray() returns a null then only my factory is getting called. But I can't return null from getSecondBeanArray() method. Is there any direct way to solve this problem ?? If not, is there any way if I extend some classes of JXPath API and register those back? I saw the code also of JXPath API. And found that BeanPropertyPointer.createPath() is calling the PropertyPointer to create the node only in case of null. Thanks Puneet __ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java
dmitri 2004/12/30 13:59:36 Modified:jxpath/src/java/org/apache/commons/jxpath/ri/model/dom DOMNodePointer.java jxpath/src/java/org/apache/commons/jxpath/ri NamespaceResolver.java JXPathContextReferenceImpl.java jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java Log: Made namespace mappings inherited by child contexts Revision ChangesPath 1.26 +5 -1 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java Index: DOMNodePointer.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- DOMNodePointer.java 6 Oct 2004 00:34:14 - 1.25 +++ DOMNodePointer.java 30 Dec 2004 21:59:36 - 1.26 @@ -226,6 +226,10 @@ } namespaces.put(prefix, namespace); +if (namespace == UNKNOWN_NAMESPACE) { +return null; +} + // TBD: We are supposed to resolve relative URIs to absolute ones. return namespace; } 1.3 +18 -2 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java Index: NamespaceResolver.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- NamespaceResolver.java29 Jun 2004 22:57:20 - 1.2 +++ NamespaceResolver.java30 Dec 2004 21:59:36 - 1.3 @@ -31,11 +31,15 @@ * @version $Revision$ $Date$ */ public class NamespaceResolver implements Cloneable { - +final protected NamespaceResolver parent; protected HashMap namespaceMap = new HashMap(); protected HashMap reverseMap; protected NodePointer pointer; private boolean sealed; + +public NamespaceResolver(NamespaceResolver parent) { +this.parent = parent; +} /** * Registers a namespace prefix. @@ -56,6 +60,9 @@ } public Pointer getNamespaceContextPointer() { +if (pointer == null parent != null) { +return parent.getNamespaceContextPointer(); +} return pointer; } @@ -74,6 +81,9 @@ if (uri == null pointer != null) { uri = pointer.getNamespaceURI(prefix); } +if (uri == null parent != null) { +return parent.getNamespaceURI(prefix); +} //System.err.println(For prefix + prefix + URI= + uri); return uri; } @@ -96,6 +106,9 @@ } } String prefix = (String) reverseMap.get(namespaceURI); +if (prefix == null parent != null) { +return parent.getPrefix(namespaceURI); +} return prefix; } @@ -105,6 +118,9 @@ public void seal() { sealed = true; +if (parent != null) { +parent.seal(); +} } public Object clone() { 1.44 +6 -2 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java Index: JXPathContextReferenceImpl.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- JXPathContextReferenceImpl.java 4 Apr 2004 23:16:23 - 1.43 +++ JXPathContextReferenceImpl.java 30 Dec 2004 21:59:36 - 1.44 @@ -146,7 +146,11 @@ this.rootPointer = this.contextPointer; } -namespaceResolver = new NamespaceResolver(); +NamespaceResolver parentNR = null; +if (parentContext instanceof JXPathContextReferenceImpl) { +parentNR = ((JXPathContextReferenceImpl)parentContext).getNamespaceResolver(); +} +namespaceResolver = new NamespaceResolver(parentNR); namespaceResolver .setNamespaceContextPointer((NodePointer) this.contextPointer); } 1.25 +17 -1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java Index: XMLModelTestCase.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model
Re: JXPath and namespaces
Edwin, I hope you don't mind my posting this exchange on the mailing lists, as it could be important to a lot of JXPath users. You are making a very good point! At this point I cannot change API that has already been released. However the issue is real and needed to be addressed, so what I have done instead is allow for the namespace mappings to be inheritable via child contexts, just like extension functions, locale etc. So, the way to reuse mappings will be as follows: 1. You create a reusable parent context (which BTW does not even have to have a context node). JXPathContext pmap = JXPathContext.newContext(null); 2. Register namespaces: pmap.registerNamespace(foo, http://foomatic.bar/foo;) 3. Use this context as a parent every time you create a new JXPathContext: JXPathContext context = JXPathContext.newContext(pmap, xmlDocument) 4. Use the mapped prefixes in your xpaths: String baz = (String) context.getValue(foo:bar/foo:baz); In order to take advantage of this new functionality, you will need to use the HEAD branch from CVS (or the nightly build starting tomorrow). I hope this helps, Thank you for the insightful suggestion, Happy New Year, - Dmitri - Original Message - From: Edwin de Jong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, December 22, 2004 11:20 AM Subject: JXPath and namespaces Hi Dmitri, Recently we have begun to incorporate the new version of JXPath 1.2 into our current products. One of the (in my eyes bennevicient) changes is related to the stricter use of namespaces. Nevertheless, I feel a design flaw has been made in implementing them. Right now the prime location of changing namespaces is in the instance of the JXPathContext class. However, these namespace changes are applied to the supplied JXPaths. So instead of applying a namespace to a context, it should be applied to the search string (or have additional methods which allow an instance of a class that maps from prefixes to URI's). This way, binding can be seperated from context and search criteria. Example code snippet: --- cut here -8--- JXPrefixMap pmap = JXPrefixMap.getInstance(); pmap.add(foo, http://foomatic.bar/foo;); // or JXPrefixMap pmap = xmlContainerInstance.getPrefixMap(); JXPathContext context = JXPathContext.newContext(xmlDocument); // either: String baz = (String) context.getValue(foo:bar/foo:baz, pmap); // or: String baz = (String) context.getValue(new JXPathExpression(foo:bar/foo:baz, pmap)); System.out.println(Hello world: +baz+!); --- cut here -8--- Hope this makes some sense. It will make refactoring our code much easier since we don't always use JXPathContext's as our leading datasource (sometimes the context changes, but the query stays the same). Regards, Edwin de Jong -- Edwin de Jong eMAXX B.V. Kopersteden 22-4 P.O. Box 157 7500 AD Enschede The Netherlands tel. +31 53 484 83 21 fax. +31 53 484 83 23 http://www.emaxx.nl This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. www.emaxx.nl ([EMAIL PROTECTED]) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java
dmitri 2004/10/05 17:34:14 Modified:jxpath/src/java/org/apache/commons/jxpath/ri/model/dom DOMNodePointer.java jxpath/src/test/org/apache/commons/jxpath Vendor.xml jxpath/src/test/org/apache/commons/jxpath/ri/compiler ExtensionFunctionTest.java jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java Log: Applied patch by Nick Van den Bleeken, dealing with null default namespace Revision ChangesPath 1.25 +6 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java Index: DOMNodePointer.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- DOMNodePointer.java 29 Jun 2004 22:58:17 - 1.24 +++ DOMNodePointer.java 6 Oct 2004 00:34:14 - 1.25 @@ -130,11 +130,12 @@ } private static boolean equalStrings(String s1, String s2) { -if (s1 == null s2 != null) { -return false; +if (s1 == null) { +return s2 == null || s2.trim().length() == 0; } -if (s1 != null s2 == null) { -return false; + +if (s2 == null) { +return s1 == null || s1.trim().length() == 0; } if (s1 != null !s1.trim().equals(s2.trim())) { 1.10 +7 -0 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/Vendor.xml Index: Vendor.xml === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/Vendor.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Vendor.xml1 Apr 2004 02:55:31 - 1.9 +++ Vendor.xml6 Oct 2004 00:34:14 - 1.10 @@ -46,4 +46,11 @@ ?security do not show anybody ? ?report average only ? /product + + pos xmlns=temp +register xmlns= + number109/number +/register + /pos + /vendor 1.17 +5 -1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/ExtensionFunctionTest.java Index: ExtensionFunctionTest.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/ExtensionFunctionTest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- ExtensionFunctionTest.java4 Apr 2004 23:16:24 - 1.16 +++ ExtensionFunctionTest.java6 Oct 2004 00:34:14 - 1.17 @@ -225,6 +225,10 @@ context.getValue(add($myList, 'hello')); assertEquals(After adding an element, 2, list.size()); + +JXPathContext context = JXPathContext.newContext(new ArrayList()); +assertEquals(Extension function on root collection, 0, String +.valueOf(context.getValue(size(/; } public void testStaticMethodCall() { 1.24 +5 -1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java Index: XMLModelTestCase.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- XMLModelTestCase.java 30 Jun 2004 00:29:13 - 1.23 +++ XMLModelTestCase.java 6 Oct 2004 00:34:14 - 1.24 @@ -375,6 +375,10 @@ // child:: with a qualified name assertXPathValue(context, vendor/product/price:amount, 45.95); + +// null default namespace +context.registerNamespace(x, temp); +assertXPathValue(context, vendor/x:pos//number, 109); } public void testAxisChildIndexPredicate() { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with default namespace.
Nick, I have applied the patch. Thank you very much for tracing the problem - Dmitri - Original Message - From: Nick Van den Bleeken [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, September 02, 2004 2:30 PM Subject: Re: Problem with default namespace. Hi, My notes fucked-up my previous post. Therefor I will send my message again with an other mail client. We discovered a problem with how JXPath handles default namespaces. We wrote the following testprogram illustrating the problem (see JXPathTest.java and data.xml). We also fixed the problem against the HEAD of the jakarta CVS by changing the way namespace strings are compared (see path-DOMNodePointer.txt). We ran the JUnit tests against our fix , and no failures were reported. Is it possible to apply this patch to HEAD of the CVS? Best regards, Nick Van den Bleeken, Nick Hofstede - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with default namespace.
Nick, Thank you very much for the patch - I will apply it within a couple of days. - Dmitri - Original Message - From: Nick Van den Bleeken [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, September 02, 2004 2:30 PM Subject: Re: Problem with default namespace. Hi, My notes fucked-up my previous post. Therefor I will send my message again with an other mail client. We discovered a problem with how JXPath handles default namespaces. We wrote the following testprogram illustrating the problem (see JXPathTest.java and data.xml). We also fixed the problem against the HEAD of the jakarta CVS by changing the way namespace strings are compared (see path-DOMNodePointer.txt). We ran the JUnit tests against our fix , and no failures were reported. Is it possible to apply this patch to HEAD of the CVS? Best regards, Nick Van den Bleeken, Nick Hofstede - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [doc] not enough Karma?
Thank you very much. - Dmitri - Original Message - From: Henri Yandell [EMAIL PROTECTED] To: Jakarta Commons Developers List [EMAIL PROTECTED] Sent: Monday, August 02, 2004 8:04 AM Subject: Re: [doc] not enough Karma? Jakarta General is probably the best way to make the request; but I can do it and have done so. Hen On Sun, 1 Aug 2004, Dmitri Plotnikov wrote: Who should I contact to get a little more Karma, so I would be able to commit changes to the jakarta-site2 module? Thank you, - Dmitri - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[RESULT][VOTE] Release vote for JXPath 1.2
It's been a week since the original call for votes was issued. We've got three +1 votes (Dmitri Plotnikov, Matthew Hawthorne and Davanum Srinivas) and no objections. Thus, we are ready to cut the release, which is precisely what I am going to do. - Dmitri - Original Message - From: Dmitri Plotnikov [EMAIL PROTECTED] To: Jakarta Commons Developers List [EMAIL PROTECTED] Sent: Sunday, July 25, 2004 3:13 PM Subject: [VOTE] Release vote for JXPath 1.2 I'd like to call for a release vote on JXPath 1.2. It has been stable for a long time, and there are no outstanding bugs against it. It includes about 1.5 years of bug fixes and other improvements. The release candidate build can be found at http://www.apache.org/dist/jakarta/commons/jxpath/jxpath_1.2RC2/ +1 (this is my vote) Thank you, Dmitri - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[ANNOUNCEMENT] JXPath 1.2 Released
We are proud to announce the release of JXPath 1.2. JXPath is an interpreter of the XPath expression language. JXPath applies XPath expressions to graphs of objects of all kinds: JavaBeans, Collections, arrays, Maps, Servlet contexts, DOM, JDOM etc, including mixtures thereof. It fully supports the XPath 1.0 standard: paths, arithmetic, logical, set and string expressions, all standard as well as extension functions etc. The new release adds a couple of new APIs, introduces many improvements and bug fixes. JXPath's home page which has links to API documentation and a detailed user's guide: http://jakarta.apache.org/commons/jxpath/ JXPath 1.2 Release Notes are at: http://jakarta.apache.org/commons/jxpath/release-notes-1.2.html Great thanks to everybody who reported problems, helped to trace them, suggested changes or simply provided encouragement. Thank you all for your continuous support of JXPath. Dmitri Plotnikov [EMAIL PROTECTED] P.S. I wish I had enough Karma to update the documentation on the Jakarta website. :-( - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes InitialContext.java
dmitri 2004/07/30 06:51:01 Modified:jxpath/src/java/org/apache/commons/jxpath/ri/axes InitialContext.java Log: PR: 30298. Invalid implementation of InitialContext.getValue() Revision ChangesPath 1.15 +2 -2 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/InitialContext.java Index: InitialContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/InitialContext.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- InitialContext.java 25 Mar 2004 05:42:01 - 1.14 +++ InitialContext.java 30 Jul 2004 13:51:01 - 1.15 @@ -52,7 +52,7 @@ } public Object getValue() { -return nodePointer; +return nodePointer.getValue(); } public boolean nextNode() { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util BasicTypeConverter.java
dmitri 2004/07/25 06:16:04 Modified:jxpath/src/java/org/apache/commons/jxpath/util BasicTypeConverter.java Log: PR: 30272. Integration with ConverterUtils had a bug in it Revision ChangesPath 1.15 +6 -4 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java Index: BasicTypeConverter.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- BasicTypeConverter.java 29 Jun 2004 21:50:02 - 1.14 +++ BasicTypeConverter.java 25 Jul 2004 13:16:04 - 1.15 @@ -26,6 +26,7 @@ import java.util.Set; import org.apache.commons.beanutils.ConvertUtils; +import org.apache.commons.beanutils.Converter; import org.apache.commons.jxpath.JXPathException; import org.apache.commons.jxpath.NodeSet; import org.apache.commons.jxpath.Pointer; @@ -293,9 +294,10 @@ } } -if (ConvertUtils.lookup(toType) != null) { - return ConvertUtils.convert(object.toString(), toType); - } +Converter converter = ConvertUtils.lookup(toType); +if (converter != null) { +return converter.convert(toType, object); +} throw new RuntimeException( Cannot convert + object.getClass() + to + toType); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[VOTE] Release vote for JXPath 1.2
I'd like to call for a release vote on JXPath 1.2. It has been stable for a long time, and there are no outstanding bugs against it. It includes about 1.5 years of bug fixes and other improvements. The release candidate build can be found at http://www.apache.org/dist/jakarta/commons/jxpath/jxpath_1.2RC2/ +1 (this is my vote) Thank you, Dmitri
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri InfoSetUtil.java
dmitri 2004/07/16 15:49:33 Modified:jxpath/src/java/org/apache/commons/jxpath/ri InfoSetUtil.java Log: Corrected the behavior of boolean() and not() with variables Revision ChangesPath 1.11 +13 -3 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java Index: InfoSetUtil.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- InfoSetUtil.java 8 May 2004 20:07:09 - 1.10 +++ InfoSetUtil.java 16 Jul 2004 22:49:33 - 1.11 @@ -17,6 +17,7 @@ import org.apache.commons.jxpath.Pointer; import org.apache.commons.jxpath.ri.model.NodePointer; +import org.apache.commons.jxpath.ri.model.VariablePointer; /** * Type conversions, XPath style. @@ -151,13 +152,22 @@ } else if (object instanceof EvalContext) { EvalContext ctx = (EvalContext) object; -return ctx.nextSet() ctx.nextNode(); +Pointer ptr = ctx.getSingleNodePointer(); +if (ptr == null) { +return false; +} +return booleanValue(ptr); } else if (object instanceof String) { return ((String) object).length() != 0; } else if (object instanceof NodePointer) { -return ((NodePointer) object).isActual(); +NodePointer pointer = (NodePointer) object; +if (pointer instanceof VariablePointer) { +return booleanValue(pointer.getNode()); +} +pointer = pointer.getValuePointer(); +return pointer.isActual(); } else if (object == null) { return false; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath JXPathTestCase.java
dmitri 2004/07/16 15:52:32 Modified:jxpath/src/test/org/apache/commons/jxpath JXPathTestCase.java Log: PR 30133. Made test cases Locale-independent Revision ChangesPath 1.36 +3 -1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestCase.java Index: JXPathTestCase.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestCase.java,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- JXPathTestCase.java 29 Feb 2004 14:17:40 - 1.35 +++ JXPathTestCase.java 16 Jul 2004 22:52:32 - 1.36 @@ -21,6 +21,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Set; import junit.framework.TestCase; @@ -42,6 +43,7 @@ */ public JXPathTestCase(String name) { super(name); +Locale.setDefault(Locale.US); } protected void assertXPathValue(JXPathContext ctx, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath build.xml
dmitri 2004/07/12 20:42:43 Modified:jxpath build.xml Log: Didn't realize that the version number is not permitted in the name of the jar file Revision ChangesPath 1.23 +1 -1 jakarta-commons/jxpath/build.xml Index: build.xml === RCS file: /home/cvs/jakarta-commons/jxpath/build.xml,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- build.xml 9 Jul 2004 04:50:38 - 1.22 +++ build.xml 13 Jul 2004 03:42:43 - 1.23 @@ -20,7 +20,7 @@ /property property name=javadocdir value=${basedir}/dist/docs/api /property - property name=final.name value=commons-jxpath-1.2 + property name=final.name value=commons-jxpath /property target name=init description=o Initializes some properties mkdir dir=${libdir} - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath build.xml
dmitri 2004/07/08 21:50:38 Modified:jxpath build.xml Log: Fixed a problem with javadoc generation Revision ChangesPath 1.22 +1 -1 jakarta-commons/jxpath/build.xml Index: build.xml === RCS file: /home/cvs/jakarta-commons/jxpath/build.xml,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- build.xml 2 Jul 2004 22:26:00 - 1.21 +++ build.xml 9 Jul 2004 04:50:38 - 1.22 @@ -139,7 +139,7 @@ /property property name=title value=JXPath 1.2 API /property -javadoc use=true private=true destdir=${javadocdir} author=true version=true sourcepath=src/java packagenames=.* +javadoc use=true private=true destdir=${javadocdir} author=true version=true sourcepath=src/java packagenames=* classpath fileset dir=${libdir} include name=*.jar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath build.xml
dmitri 2004/07/02 15:26:00 Modified:jxpath build.xml Log: Removed accidental dependency on a local directory Revision ChangesPath 1.21 +10 -10jakarta-commons/jxpath/build.xml Index: build.xml === RCS file: /home/cvs/jakarta-commons/jxpath/build.xml,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- build.xml 30 Jun 2004 00:30:01 - 1.20 +++ build.xml 2 Jul 2004 22:26:00 - 1.21 @@ -4,21 +4,21 @@ on date June 28 2004, time 1759-- project default=jar name=commons-jxpath basedir=. - property name=defaulttargetdir value=D:\jakarta-commons\jxpath/target + property name=defaulttargetdir value=${basedir}/target /property - property name=libdir value=D:\jakarta-commons\jxpath/target/lib + property name=libdir value=${basedir}/target/lib /property - property name=classesdir value=D:\jakarta-commons\jxpath/target/classes + property name=classesdir value=${basedir}/target/classes /property - property name=testclassesdir value=D:\jakarta-commons\jxpath/target/test-classes + property name=testclassesdir value=${basedir}/target/test-classes /property - property name=testclassesdir value=D:\jakarta-commons\jxpath/target/test-classes + property name=testclassesdir value=${basedir}/target/test-classes /property - property name=testreportdir value=D:\jakarta-commons\jxpath/target/test-reports + property name=testreportdir value=${basedir}/target/test-reports /property property name=distdir value=dist /property - property name=javadocdir value=dist/docs/api + property name=javadocdir value=${basedir}/dist/docs/api /property property name=final.name value=commons-jxpath-1.2 /property @@ -35,7 +35,7 @@ /mkdir javac destdir=${classesdir} deprecation=true debug=true optimize=false excludes=**/package.html src -pathelement location=src/java +pathelement location=${basedir}/src/java /pathelement /src classpath @@ -109,7 +109,7 @@ /mkdir javac destdir=${testclassesdir} deprecation=true debug=true optimize=false excludes=**/package.html src -pathelement location=src/test +pathelement location=${basedir}/src/test /pathelement /src classpath @@ -122,7 +122,7 @@ /classpath /javac copy todir=${testclassesdir} - fileset dir=D:\jakarta-commons\jxpath\src\test + fileset dir=${basedir}/src\test include name=**/*.xml /include /fileset - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath JXPathContext.java
dmitri 2004/06/29 14:15:46 Modified:jxpath/src/java/org/apache/commons/jxpath JXPathContext.java Log: Added selectNodes and selectSingleNode methods Revision ChangesPath 1.25 +37 -1 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java Index: JXPathContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- JXPathContext.java4 Apr 2004 23:16:23 - 1.24 +++ JXPathContext.java29 Jun 2004 21:15:46 - 1.25 @@ -16,8 +16,10 @@ package org.apache.commons.jxpath; import java.text.DecimalFormatSymbols; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Locale; /** @@ -623,6 +625,40 @@ */ protected abstract CompiledExpression compilePath(String xpath); +/** + * Finds the first object that matches the specified XPath. It is equivalent + * to codegetPointer(xpath).getNode()/code. Note, that this method + * produces the same result as codegetValue()/code on object models + * like JavaBeans, but a different result for DOM/JDOM etc., because it + * returns the Node itself, rather than its textual contents. + * + * @param xpath the xpath to be evaluated + * @return the found object + */ +public Object selectSingleNode(String xpath) { + Pointer pointer = getPointer(xpath); + if (pointer == null) { + return null; + } + return pointer.getNode(); +} + +/** + * Finds all nodes that match the specified XPath. + * + * @param xpath the xpath to be evaluated + * @return a list of found objects + */ +public List selectNodes(String xpath) { + ArrayList list = new ArrayList(); + Iterator iterator = iteratePointers(xpath); + while (iterator.hasNext()) { + Pointer pointer = (Pointer) iterator.next(); + list.add(pointer.getNode()); + } + return list; +} + /** * Evaluates the xpath and returns the resulting object. Primitive * types are wrapped into objects. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/util BasicTypeConverterTest.java
dmitri 2004/06/29 14:50:02 Modified:jxpath/src/java/org/apache/commons/jxpath/util BasicTypeConverter.java jxpath/src/test/org/apache/commons/jxpath/util BasicTypeConverterTest.java Log: Integrated with BeanUtils ConverterUtils Revision ChangesPath 1.14 +8 -3 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java Index: BasicTypeConverter.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- BasicTypeConverter.java 25 Mar 2004 05:42:01 - 1.13 +++ BasicTypeConverter.java 29 Jun 2004 21:50:02 - 1.14 @@ -25,9 +25,10 @@ import java.util.List; import java.util.Set; +import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.jxpath.JXPathException; -import org.apache.commons.jxpath.Pointer; import org.apache.commons.jxpath.NodeSet; +import org.apache.commons.jxpath.Pointer; /** * The default implementation of TypeConverter. @@ -160,7 +161,7 @@ else if (object instanceof Pointer) { return canConvert(((Pointer) object).getValue(), toType); } -return false; +return ConvertUtils.lookup(toType) != null; } /** @@ -292,6 +293,10 @@ } } +if (ConvertUtils.lookup(toType) != null) { + return ConvertUtils.convert(object.toString(), toType); + } + throw new RuntimeException( Cannot convert + object.getClass() + to + toType); } 1.7 +6 -1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/util/BasicTypeConverterTest.java Index: BasicTypeConverterTest.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/util/BasicTypeConverterTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- BasicTypeConverterTest.java 29 Feb 2004 14:17:46 - 1.6 +++ BasicTypeConverterTest.java 29 Jun 2004 21:50:02 - 1.7 @@ -16,6 +16,7 @@ package org.apache.commons.jxpath.util; import java.lang.reflect.Array; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -166,4 +167,8 @@ } }, Integer.class, new Integer(9)); } + +public void testBeanUtilsConverter() { +assertConversion(12, BigDecimal.class, new BigDecimal(12)); +} } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri NamespaceResolver.java
dmitri 2004/06/29 15:57:20 Modified:jxpath/src/java/org/apache/commons/jxpath/ri NamespaceResolver.java Log: Fixed a bug having to do with the caching or the reverseMap Revision ChangesPath 1.2 +2 -1 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java Index: NamespaceResolver.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- NamespaceResolver.java1 Apr 2004 02:55:32 - 1.1 +++ NamespaceResolver.java29 Jun 2004 22:57:20 - 1.2 @@ -45,6 +45,7 @@ */ public void registerNamespace(String prefix, String namespaceURI) { namespaceMap.put(prefix, namespaceURI); +reverseMap = null; } /** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom JDOMNodePointer.java
dmitri 2004/06/29 15:58:18 Modified:jxpath/src/java/org/apache/commons/jxpath/ri/model/dom DOMNodePointer.java jxpath/src/test/org/apache/commons/jxpath/ri/model/jdom TestJDOMFactory.java jxpath/src/test/org/apache/commons/jxpath/ri/model/dom TestDOMFactory.java jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom JDOMNodePointer.java Log: Fixed a bug having to do with creation of nodes with prefixes Revision ChangesPath 1.24 +12 -3 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java Index: DOMNodePointer.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- DOMNodePointer.java 1 Apr 2004 02:55:32 - 1.23 +++ DOMNodePointer.java 29 Jun 2004 22:58:17 - 1.24 @@ -387,8 +387,17 @@ name.toString(), index); if (success) { -NodeIterator it = -childIterator(new NodeNameTest(name), false, null); +NodeTest nodeTest; +String prefix = name.getPrefix(); +if (prefix != null) { +String namespaceURI = context.getNamespaceURI(prefix); +nodeTest = new NodeNameTest(name, namespaceURI); +} +else { +nodeTest = new NodeNameTest(name); +} + +NodeIterator it = childIterator(nodeTest, false, null); if (it != null it.setPosition(index + 1)) { return it.getNodePointer(); } 1.6 +18 -4 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/jdom/TestJDOMFactory.java Index: TestJDOMFactory.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/jdom/TestJDOMFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- TestJDOMFactory.java 29 Feb 2004 14:17:43 - 1.5 +++ TestJDOMFactory.java 29 Jun 2004 22:58:17 - 1.6 @@ -44,13 +44,19 @@ if (name.equals(location) || name.equals(address) || name.equals(street)) { -addJDOMElement((Element) parent, index, name); +addJDOMElement((Element) parent, index, name, null); return true; } +if (name.startsWith(price:)) { +String namespaceURI = context.getNamespaceURI(price); +addJDOMElement((Element) parent, index, name, namespaceURI); +return true; +} + return false; } -private void addJDOMElement(Element parent, int index, String tag) { +private void addJDOMElement(Element parent, int index, String tag, String namespaceURI) { List children = parent.getContent(); int count = 0; for (int i = 0; i children.size(); i++) { @@ -65,7 +71,15 @@ while (count = index) { // In a real factory we would need to do the right thing with // the namespace prefix. -Element newElement = new Element(tag); +Element newElement; +if (namespaceURI != null) { +String prefix = tag.substring(0, tag.indexOf(':')); +tag = tag.substring(tag.indexOf(':') + 1); +newElement = new Element(tag, prefix, namespaceURI); +} +else { +newElement = new Element(tag); +} parent.addContent(newElement); count++; } 1.6 +18 -4 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/dom/TestDOMFactory.java Index: TestDOMFactory.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/dom/TestDOMFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- TestDOMFactory.java 29 Feb 2004 14:17:46 - 1.5 +++ TestDOMFactory.java 29 Jun 2004 22:58:17 - 1.6 @@ -18,6 +18,7 @@ import org.apache.commons.jxpath.AbstractFactory; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.Pointer; +import org.w3c.dom.Document; import org.w3c.dom.Node; /** @@ -41,13 +42,18
Re: [jxpath] bug in DOMNodePointer?
Nikolay, Thank you very much for reporting this issue. It is now fixed. - Dmitri - Original Message - From: Nikolay Tsankov [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, June 17, 2004 4:29 AM Subject: [jxpath] bug in DOMNodePointer? class org.apache.commons.jxpath.ri.model.dom.DOMNodePointer in method public NodePointer createChild(JXPathContext context, QName name, int index) has NodeIterator it = childIterator(new NodeNameTest(name), false, null); Now where is the namespaceUri of this NodeNameTest constructor? In case there is a namespace, the check next line fails and an exceptions is thrown fix: ...new NodeNameTest(name, context.getNamespaceURI(name.getPrefix()))... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java
dmitri 2004/06/29 17:29:13 Modified:jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java Log: Verified name() in a predicate Revision ChangesPath 1.23 +6 -1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java Index: XMLModelTestCase.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- XMLModelTestCase.java 29 Jun 2004 22:58:18 - 1.22 +++ XMLModelTestCase.java 30 Jun 2004 00:29:13 - 1.23 @@ -555,6 +555,11 @@ context, vendor/[EMAIL PROTECTED]'101']//street, Tangerine Drive); + +assertXPathValueIterator( +context, +/vendor/location[1]/@*[name()!= 'manager'], list(100, +local)); } public void testAxisNamespace() { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jxpath] JXPath 1.2 RC1 is now available
The first Release Candidate for JXPath 1.2 is now available at: http://www.apache.org/dist/jakarta/commons/jxpath/jxpath_1.2RC1/ Please check it out when (if) you have a minute. The binary distribution contains the complete documentation, including the updated Users' Guide and a (brief) Release Notes document. Any comments will be highly appreciated. Thanks in advance, - Dmitri Plotnikov
[jxpath][VOTE] Release plan for JXPath 1.2
We have received repeated requests to make a new release of JXPath. Even though there have been no major functional changes or additions since 1.1, the number of bug fixes and other improvements warrants a new release. This is a vote to approve the 1.2 release plan (http://wiki.apache.org/jakarta-commons/JXPathRelease1_2e2) and myself as release manager for this release. Here's my +1 - Dmitri
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath JXPathBasicBeanInfo.java
dmitri 2004/05/08 08:03:36 Modified:jxpath/src/java/org/apache/commons/jxpath JXPathBasicBeanInfo.java Log: Improved toString() Revision ChangesPath 1.9 +7 -1 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java Index: JXPathBasicBeanInfo.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathBasicBeanInfo.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- JXPathBasicBeanInfo.java 29 Feb 2004 14:17:42 - 1.8 +++ JXPathBasicBeanInfo.java 8 May 2004 15:03:36 - 1.9 @@ -131,6 +131,12 @@ StringBuffer buffer = new StringBuffer(); buffer.append(BeanInfo [class = ); buffer.append(clazz.getName()); +if (isDynamic()) { +buffer.append(, dynamic); +} +if (isAtomic()) { +buffer.append(, atomic); +} buffer.append(, properties = ); PropertyDescriptor[] jpds = getPropertyDescriptors(); for (int i = 0; i jpds.length; i++) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath JXPathIntrospector.java
dmitri 2004/05/08 08:10:05 Modified:jxpath/src/java/org/apache/commons/jxpath JXPathIntrospector.java Log: Fixed dynamic BeanInfo lookup Revision ChangesPath 1.10 +9 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathIntrospector.java Index: JXPathIntrospector.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathIntrospector.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- JXPathIntrospector.java 29 Feb 2004 14:17:42 - 1.9 +++ JXPathIntrospector.java 8 May 2004 15:10:05 - 1.10 @@ -117,10 +117,10 @@ * interfaces. */ private static JXPathBeanInfo findDynamicBeanInfo(Class beanClass) { -JXPathBeanInfo beanInfo; +JXPathBeanInfo beanInfo = null; if (beanClass.isInterface()) { beanInfo = (JXPathBeanInfo) byInterface.get(beanClass); -if (beanInfo != null) { +if (beanInfo != null beanInfo.isDynamic()) { return beanInfo; } } @@ -129,7 +129,7 @@ if (interfaces != null) { for (int i = 0; i interfaces.length; i++) { beanInfo = findDynamicBeanInfo(interfaces[i]); -if (beanInfo != null) { +if (beanInfo != null beanInfo.isDynamic()) { return beanInfo; } } @@ -137,7 +137,11 @@ Class sup = beanClass.getSuperclass(); if (sup != null) { -return findDynamicBeanInfo(sup); +beanInfo = (JXPathBeanInfo) byClass.get(sup); +if (beanInfo != null beanInfo.isDynamic()) { +return beanInfo; +} +return findDynamicBeanInfo(sup); } return null; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test-webapp - New directory
dmitri 2004/05/08 08:10:45 jakarta-commons/jxpath/src/test-webapp - New directory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test-webapp/WEB-INF - New directory
dmitri 2004/05/08 08:10:45 jakarta-commons/jxpath/src/test-webapp/WEB-INF - New directory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test-webapp/WEB-INF web.xml
dmitri 2004/05/08 08:10:49 Modified:jxpath/src/java/org/apache/commons/jxpath/servlet ServletRequestHandler.java HttpSessionHandler.java JXPathServletContexts.java PageContextHandler.java ServletContextHandler.java PageScopeContextHandler.java Added: jxpath/src/java/org/apache/commons/jxpath/servlet ServletRequestAndContext.java HttpSessionAndServletContext.java jxpath/src/test-webapp JXPathServletContextsTestServlet.java JXPathTest.jsp jxpath/src/test-webapp/WEB-INF web.xml Removed: jxpath/src/java/org/apache/commons/jxpath/servlet Util.java Log: Fixed issues with JXPathServletContexts Revision ChangesPath 1.6 +38 -11 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java Index: ServletRequestHandler.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ServletRequestHandler.java29 Feb 2004 14:17:40 - 1.5 +++ ServletRequestHandler.java8 May 2004 15:10:49 - 1.6 @@ -16,26 +16,53 @@ package org.apache.commons.jxpath.servlet; import java.util.Enumeration; +import java.util.HashSet; import javax.servlet.ServletRequest; -import org.apache.commons.jxpath.DynamicPropertyHandler; /** * Implementation of the DynamicPropertyHandler interface that provides - * access to attributes of a ServletRequest. + * access to attributes and parameters of a ServletRequest. * * @author Dmitri Plotnikov * @version $Revision$ $Date$ */ -public class ServletRequestHandler implements DynamicPropertyHandler { - -public String[] getPropertyNames(Object request) { -Enumeration e = ((ServletRequest) request).getAttributeNames(); -return Util.toStrings(e); +public class ServletRequestHandler extends HttpSessionHandler { + +protected void collectPropertyNames(HashSet set, Object bean) { +super.collectPropertyNames(set, bean); +ServletRequestAndContext handle = (ServletRequestAndContext) bean; +ServletRequest servletRequest = handle.getServletRequest(); +Enumeration e = servletRequest.getAttributeNames(); +while (e.hasMoreElements()) { +set.add(e.nextElement()); +} +e = servletRequest.getParameterNames(); +while (e.hasMoreElements()) { +set.add(e.nextElement()); +} } - -public Object getProperty(Object request, String property) { -return ((ServletRequest) request).getAttribute(property); + +public Object getProperty(Object bean, String property) { +ServletRequestAndContext handle = (ServletRequestAndContext) bean; +ServletRequest servletRequest = handle.getServletRequest(); +String[] strings = servletRequest.getParameterValues(property); +if (strings != null) { +if (strings.length == 0) { +return null; +} +if (strings.length == 1) { +return strings[0]; +} +return strings; +} + +Object object = servletRequest.getAttribute(property); +if (object != null) { +return object; +} + +return super.getProperty(bean, property); } public void setProperty(Object request, String property, Object value) { 1.6 +39 -11 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java Index: HttpSessionHandler.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- HttpSessionHandler.java 29 Feb 2004 14:17:40 - 1.5 +++ HttpSessionHandler.java 8 May 2004 15:10:49 - 1.6 @@ -16,9 +16,11 @@ package org.apache.commons.jxpath.servlet; import java.util.Enumeration; +import java.util.HashSet; import javax.servlet.http.HttpSession; -import org.apache.commons.jxpath.DynamicPropertyHandler; + +import org.apache.commons.jxpath.JXPathException; /** * Implementation of the DynamicPropertyHandler interface that provides @@ -27,18 +29,44 @@ * @author Dmitri Plotnikov * @version $Revision$ $Date$ */ -public class HttpSessionHandler implements DynamicPropertyHandler { +public class HttpSessionHandler
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler CoreFunctionTest.java
dmitri 2004/05/08 13:07:09 Modified:jxpath/src/java/org/apache/commons/jxpath/ri InfoSetUtil.java jxpath/src/test/org/apache/commons/jxpath/ri/compiler CoreFunctionTest.java Log: Fixed Bug #28753: conversion of Boolean to Number Revision ChangesPath 1.10 +13 -3 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java Index: InfoSetUtil.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- InfoSetUtil.java 29 Feb 2004 14:17:45 - 1.9 +++ InfoSetUtil.java 8 May 2004 20:07:09 - 1.10 @@ -87,7 +87,12 @@ return value; } else if (object instanceof EvalContext) { -return number(stringValue(object)); +EvalContext ctx = (EvalContext) object; +Pointer ptr = ctx.getSingleNodePointer(); +if (ptr != null) { +return number(ptr); +} +return NOT_A_NUMBER; } else if (object instanceof NodePointer) { return number(((NodePointer) object).getValue()); @@ -123,7 +128,12 @@ return doubleValue(((NodePointer) object).getValue()); } else if (object instanceof EvalContext) { -return doubleValue(stringValue(object)); +EvalContext ctx = (EvalContext) object; +Pointer ptr = ctx.getSingleNodePointer(); +if (ptr != null) { +return doubleValue(ptr); +} +return Double.NaN; } return doubleValue(stringValue(object)); } 1.10 +6 -2 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java Index: CoreFunctionTest.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- CoreFunctionTest.java 29 Feb 2004 14:17:42 - 1.9 +++ CoreFunctionTest.java 8 May 2004 20:07:09 - 1.10 @@ -50,6 +50,8 @@ context = JXPathContext.newContext(new TestMixedModelBean()); Variables vars = context.getVariables(); vars.declareVariable(nan, new Double(Double.NaN)); +vars.declareVariable(bool_true, new Boolean(true)); +vars.declareVariable(bool_false, new Boolean(false)); } } @@ -95,13 +97,15 @@ assertXPathValue(context, not(false()), Boolean.TRUE); assertXPathValue(context, not(true()), Boolean.FALSE); assertXPathValue(context, number('1'), new Double(1)); +assertXPathValue(context, number($bool_true), new Double(1)); +assertXPathValue(context, number($bool_false), new Double(0)); assertXPathValue(context, floor(1.5), new Double(1)); assertXPathValue(context, floor(-1.5), new Double(-2)); assertXPathValue(context, ceiling(1.5), new Double(2)); assertXPathValue(context, ceiling(-1.5), new Double(-1)); assertXPathValue(context, round(1.5), new Double(2)); assertXPathValue(context, round(-1.5), new Double(-1)); -assertXPathValue(context, null(), null); +assertXPathValue(context, null(), null); } public void testIDFunction() { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/container - New directory
dmitri 2004/04/04 15:06:29 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/container - New directory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/container ContainerPointer.java
dmitri 2004/04/04 15:06:36 Modified:jxpath/src/test/org/apache/commons/jxpath JXPathTestSuite.java jxpath/src/java/org/apache/commons/jxpath/ri/model/dynabeans DynaBeanPropertyPointer.java jxpath/src/java/org/apache/commons/jxpath/ri/model/beans CollectionPointer.java BeanPropertyPointer.java PropertyPointer.java PropertyOwnerPointer.java jxpath/src/java/org/apache/commons/jxpath/ri/model VariablePointer.java jxpath/src/java/org/apache/commons/jxpath/util ValueUtils.java jxpath/src/java/org/apache/commons/jxpath/ri JXPathContextReferenceImpl.java jxpath/src/test/org/apache/commons/jxpath/ri/model MixedModelTest.java jxpath/src/java/org/apache/commons/jxpath/ri/model/dynamic DynamicPropertyPointer.java jxpath/src/java/org/apache/commons/jxpath/ri/model/container ContainerPointer.java Added: jxpath/src/test/org/apache/commons/jxpath/ri/model/container ContainerModelTest.java Log: In some situations JXPath would not open containers during path traversal. Made the container opening consistent throughout RI. Revision ChangesPath 1.7 +3 -1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestSuite.java Index: JXPathTestSuite.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/JXPathTestSuite.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JXPathTestSuite.java 29 Feb 2004 14:17:40 - 1.6 +++ JXPathTestSuite.java 4 Apr 2004 22:06:35 - 1.7 @@ -30,6 +30,7 @@ import org.apache.commons.jxpath.ri.compiler.VariableTest; import org.apache.commons.jxpath.ri.model.MixedModelTest; import org.apache.commons.jxpath.ri.model.beans.BeanModelTest; +import org.apache.commons.jxpath.ri.model.container.ContainerModelTest; import org.apache.commons.jxpath.ri.model.dom.DOMModelTest; import org.apache.commons.jxpath.ri.model.dynabeans.DynaBeanModelTest; import org.apache.commons.jxpath.ri.model.dynamic.DynamicPropertiesModelTest; @@ -79,6 +80,7 @@ suite.addTestSuite(CoreOperationTest.class); suite.addTestSuite(ExtensionFunctionTest.class); suite.addTestSuite(VariableTest.class); +suite.addTestSuite(ContainerModelTest.class); suite.addTestSuite(BeanModelTest.class); suite.addTestSuite(DynamicPropertiesModelTest.class); suite.addTestSuite(DOMModelTest.class); 1.1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/container/ContainerModelTest.java Index: ContainerModelTest.java === /* * Copyright 1999-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.jxpath.ri.model.container; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.apache.commons.jxpath.Container; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathTestCase; /** * Tests JXPath with containers as root or value of a variable, property, etc. * * @author Dmitri Plotnikov * @version $Revision: 1.1 $ $Date: 2004/04/04 22:06:35 $ */ public class ContainerModelTest extends JXPathTestCase { private JXPathContext context; /** * Construct a new instance of this test case. * * @param name Name of the test case */ public ContainerModelTest(String name) { super(name); } public static void main(String[] args) { TestRunner.run(suite()); } /** * Return the tests included in this test suite. */ public static Test suite() { return (new TestSuite(ContainerModelTest.class)); } private
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler ExtensionFunctionTest.java
dmitri 2004/04/04 16:16:24 Modified:jxpath/src/java/org/apache/commons/jxpath PackageFunctions.java JXPathContext.java jxpath/src/java/org/apache/commons/jxpath/ri JXPathContextReferenceImpl.java jxpath/src/test/org/apache/commons/jxpath/ri/compiler ExtensionFunctionTest.java Log: setFunctions now completely overrides the default, thus enabling a secure implementation of the Functions interface Revision ChangesPath 1.14 +2 -2 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/PackageFunctions.java Index: PackageFunctions.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/PackageFunctions.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- PackageFunctions.java 25 Mar 2004 05:42:01 - 1.13 +++ PackageFunctions.java 4 Apr 2004 23:16:23 - 1.14 @@ -189,7 +189,7 @@ ex); } -if (methodName.endsWith(new)) { +if (methodName.equals(new)) { Constructor constructor = MethodLookupUtils.lookupConstructor(functionClass, parameters); if (constructor != null) { 1.24 +11 -2 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java Index: JXPathContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- JXPathContext.java1 Apr 2004 02:55:31 - 1.23 +++ JXPathContext.java4 Apr 2004 23:16:23 - 1.24 @@ -389,6 +389,9 @@ private static JXPathContextFactory contextFactory; private static JXPathContext compilationContext; + +private static final PackageFunctions GENERIC_FUNCTIONS = +new PackageFunctions(, null); /** * Creates a new JXPathContext with the specified object as the root node. @@ -488,7 +491,13 @@ * Returns the set of functions installed on the context. */ public Functions getFunctions() { -return functions; +if (functions != null) { +return functions; +} +if (parentContext == null) { +return GENERIC_FUNCTIONS; +} +return null; } /** 1.43 +1 -8 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java Index: JXPathContextReferenceImpl.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- JXPathContextReferenceImpl.java 4 Apr 2004 22:06:36 - 1.42 +++ JXPathContextReferenceImpl.java 4 Apr 2004 23:16:23 - 1.43 @@ -32,7 +32,6 @@ import org.apache.commons.jxpath.Functions; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathException; -import org.apache.commons.jxpath.PackageFunctions; import org.apache.commons.jxpath.Pointer; import org.apache.commons.jxpath.Variables; import org.apache.commons.jxpath.ri.axes.InitialContext; @@ -66,8 +65,6 @@ private static final Compiler COMPILER = new TreeCompiler(); private static Map compiled = new HashMap(); -private static final PackageFunctions GENERIC_FUNCTIONS = -new PackageFunctions(, null); private static int cleanupCount = 0; private static Vector nodeFactories = new Vector(); @@ -644,10 +641,6 @@ } } funcCtx = funcCtx.getParentContext(); -} -func = GENERIC_FUNCTIONS.getFunction(namespace, name, parameters); -if (func != null) { -return func; } throw new JXPathException( Undefined function: + functionName.toString()); 1.16 +9 -2 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/ExtensionFunctionTest.java Index: ExtensionFunctionTest.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/ExtensionFunctionTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- ExtensionFunctionTest.java25 Mar 2004 05:42:01 - 1.15 +++ ExtensionFunctionTest.java4 Apr 2004 23:16:24 - 1.16 @@ -20,6 +20,8
Re: [jxpath] problem with Container interface
The problem is now fixed. In some situations JXPath would not open containers during path traversal. I went through the entire code base to see that container opening is done properly everywhere. I ran the test you provided and it now runs fine. Thank you very much for pointing out this problem. - Dmitri - Original Message - From: Dmitri Plotnikov [EMAIL PROTECTED] To: Jakarta Commons Users List [EMAIL PROTECTED] Sent: Tuesday, March 09, 2004 12:08 PM Subject: Re: [jxpath] problem with Container interface I'll look into this. I haven't tried putting a collection in a container - it's quite possible there is a bug there. Out of curiosity - what purpose does the container serve in your situation? Why don't you use the contents of the container as the context object? Thanks, - Dmitri - Original Message - From: Uwe Janner [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, March 08, 2004 1:38 PM Subject: Re: [jxpath] problem with Container interface to describe my problem more precisely, i also append this test; i dont understand why it evaluates correcty with index [1], but not with index [2]. both ctx.getValue(/a) and ctx.getValue(/b) correctly evaluate to the whole arraylist [x,y]; thank you in advance for any help, uwe! public class XpathUtilTest extends TestCase { public void testEval(){ JXPathContext ctx = JXPathContext.newContext(new MyObject()); // this test succeeds: assertEquals(x, ctx.getValue(/a[1])); // this test fails because of: // JXPathException: No value for xpath: /a[2] assertEquals(y, ctx.getValue(/a[2])); } public class MyObject implements Container{ Map map; public MyObject(){ map = new HashMap(); map.put( a, new ListEntry()); map.put( b, new ListEntry()); } public Object getValue() { return map; } public void setValue(Object arg0) {} } public class ListEntry implements Container{ private List list; public ListEntry(){ this.list = new ArrayList(); list.add(x); list.add(y); } public Object getValue() { return list; } public void setValue(Object arg0) {} } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/axes SimplePathInterpreterTest.java
dmitri 2004/03/24 19:49:51 Modified:jxpath/src/java/org/apache/commons/jxpath/ri/axes SimplePathInterpreter.java ParentContext.java AncestorContext.java PrecedingOrFollowingContext.java ChildContext.java jxpath/src/java/org/apache/commons/jxpath/ri/model NodePointer.java jxpath/src/java/org/apache/commons/jxpath/ri/model/beans CollectionPointer.java NullElementPointer.java NullPropertyPointer.java PropertyPointer.java PropertyIterator.java jxpath/src/java/org/apache/commons/jxpath/ri JXPathContextReferenceImpl.java jxpath/src/java/org/apache/commons/jxpath/ri/model/dynamic DynamicPropertyPointer.java jxpath/src/test/org/apache/commons/jxpath/ri/axes SimplePathInterpreterTest.java Log: getParent() will now return the actual parent NodePointer, not some intermediate helper NodePointer Revision ChangesPath 1.15 +1 -1 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java Index: SimplePathInterpreter.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- SimplePathInterpreter.java29 Feb 2004 14:17:38 - 1.14 +++ SimplePathInterpreter.java25 Mar 2004 03:49:50 - 1.15 @@ -694,7 +694,7 @@ int quality = PERFECT_MATCH; while (pointer != null !pointer.isActual()) { quality--; -pointer = pointer.getParent(); +pointer = pointer.getImmediateParentPointer(); } return quality; } 1.15 +3 -3 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/ParentContext.java Index: ParentContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/ParentContext.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ParentContext.java29 Feb 2004 14:17:37 - 1.14 +++ ParentContext.java25 Mar 2004 03:49:50 - 1.15 @@ -64,10 +64,10 @@ } setStarted = true; NodePointer thisLocation = parentContext.getCurrentNodePointer(); -currentNodePointer = thisLocation.getParent(); +currentNodePointer = thisLocation.getImmediateParentPointer(); while (currentNodePointer != null currentNodePointer.isContainer()) { -currentNodePointer = currentNodePointer.getParent(); +currentNodePointer = currentNodePointer.getImmediateParentPointer(); } if (currentNodePointer != null currentNodePointer.testNode(nodeTest)) { 1.15 +2 -2 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/AncestorContext.java Index: AncestorContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/AncestorContext.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- AncestorContext.java 29 Feb 2004 14:17:37 - 1.14 +++ AncestorContext.java 25 Mar 2004 03:49:50 - 1.15 @@ -86,7 +86,7 @@ } while (true) { -currentNodePointer = currentNodePointer.getParent(); +currentNodePointer = currentNodePointer.getImmediateParentPointer(); if (currentNodePointer == null) { return false; 1.15 +4 -18 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/PrecedingOrFollowingContext.java Index: PrecedingOrFollowingContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/PrecedingOrFollowingContext.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- PrecedingOrFollowingContext.java 29 Feb 2004 14:17:38 - 1.14 +++ PrecedingOrFollowingContext.java 25 Mar 2004 03:49:50 - 1.15 @@ -80,8 +80,7 @@ if (!setStarted) { setStarted = true; currentRootLocation = parentContext.getCurrentNodePointer(); -NodePointer parent = -getMaterialPointer(currentRootLocation.getParent()); +NodePointer parent
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom JDOMNodePointer.java
dmitri 2004/03/24 21:41:29 Modified:jxpath/src/java/org/apache/commons/jxpath/ri/model/dom DOMNodePointer.java jxpath/src/java/org/apache/commons/jxpath/ri/compiler NodeNameTest.java Path.java jxpath/src/java/org/apache/commons/jxpath/ri/model NodePointer.java jxpath/src/java/org/apache/commons/jxpath/ri/model/beans PropertyOwnerPointer.java jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom JDOMNodePointer.java Log: Introduced NodeNameTest.isWildcard() Revision ChangesPath 1.22 +6 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java Index: DOMNodePointer.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- DOMNodePointer.java 29 Feb 2004 14:17:44 - 1.21 +++ DOMNodePointer.java 25 Mar 2004 05:41:29 - 1.22 @@ -90,16 +90,17 @@ return false; } -QName testName = ((NodeNameTest) test).getNodeName(); -String testLocalName = testName.getName(); -boolean wildcard = testLocalName.equals(*); +NodeNameTest nodeNameTest = (NodeNameTest) test; +QName testName = nodeNameTest.getNodeName(); +boolean wildcard = nodeNameTest.isWildcard(); String testPrefix = testName.getPrefix(); if (wildcard testPrefix == null) { return true; } if (wildcard -|| testLocalName.equals(DOMNodePointer.getLocalName(node))) { +|| testName.getName() +.equals(DOMNodePointer.getLocalName(node))) { String nodePrefix = DOMNodePointer.getPrefix(node); if (equalStrings(testPrefix, nodePrefix)) { return true; 1.10 +5 -1 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/compiler/NodeNameTest.java Index: NodeNameTest.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/compiler/NodeNameTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- NodeNameTest.java 29 Feb 2004 14:17:38 - 1.9 +++ NodeNameTest.java 25 Mar 2004 05:41:29 - 1.10 @@ -31,6 +31,10 @@ public QName getNodeName() { return qname; } + +public boolean isWildcard() { +return qname.getName().equals(*); +} public String toString() { return qname.toString(); 1.13 +2 -3 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/compiler/Path.java Index: Path.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/compiler/Path.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Path.java 29 Feb 2004 14:17:39 - 1.12 +++ Path.java 25 Mar 2004 05:41:29 - 1.13 @@ -105,8 +105,7 @@ return false; } -String name = ((NodeNameTest) nodeTest).getNodeName().getName(); -if (name.equals(*)) { +if (((NodeNameTest) nodeTest).isWildcard()) { return false; } return areBasicPredicates(step.getPredicates()); 1.24 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java Index: NodePointer.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- NodePointer.java 25 Mar 2004 03:49:50 - 1.23 +++ NodePointer.java 25 Mar 2004 05:41:29 - 1.24 @@ -332,7 +332,8 @@ if (isContainer()) { return false; } -QName testName = ((NodeNameTest) test).getNodeName(); +NodeNameTest nodeNameTest = (NodeNameTest) test; +QName testName = nodeNameTest.getNodeName(); QName nodeName = getName(); if (nodeName == null) { return false; @@ -347,11 +348,10 @@ return false; } } -String testLocalName
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/compiler ExtensionFunction.java
dmitri 2004/03/24 21:42:01 Modified:jxpath/src/java/org/apache/commons/jxpath/util BasicTypeConverter.java jxpath/src/test/org/apache/commons/jxpath/ri/compiler TestFunctions.java ExtensionFunctionTest.java jxpath/src/java/org/apache/commons/jxpath/ri/axes InitialContext.java RootContext.java NamespaceContext.java jxpath/src/java/org/apache/commons/jxpath PackageFunctions.java jxpath/src/java/org/apache/commons/jxpath/ri EvalContext.java jxpath/src/java/org/apache/commons/jxpath/ri/compiler ExtensionFunction.java Log: Improved type conversion for extenstion functions Revision ChangesPath 1.13 +7 -1 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java Index: BasicTypeConverter.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- BasicTypeConverter.java 29 Feb 2004 14:17:43 - 1.12 +++ BasicTypeConverter.java 25 Mar 2004 05:42:01 - 1.13 @@ -177,6 +177,12 @@ } if (toType == Object.class) { +if (object instanceof NodeSet) { +return convert(((NodeSet) object).getValues(), toType); +} +else if (object instanceof Pointer) { +return convert(((Pointer) object).getValue(), toType); +} return object; } 1.10 +6 -1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/TestFunctions.java Index: TestFunctions.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/TestFunctions.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- TestFunctions.java29 Feb 2004 14:17:42 - 1.9 +++ TestFunctions.java25 Mar 2004 05:42:01 - 1.10 @@ -49,6 +49,11 @@ ((Number) context.getContextNodePointer().getValue()).intValue(); this.bar = bar; } + +public TestFunctions(int foo, Object object, boolean another) { +this.foo = foo; +bar = String.valueOf(object); +} public int getFoo() { return foo; 1.15 +9 -11 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/ExtensionFunctionTest.java Index: ExtensionFunctionTest.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/ExtensionFunctionTest.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ExtensionFunctionTest.java29 Feb 2004 14:17:42 - 1.14 +++ ExtensionFunctionTest.java25 Mar 2004 05:42:01 - 1.15 @@ -170,6 +170,12 @@ // Allocate new object using a custom constructor - type conversion assertXPathValue(context, string(test:new('3', 4)), foo=3; bar=4.0); + +context.getVariables().declareVariable(A, baz); +assertXPathValue( +context, +string(test:new(2, $A, false)), +foo=2; bar=baz); } public void testMethodCall() { @@ -210,16 +216,8 @@ size(beans), new Integer(2)); -boolean exception = false; -try { -assertXPathValue(context, add($myList, 'hello'), Boolean.TRUE); -} -catch (Exception ex) { -exception = true; -} -assertTrue( -Exception trying to add to an unmodifiable list, -exception); +context.getValue(add($myList, 'hello')); +assertEquals(After adding an element, 2, list.size()); } public void testStaticMethodCall() { 1.14 +6 -2 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/InitialContext.java Index: InitialContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/InitialContext.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- InitialContext.java 29 Feb 2004 14:17:37 - 1.13 +++ InitialContext.java 25 Mar 2004 05:42:01 - 1.14 @@ -50,7 +50,11 @@ public NodePointer
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom JDOMNamespaceIterator.java JDOMNodePointer.java
dmitri 2004/03/03 17:01:27 Modified:jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom JDOMNamespaceIterator.java JDOMNodePointer.java Log: Resolved compatibility issue with JDOM b10 Revision ChangesPath 1.8 +4 -4 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNamespaceIterator.java Index: JDOMNamespaceIterator.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNamespaceIterator.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- JDOMNamespaceIterator.java29 Feb 2004 14:17:40 - 1.7 +++ JDOMNamespaceIterator.java4 Mar 2004 01:01:27 - 1.8 @@ -61,9 +61,9 @@ prefixes.add(ns.getPrefix()); } } -Element parent = (Element) element.getParent(); -if (parent != null) { -collectNamespaces(parent); +Object parent = element.getParent(); +if (parent instanceof Element) { +collectNamespaces((Element)parent); } } 1.14 +9 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java Index: JDOMNodePointer.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- JDOMNodePointer.java 29 Feb 2004 14:17:40 - 1.13 +++ JDOMNodePointer.java 4 Mar 2004 01:01:27 - 1.14 @@ -467,7 +467,10 @@ private Element nodeParent(Object node) { if (node instanceof Element) { -return (Element) ((Element) node).getParent(); +Object parent = ((Element) node).getParent(); +if (parent instanceof Element) { +return (Element) parent; +} } else if (node instanceof Text) { return (Element) ((Text) node).getParent(); @@ -623,11 +626,12 @@ private int getRelativePositionByName() { if (node instanceof Element) { -Element parent = (Element)((Element) node).getParent(); -if (parent == null) { +Object parent = ((Element) node).getParent(); +if (!(parent instanceof Element)) { return 1; } -List children = parent.getContent(); + +List children = ((Element)parent).getContent(); int count = 0; String name = ((Element) node).getQualifiedName(); for (int i = 0; i children.size(); i++) { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Bug 26853] New: - Improving MapDynamicPropertyHandler
Yann, Sure, I'll commit the change. But just out of curiousity, what is that situtation where map.size() != map.keySet().size()? It almost feels like it would break a bunch of other things. Thanks for the report. - Dmitri --- [EMAIL PROTECTED] wrote: DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26853. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26853 Improving MapDynamicPropertyHandler Summary: Improving MapDynamicPropertyHandler Product: Commons Version: Nightly Builds Platform: All OS/Version: All Status: NEW Severity: Enhancement Priority: Other Component: JXPath AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] in: org.apache.commons.jxpath.MapDynamicPropertyHandler If the following code: public String[] getPropertyNames(Object object) { Map map = (Map) object; String names[] = new String[map.size()]; Iterator it = map.keySet().iterator(); for (int i = 0; i names.length; i++) { names[i] = String.valueOf(it.next()); } return names; } could be replaced by: public String[] getPropertyNames(Object object) { Set keys = ((Map) object).keySet(); String names[] = new String[keys.size()]; Iterator it = keys.iterator(); for (int i = 0; i names.length; i++) { names[i] = String.valueOf(it.next()); } return names; } This would permit to support very special cases where Map.keySet().size() != Map.size() [which, I know, does not conform to the Map API]. Anyway, in general, it is better to compute the size on the Set we are actually using and not on another one related to it... Thanks, Yann Duponchel. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans NullPropertyPointer.java
dmitri 2004/01/23 17:12:02 Modified:jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java jxpath/src/java/org/apache/commons/jxpath/ri/model/beans NullPropertyPointer.java Log: Bug report 25609: Child not created when setting attribute Revision ChangesPath 1.17 +21 -6 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java Index: XMLModelTestCase.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- XMLModelTestCase.java 19 Jan 2004 20:44:52 - 1.16 +++ XMLModelTestCase.java 24 Jan 2004 01:12:01 - 1.17 @@ -230,6 +230,12 @@ /vendor[1]/location[1]/@name, local, /vendor[1]/location[1]/@name); + + assertXPathCreatePathAndSetValue( +context, +/vendor[1]/location[4]/@manager, +, +/vendor[1]/location[4]/@manager); } /** @@ -262,7 +268,13 @@ vendor/location[1]/@manager, John Doe, /vendor[1]/location[1]/@manager); - + +assertXPathCreatePathAndSetValue( +context, +/vendor[1]/location[4]/@manager, +James Dow, +/vendor[1]/location[4]/@manager); + assertXPathCreatePathAndSetValue( context, vendor/product/name/attribute::price:language, @@ -343,7 +355,10 @@ priceNS:amount); // name (non-qualified) -assertXPathValue(context, name(vendor/location), location); +assertXPathValue( +context, +name(vendor/location), +location); // namespace-uri (qualified) assertXPathValue( 1.16 +9 -10 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java Index: NullPropertyPointer.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- NullPropertyPointer.java 23 Jan 2004 01:10:21 - 1.15 +++ NullPropertyPointer.java 24 Jan 2004 01:12:02 - 1.16 @@ -146,8 +146,9 @@ } public NodePointer createPath(JXPathContext context) { +NodePointer newParent = parent.createPath(context); if (isAttribute()) { -return parent.createAttribute(context, getName()); +return newParent.createAttribute(context, getName()); } else { // Consider these two use cases: @@ -160,11 +161,9 @@ // 2. The parent pointer of NullPropertyPointer is a NullPointer. //When we call createPath, it may return a PropertyOwnerPointer //or it may return anything else, like a DOMNodePointer. -//In the former case we need to exactly what we did in use +//In the former case we need to do exactly what we did in use //case 1. In the latter case, we simply request that the //non-property pointer expand the collection by itself. - -NodePointer newParent = parent.createPath(context); if (newParent instanceof PropertyOwnerPointer) { PropertyOwnerPointer pop = (PropertyOwnerPointer) newParent; newParent = pop.getPropertyPointer(); @@ -174,13 +173,13 @@ } public NodePointer createPath(JXPathContext context, Object value) { +NodePointer newParent = parent.createPath(context); if (isAttribute()) { -NodePointer pointer = parent.createAttribute(context, getName()); +NodePointer pointer = newParent.createAttribute(context, getName()); pointer.setValue(value); return pointer; } else { -NodePointer newParent = parent.createPath(context); if (newParent instanceof PropertyOwnerPointer) { PropertyOwnerPointer pop = (PropertyOwnerPointer) newParent; newParent = pop.getPropertyPointer(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri EvalContext.java
dmitri 2004/01/23 18:16:19 Modified:jxpath/src/java/org/apache/commons/jxpath/ri EvalContext.java Log: Fixed a problem with passing collections as arguments and using getNodeSet in general Revision ChangesPath 1.28 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/EvalContext.java Index: EvalContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/EvalContext.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- EvalContext.java 9 Oct 2003 21:31:38 - 1.27 +++ EvalContext.java 24 Jan 2004 02:16:19 - 1.28 @@ -284,7 +284,7 @@ BasicNodeSet set = new BasicNodeSet(); while (nextSet()) { while (nextNode()) { -set.add(getCurrentNodePointer()); +set.add((Pointer)getCurrentNodePointer().clone()); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler TestFunctions.java ExtensionFunctionTest.java
dmitri 2004/01/23 18:16:51 Modified:jxpath/src/test/org/apache/commons/jxpath/ri/compiler TestFunctions.java ExtensionFunctionTest.java Log: Fixed a problem with passing collections as arguments and using getNodeSet in general Revision ChangesPath 1.8 +8 -4 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/TestFunctions.java Index: TestFunctions.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/TestFunctions.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- TestFunctions.java9 Oct 2003 21:31:43 - 1.7 +++ TestFunctions.java24 Jan 2004 02:16:51 - 1.8 @@ -185,4 +185,8 @@ return set; } + +public static Collection items(Collection arg) { +return arg; +} } 1.12 +13 -5 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/ExtensionFunctionTest.java Index: ExtensionFunctionTest.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/ExtensionFunctionTest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ExtensionFunctionTest.java19 Jan 2004 20:44:52 - 1.11 +++ ExtensionFunctionTest.java24 Jan 2004 02:16:51 - 1.12 @@ -353,7 +353,15 @@ assertXPathValue( context, test:collection()/@name, -foo); +foo); + +List list = new ArrayList(); +list.add(foo); +list.add(bar); +context.getVariables().declareVariable(myList, list); +Object +values = context.getValue(test:items($myList)); +System.err.println(Values: + values); } public void testNodeSetReturn() { - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [jxpath] extension function bug
Jason, Thank you very much for reporting this problem. It is now fixed. - Dmitri - Original Message - From: Jason Horman [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, November 13, 2003 11:36 AM Subject: [jxpath] extension function bug There seems to be a bug with ExtensionFunctions and collections as parameters. Example: List list = new ArrayList(); list.add(foo); list.add(bar); context.getVariables().declareVariable(myList, list); Collection values = context.getValue(test:getItems($myList)); * Values returns: [bar, bar] not [foo, bar] Extension Function: public static Collection getItems(Collection items) { return items; } It seems that the iterator building the collection is always returning the last element. Since the existing unit test (ExtensionFunctionTest.testCollectionMethodCall) is only testing the size, the test passes. I added a test to check the actual values passed to the extension function. Diff of ExtensionFunctionTest.java 270a271,282 public void testCollectionMethodCall2() { List list = new ArrayList(); list.add(foo); list.add(bar); context.getVariables().declareVariable(myList, list); assertXPathValue( context, test:getItems($myList), list); } Diff of TestFunctions.java 168c168,172 --- public static Collection getItems(Collection items) { return items; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/test/org/apache/commons/jxpath JXPathTestCase.java
dmitri 2004/01/23 18:42:22 Modified:jxpath/src/test/org/apache/commons/jxpath/ri/compiler ExtensionFunctionTest.java jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java jxpath/src/test/org/apache/commons/jxpath/ri/model/dom DOMModelTest.java jxpath/src/test/org/apache/commons/jxpath/ri/model/jdom JDOMModelTest.java jxpath/src/test/org/apache/commons/jxpath JXPathTestCase.java Log: Added some testing for pointer.getNode() Revision ChangesPath 1.13 +12 -8 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/ExtensionFunctionTest.java Index: ExtensionFunctionTest.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/compiler/ExtensionFunctionTest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ExtensionFunctionTest.java24 Jan 2004 02:16:51 - 1.12 +++ ExtensionFunctionTest.java24 Jan 2004 02:42:21 - 1.13 @@ -63,6 +63,7 @@ package org.apache.commons.jxpath.ri.compiler; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Locale; @@ -358,10 +359,13 @@ List list = new ArrayList(); list.add(foo); list.add(bar); -context.getVariables().declareVariable(myList, list); -Object -values = context.getValue(test:items($myList)); -System.err.println(Values: + values); +context.getVariables().declareVariable(list, list); +Object values = context.getValue(test:items($list)); +assertTrue(Return type: , values instanceof Collection); +assertEquals( +Return values: , +list, +new ArrayList((Collection) values)); } public void testNodeSetReturn() { 1.18 +5 -5 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java Index: XMLModelTestCase.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- XMLModelTestCase.java 24 Jan 2004 01:12:01 - 1.17 +++ XMLModelTestCase.java 24 Jan 2004 02:42:22 - 1.18 @@ -80,7 +80,7 @@ */ public abstract class XMLModelTestCase extends JXPathTestCase { -private JXPathContext context; +protected JXPathContext context; /** * Construct a new instance of this test case. 1.11 +13 -4 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/dom/DOMModelTest.java Index: DOMModelTest.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/dom/DOMModelTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- DOMModelTest.java 19 Jan 2004 20:44:52 - 1.10 +++ DOMModelTest.java 24 Jan 2004 02:42:22 - 1.11 @@ -66,8 +66,11 @@ import junit.framework.TestSuite; import org.apache.commons.jxpath.AbstractFactory; +import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.ri.model.XMLModelTestCase; import org.apache.commons.jxpath.xml.DocumentContainer; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -103,6 +106,12 @@ protected AbstractFactory getAbstractFactory() { return new TestDOMFactory(); +} + +public void testGetNode() { +assertXPathNodeType(context, /, Document.class); +assertXPathNodeType(context, /vendor/location, Element.class); +assertXPathNodeType(context, //location/@name, Attr.class); } protected String getXMLSignature( 1.11 +12 -5 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/jdom/JDOMModelTest.java Index: JDOMModelTest.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/jdom/JDOMModelTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JDOMModelTest.java19 Jan 2004 20:44:52 - 1.10 +++ JDOMModelTest.java24 Jan 2004 02:42:22 - 1.11 @@ -70,6 +70,7 @@ import org.apache.commons.jxpath.AbstractFactory; import
Re: Jxpath vs. Jaxen?
Matthew, If you have the need to traverse through Java Beans, Maps, Collections etc, JXPath does all of that out of the box. Plus it supports mixed models, e.g. a map containing DOM documents or a Java Bean that has a JDOM document as the value of some property. Jaxen is better suited for homogenous representations of XML, such as DOM, JDOM, DOM4J etc. It supports a much wider varieties of in-memory representations of XML than JXPath. You can make Jaxen traverse non-XML object graphs, but you would have to provide your own implementations of some Jaxen APIs. So, to summarize: with pure XML, try either Jaxen or JXPath (or for that matter Xalan if you are working with DOM). With non-XML objects in the picture - go with JXPath. - Dmitri - Original Message - From: __matthewHawthorne [EMAIL PROTECTED] To: Jakarta Commons Developers List [EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 1:09 AM Subject: Jxpath vs. Jaxen? I'm frequently finding myself needing a Bean query language, and then I remembered that Jxpath can do this easily. But I've done a little reading about Jaxen and wondering if I should give this library it's day in court also. I'm continuing the investigation, but I'm interested in what others have to say. Anyone have feelings favoring one or the other? Apache vs. Codehaus -- who will triumph? It's a true battle of the titans. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans PropertyOwnerPointer.java NullPropertyPointer.java
dmitri 2004/01/22 17:10:21 Modified:jxpath/src/java/org/apache/commons/jxpath/ri/model/dynamic DynamicPropertyIterator.java DynamicPointer.java jxpath/src/java/org/apache/commons/jxpath/ri/axes SimplePathInterpreter.java jxpath/src/test/org/apache/commons/jxpath/ri/model/dynamic DynamicPropertiesModelTest.java jxpath/src/java/org/apache/commons/jxpath/ri/compiler Path.java jxpath/src/java/org/apache/commons/jxpath/ri/model/beans PropertyOwnerPointer.java NullPropertyPointer.java Log: Fixed an issue with searches in graphs containing DynamicPropertyHandlers Revision ChangesPath 1.4 +2 -9 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPropertyIterator.java Index: DynamicPropertyIterator.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPropertyIterator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DynamicPropertyIterator.java 9 Oct 2003 21:31:41 - 1.3 +++ DynamicPropertyIterator.java 23 Jan 2004 01:10:20 - 1.4 @@ -58,9 +58,7 @@ import org.apache.commons.jxpath.ri.model.beans.PropertyOwnerPointer; /** - * codeDynamicPropertyIterator/code is different from a regular - * codePropertyIterator/code in that given a property name it - * will always find that property (albeit with a null value). + * @deprecated - no longer needed, as it is identical to PropertyIterator. * * @author a href=mailto:[EMAIL PROTECTED]Dmitri Plotnikov/a * @version $Id$ @@ -75,9 +73,4 @@ { super(pointer, name, reverse, startWith); } - -protected void prepareForIndividualProperty(String name) { -((DynamicPropertyPointer) getPropertyPointer()).setPropertyName(name); -super.prepareForIndividualProperty(name); - } } 1.5 +11 -6 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPointer.java Index: DynamicPointer.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPointer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DynamicPointer.java 9 Oct 2003 21:31:41 - 1.4 +++ DynamicPointer.java 23 Jan 2004 01:10:20 - 1.5 @@ -68,6 +68,7 @@ import org.apache.commons.jxpath.ri.QName; import org.apache.commons.jxpath.ri.model.NodeIterator; import org.apache.commons.jxpath.ri.model.NodePointer; +import org.apache.commons.jxpath.ri.model.beans.PropertyIterator; import org.apache.commons.jxpath.ri.model.beans.PropertyOwnerPointer; import org.apache.commons.jxpath.ri.model.beans.PropertyPointer; @@ -110,7 +111,7 @@ public NodeIterator createNodeIterator( String property, boolean reverse, NodePointer startWith) { -return new DynamicPropertyIterator(this, property, reverse, startWith); +return new PropertyIterator(this, property, reverse, startWith); } public NodeIterator attributeIterator(QName name) { @@ -120,7 +121,11 @@ public QName getName() { return name; } - + +public boolean isDynamicPropertyDeclarationSupported() { +return true; +} + /** * Returns the DP object iself. */ 1.13 +1 -1 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java Index: SimplePathInterpreter.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- SimplePathInterpreter.java9 Oct 2003 21:31:39 - 1.12 +++ SimplePathInterpreter.java23 Jan 2004 01:10:20 - 1.13 @@ -787,7 +787,7 @@ * a) represents the requested path and * b) can be used for creation of missing nodes in the path. */ -private static NodePointer createNullPointer( +public static NodePointer createNullPointer( EvalContext context, NodePointer parent, Step[] steps, int currentStep) { 1.7 +49 -5 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/dynamic/DynamicPropertiesModelTest.java Index: DynamicPropertiesModelTest.java === RCS file: /home/cvs
Re: [JXPath] Registering namespace prefixes - never mind
I understand now. Let me read a little more before I reintroduce this feature. In XPath 2 there is this notion of in-scope-namespaces. Are these two related? - Dmitri - Original Message - From: Sudhir Rao [EMAIL PROTECTED] To: Dmitri Plotnikov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; Jakarta Commons Developers List [EMAIL PROTECTED]; Jakarta Commons Users List [EMAIL PROTECTED] Sent: Tuesday, January 20, 2004 5:45 PM Subject: Re: [JXPath] Registering namespace prefixes - never mind Dmitri, I was looking at it mainly for xml documents. I am not sure how this maps out to Java objects (and as I mentioned earlier as I don't have a very good idea in that respect). Here is what I feel the issue is with xml documents (Chap pointed this out briefly earlier). I have a fairly simple xml document, === |?xml version=1.0? bk:book xmlns:bk='urn:loc.gov:books' xmlns:isbn='urn:ISBN:0-395-36341-6' bk:titleCheaper by the Dozen/bk:title isbn:number1568491379/isbn:number /bk:book |=== |To access say the isbn number I would use the following xpath in my code. /bk:book/isbn:number Note that I need to specify the prefixes in my xpath or it won't work. Now if I had instead the following document which is identical for all practical purposes with the earlier xml except that the prefixes are different, it is my opinion that my code still ought to work. |=== |?xml version=1.0? !-- both namespace prefixes are available throughout -- ck:book xmlns:ck='urn:loc.gov:books' xmlns:idn='urn:ISBN:0-395-36341-6' ck:titleCheaper by the Dozen/ck:title idn:number1568491379/idn:number /ck:book |=== |But it doesn't. And that is because the prefixes I am specifying in my xpaths are not the same as what is used in the document. I need the xpaths being used to stay consistent and I ought to be able to specify the namespace mappings. So that when I say I want to access the xpath /||bk:book/isbn:number, I can specify exactly what I mean by bk and isbn in this xpath. There might be a easier, cleaner way using jxpath, but I am not aware of it at this point. If you could specify alternatives that would be great. For my purposes I think Xalan might be a better fit for now. Regards Sudhir || | Dmitri Plotnikov wrote: Chap, Sudhir, After some profound discussions on the [EMAIL PROTECTED] mailing list, I decided to roll back this new feature. I need to better understand the use case before I introduce this new API. Is the functionality you are referring to intended for use with Java objects? What is the meaning of a namespace URI in the context of Java objects? Please, give me as much information about this use case as possible. - Dmiri - Original Message - From: Dmitri Plotnikov [EMAIL PROTECTED] To: [EMAIL PROTECTED]; Jakarta Commons Users List [EMAIL PROTECTED]; Sudhir Rao [EMAIL PROTECTED] Cc: Jakarta Commons Developers List [EMAIL PROTECTED] Sent: Saturday, January 17, 2004 8:52 PM Subject: Re: [JXPath] Registering namespace prefixes Chap, I added registration of external namespaces to JXPath. My solution is a little different from the one proposed by Sudhir. The main difference in the API is that instead of calling registerNamespace directly on JXPathContext, you call it indirectly like this: JXPathContext context = JXPathContext.newContext(document); NamespaceManager nsm = context.getNamespaceManager(); nsm.registerNamespace (prefix, http://www.example.com/ns/sample;); Take a look at the NamespaceManager interface - you can supply your own implementation, which could perform very flexible customizations of namespace lookup. Please note that external namespaces are supported with DOM but not JDOM, because JDOM B9 at this point requires that all namespaces be explicitly declared in the XML file itself. Chap, Sudhir, if you guys get a chance to try out the new APIs to see if they address your needs, I will highly appreciate it. Thanks, - Dmitri - Original Message - From: Sudhir Rao [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Saturday, December 06, 2003 6:41 PM Subject: Re: [JXPath] Registering namespace prefixes I made some local modifications for this. I am not sure if adding that registerNamespace is the right way to do it, as I am not very familiar with the codebase. The changes I did locally were to a) Modify org.apache.commons.jxpath.ri.QName.java to include the namespace prefix (similar to the one in Apache Axis). Had to tweak it a bit to consider the prefix as the namespaceURI however to keep it compatible with existing code. b) Maintain a HashMap of prefixes
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/compiler Expression.java
dmitri 2004/01/19 12:44:52 Modified:jxpath/src/java/org/apache/commons/jxpath JXPathContext.java jxpath/src/java/org/apache/commons/jxpath/ri/axes RootContext.java jxpath/src/java/org/apache/commons/jxpath/ri/model NodePointer.java jxpath/src/test/org/apache/commons/jxpath/ri/compiler ExtensionFunctionTest.java CoreFunctionTest.java jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java BeanModelTestCase.java jxpath/src/test/org/apache/commons/jxpath/ri/model/dom DOMModelTest.java jxpath/src/test/org/apache/commons/jxpath/ri/model/jdom JDOMModelTest.java jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom JDOMNodePointer.java jxpath/src/java/org/apache/commons/jxpath/ri/model/dom DOMNodePointer.java jxpath/src/java/org/apache/commons/jxpath/xml JDOMParser.java jxpath/src/java/org/apache/commons/jxpath/ri JXPathContextReferenceImpl.java jxpath/src/java/org/apache/commons/jxpath/ri/compiler Expression.java Removed: jxpath/src/java/org/apache/commons/jxpath BasicNamespaceManager.java NamespaceManager.java Log: Rolled back the external namespace registration feature Revision ChangesPath 1.21 +28 -27 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java Index: JXPathContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- JXPathContext.java18 Jan 2004 01:43:29 - 1.20 +++ JXPathContext.java19 Jan 2004 20:44:51 - 1.21 @@ -432,7 +432,7 @@ protected IdentityManager idManager; protected KeyManager keyManager; protected HashMap decimalFormats; -protected NamespaceManager namespaceManager; +//protected NamespaceManager namespaceManager; private static JXPathContextFactory contextFactory; private static JXPathContext compilationContext; @@ -810,28 +810,29 @@ + no KeyManager has been specified); } } - -/** - * Install a namespace manager that will be used by the context - * to look up namespace URI's for prefixes. - */ -public void setNamespaceManager(NamespaceManager namespaceManager) { -this.namespaceManager = namespaceManager; -} -/** - * Returns this context's namespace manager. If none has been installed, - * returns the key manager of the parent context, or the default - * namespace manager. - */ -public NamespaceManager getNamespaceManager() { -if (keyManager == null parentContext != null) { -return parentContext.getNamespaceManager(); -} -if (namespaceManager == null) { -namespaceManager = new BasicNamespaceManager(); -} -return namespaceManager; -} +// TODO: either remove these methods or complete the functionality +///** +// * Install a namespace manager that will be used by the context +// * to look up namespace URI's for prefixes. +// */ +//public void setNamespaceManager(NamespaceManager namespaceManager) { +//this.namespaceManager = namespaceManager; +//} +// +///** +// * Returns this context's namespace manager. If none has been installed, +// * returns the key manager of the parent context, or the default +// * namespace manager. +// */ +//public NamespaceManager getNamespaceManager() { +//if (keyManager == null parentContext != null) { +//return parentContext.getNamespaceManager(); +//} +//if (namespaceManager == null) { +//namespaceManager = new BasicNamespaceManager(); +//} +//return namespaceManager; +//} } 1.15 +5 -6 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/RootContext.java Index: RootContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/axes/RootContext.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- RootContext.java 18 Jan 2004 01:43:29 - 1.14 +++ RootContext.java 19 Jan 2004 20:44:51 - 1.15 @@ -139,8 +139,7 @@ pointer
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml JDOMParser.java XMLParser2.java
dmitri 2004/01/19 14:17:02 Modified:jxpath/src/java/org/apache/commons/jxpath/xml JDOMParser.java XMLParser2.java Log: Changed the default from namespaceAware = false to namespaceAware = true Revision ChangesPath 1.7 +9 -19 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml/JDOMParser.java Index: JDOMParser.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml/JDOMParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JDOMParser.java 19 Jan 2004 20:44:52 - 1.6 +++ JDOMParser.java 19 Jan 2004 22:17:02 - 1.7 @@ -74,31 +74,21 @@ */ public class JDOMParser extends XMLParser2 { -/** - * Temporary fix for JDOM problem - JDOM B9 does not properly handle - * isNamespaceAware = false - */ -public boolean isNamespaceAware() { -return true; -} - public Object parseXML(InputStream stream) { +if (!isNamespaceAware()) { +throw new JXPathException(JDOM parser configuration error. JDOM ++ does not support the namespaceAware=false setting.); +} + try { SAXBuilder builder = new SAXBuilder(); builder.setExpandEntities(isExpandEntityReferences()); builder.setIgnoringElementContentWhitespace( isIgnoringElementContentWhitespace()); builder.setValidation(isValidating()); -builder.setFeature( -http://xml.org/sax/features/namespaces;, -isNamespaceAware()); -builder.setFeature( -http://xml.org/sax/features/namespace-prefixes;, -false); return builder.build(stream); } catch (Exception ex) { -ex.printStackTrace(); throw new JXPathException(JDOM parser error, ex); } } 1.2 +5 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml/XMLParser2.java Index: XMLParser2.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml/XMLParser2.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- XMLParser2.java 18 Jan 2004 01:42:58 - 1.1 +++ XMLParser2.java 19 Jan 2004 22:17:02 - 1.2 @@ -73,7 +73,7 @@ public abstract class XMLParser2 implements XMLParser { private boolean validating = false; -private boolean namespaceAware = false; +private boolean namespaceAware = true; private boolean whitespace = false; private boolean expandEntityRef = true; private boolean ignoreComments = false; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [JXPath] Registering namespace prefixes - never mind
Chap, Sudhir, After some profound discussions on the [EMAIL PROTECTED] mailing list, I decided to roll back this new feature. I need to better understand the use case before I introduce this new API. Is the functionality you are referring to intended for use with Java objects? What is the meaning of a namespace URI in the context of Java objects? Please, give me as much information about this use case as possible. - Dmiri - Original Message - From: Dmitri Plotnikov [EMAIL PROTECTED] To: [EMAIL PROTECTED]; Jakarta Commons Users List [EMAIL PROTECTED]; Sudhir Rao [EMAIL PROTECTED] Cc: Jakarta Commons Developers List [EMAIL PROTECTED] Sent: Saturday, January 17, 2004 8:52 PM Subject: Re: [JXPath] Registering namespace prefixes Chap, I added registration of external namespaces to JXPath. My solution is a little different from the one proposed by Sudhir. The main difference in the API is that instead of calling registerNamespace directly on JXPathContext, you call it indirectly like this: JXPathContext context = JXPathContext.newContext(document); NamespaceManager nsm = context.getNamespaceManager(); nsm.registerNamespace (prefix, http://www.example.com/ns/sample;); Take a look at the NamespaceManager interface - you can supply your own implementation, which could perform very flexible customizations of namespace lookup. Please note that external namespaces are supported with DOM but not JDOM, because JDOM B9 at this point requires that all namespaces be explicitly declared in the XML file itself. Chap, Sudhir, if you guys get a chance to try out the new APIs to see if they address your needs, I will highly appreciate it. Thanks, - Dmitri - Original Message - From: Sudhir Rao [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Saturday, December 06, 2003 6:41 PM Subject: Re: [JXPath] Registering namespace prefixes I made some local modifications for this. I am not sure if adding that registerNamespace is the right way to do it, as I am not very familiar with the codebase. The changes I did locally were to a) Modify org.apache.commons.jxpath.ri.QName.java to include the namespace prefix (similar to the one in Apache Axis). Had to tweak it a bit to consider the prefix as the namespaceURI however to keep it compatible with existing code. b) Maintain a HashMap of prefixes to namespace URIs in the TreeCompiler class. c) Modify the TreeCompiler.qName(..) to populate the namespace URI in the QName instance returned. d) Add the registerNamespace method to JXPathContextReferenceImpl and JXPathContext which in turn call a registerNamespace in Compiler class. I can send across my changes if someone would like to look into it. -Sudhir From: Prasad A. Chodavarapu [EMAIL PROTECTED] Subject: [JXPath] Registering namespace prefixes Date: Wed, 3 Dec 2003 12:32:23 -0500 Content-Type: text/plain; charset=iso-8859-1 Hi All: Is there a way of registering a namespace prefix upfront in a JXPathContext so that I can then use that prefix in xpath expressions? Here's what I'm looking for, in pseudo-code. JXPathContext domContext = JXPathContext.newContext(document); domContext.registerNamespace (http://www.example.com/ns/sample, prefix); domContext.getValue(prefix:a/prefix:b); Thanks chap - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath project.xml
dmitri 2004/01/17 17:39:39 Modified:jxpath project.xml Log: Upgraded to JDOM B9 Revision ChangesPath 1.14 +1 -1 jakarta-commons/jxpath/project.xml Index: project.xml === RCS file: /home/cvs/jakarta-commons/jxpath/project.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- project.xml 25 Mar 2003 02:41:33 - 1.13 +++ project.xml 18 Jan 2004 01:39:39 - 1.14 @@ -57,7 +57,7 @@ /dependency dependency idjdom/id - versionb8/version + versionb9/version urlhttp://www.jdom.org/url /dependency dependency - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml XMLParser2.java JDOMParser.java DOMParser.java DocumentContainer.java
dmitri 2004/01/17 17:42:58 Modified:jxpath/src/java/org/apache/commons/jxpath/xml JDOMParser.java DOMParser.java DocumentContainer.java Added: jxpath/src/java/org/apache/commons/jxpath/xml XMLParser2.java Log: Added support for parser features Revision ChangesPath 1.5 +25 -6 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml/JDOMParser.java Index: JDOMParser.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml/JDOMParser.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JDOMParser.java 9 Oct 2003 21:31:42 - 1.4 +++ JDOMParser.java 18 Jan 2004 01:42:58 - 1.5 @@ -72,14 +72,33 @@ * @author Dmitri Plotnikov * @version $Revision$ $Date$ */ -public class JDOMParser implements XMLParser { - +public class JDOMParser extends XMLParser2 { + +/** + * Temporary fix for JDOM problem - JDOM B9 does not properly handle + * isNamespaceAware = false + */ +public boolean isNamespaceAware() { +return true; +} + public Object parseXML(InputStream stream) { try { SAXBuilder builder = new SAXBuilder(); +builder.setExpandEntities(isExpandEntityReferences()); +builder.setIgnoringElementContentWhitespace( +isIgnoringElementContentWhitespace()); +builder.setValidation(isValidating()); +builder.setFeature( +http://xml.org/sax/features/namespaces;, +isNamespaceAware()); +builder.setFeature( +http://xml.org/sax/features/namespace-prefixes;, +isNamespaceAware()); return builder.build(stream); } catch (Exception ex) { +ex.printStackTrace(); throw new JXPathException(JDOM parser error, ex); } } 1.5 +13 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml/DOMParser.java Index: DOMParser.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml/DOMParser.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- DOMParser.java9 Oct 2003 21:31:42 - 1.4 +++ DOMParser.java18 Jan 2004 01:42:58 - 1.5 @@ -73,12 +73,20 @@ * @author Dmitri Plotnikov * @version $Revision$ $Date$ */ -public class DOMParser implements XMLParser { +public class DOMParser extends XMLParser2 { public Object parseXML(InputStream stream) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + +factory.setValidating(isValidating()); +factory.setNamespaceAware(isNamespaceAware()); +factory.setIgnoringElementContentWhitespace( +isIgnoringElementContentWhitespace()); +factory.setExpandEntityReferences(isExpandEntityReferences()); +factory.setIgnoringComments(isIgnoringComments()); +factory.setCoalescing(isCoalescing()); return factory.newDocumentBuilder().parse(stream); } catch (Exception ex) { 1.8 +33 -7 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml/DocumentContainer.java Index: DocumentContainer.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/xml/DocumentContainer.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DocumentContainer.java9 Oct 2003 21:31:42 - 1.7 +++ DocumentContainer.java18 Jan 2004 01:42:58 - 1.8 @@ -81,7 +81,7 @@ * @author Dmitri Plotnikov * @version $Revision$ $Date$ */ -public class DocumentContainer implements Container { +public class DocumentContainer extends XMLParser2 implements Container { public static final String MODEL_DOM = DOM; public static final String MODEL_JDOM = JDOM; @@ -109,6 +109,14 @@ } /** + * Add a class of a custom XML parser. + * Parsers for the models DOM and JDOM are pre-registered. + */ +public static void registerXMLParser(String model, String parserClassName) { +parserClasses.put(model, parserClassName); +} + +/** * Use this constructor if the desired model is DOM. * * @param URL is a URL for an XML file. @@ -145,7 +153,7 @@ if (xmlURL != null
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/compiler Expression.java
dmitri 2004/01/17 17:43:30 Modified:jxpath/src/java/org/apache/commons/jxpath JXPathContext.java jxpath/src/java/org/apache/commons/jxpath/ri/axes RootContext.java jxpath/src/java/org/apache/commons/jxpath/ri/model NodePointer.java NodePointerFactory.java jxpath/src/test/org/apache/commons/jxpath/ri/compiler ExtensionFunctionTest.java CoreFunctionTest.java jxpath/src/test/org/apache/commons/jxpath/ri/model XMLModelTestCase.java BeanModelTestCase.java jxpath/src/test/org/apache/commons/jxpath/ri/model/dom DOMModelTest.java jxpath/src/test/org/apache/commons/jxpath/ri/model/jdom JDOMModelTest.java jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom JDOMNodePointer.java jxpath/src/java/org/apache/commons/jxpath/ri/model/dom DOMNodePointer.java jxpath/src/java/org/apache/commons/jxpath/ri JXPathContextReferenceImpl.java jxpath/src/java/org/apache/commons/jxpath/ri/compiler Expression.java Added: jxpath/src/java/org/apache/commons/jxpath BasicNamespaceManager.java NamespaceManager.java jxpath/src/test/org/apache/commons/jxpath/ri/model ExternalNamespaceTest.xml Log: Added support for external namespace registration Revision ChangesPath 1.20 +29 -4 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java Index: JXPathContext.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/JXPathContext.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- JXPathContext.java9 Oct 2003 21:31:38 - 1.19 +++ JXPathContext.java18 Jan 2004 01:43:29 - 1.20 @@ -432,6 +432,7 @@ protected IdentityManager idManager; protected KeyManager keyManager; protected HashMap decimalFormats; +protected NamespaceManager namespaceManager; private static JXPathContextFactory contextFactory; private static JXPathContext compilationContext; @@ -809,4 +810,28 @@ + no KeyManager has been specified); } } + +/** + * Install a namespace manager that will be used by the context + * to look up namespace URI's for prefixes. + */ +public void setNamespaceManager(NamespaceManager namespaceManager) { +this.namespaceManager = namespaceManager; +} + +/** + * Returns this context's namespace manager. If none has been installed, + * returns the key manager of the parent context, or the default + * namespace manager. + */ +public NamespaceManager getNamespaceManager() { +if (keyManager == null parentContext != null) { +return parentContext.getNamespaceManager(); +} +if (namespaceManager == null) { +namespaceManager = new BasicNamespaceManager(); +} +return namespaceManager; +} + } 1.1 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/BasicNamespaceManager.java Index: BasicNamespaceManager.java === /* * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/BasicNamespaceManager.java,v 1.1 2004/01/18 01:43:29 dmitri Exp $ * $Revision: 1.1 $ * $Date: 2004/01/18 01:43:29 $ * * * The Apache Software License, Version 1.1 * * * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in *the documentation and/or other materials provided with the *distribution. * * 3. The end-user documentation included with the redistribution, if *any, must include the following acknowledgement: * This product includes software developed by the *Apache Software Foundation (http://www.apache.org/). *Alternately, this acknowledgement may appear in the software itself
Re: [JXPath] Registering namespace prefixes
Chap, I added registration of external namespaces to JXPath. My solution is a little different from the one proposed by Sudhir. The main difference in the API is that instead of calling registerNamespace directly on JXPathContext, you call it indirectly like this: JXPathContext context = JXPathContext.newContext(document); NamespaceManager nsm = context.getNamespaceManager(); nsm.registerNamespace (prefix, http://www.example.com/ns/sample;); Take a look at the NamespaceManager interface - you can supply your own implementation, which could perform very flexible customizations of namespace lookup. Please note that external namespaces are supported with DOM but not JDOM, because JDOM B9 at this point requires that all namespaces be explicitly declared in the XML file itself. Chap, Sudhir, if you guys get a chance to try out the new APIs to see if they address your needs, I will highly appreciate it. Thanks, - Dmitri - Original Message - From: Sudhir Rao [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Saturday, December 06, 2003 6:41 PM Subject: Re: [JXPath] Registering namespace prefixes I made some local modifications for this. I am not sure if adding that registerNamespace is the right way to do it, as I am not very familiar with the codebase. The changes I did locally were to a) Modify org.apache.commons.jxpath.ri.QName.java to include the namespace prefix (similar to the one in Apache Axis). Had to tweak it a bit to consider the prefix as the namespaceURI however to keep it compatible with existing code. b) Maintain a HashMap of prefixes to namespace URIs in the TreeCompiler class. c) Modify the TreeCompiler.qName(..) to populate the namespace URI in the QName instance returned. d) Add the registerNamespace method to JXPathContextReferenceImpl and JXPathContext which in turn call a registerNamespace in Compiler class. I can send across my changes if someone would like to look into it. -Sudhir From: Prasad A. Chodavarapu [EMAIL PROTECTED] Subject: [JXPath] Registering namespace prefixes Date: Wed, 3 Dec 2003 12:32:23 -0500 Content-Type: text/plain; charset=iso-8859-1 Hi All: Is there a way of registering a namespace prefix upfront in a JXPathContext so that I can then use that prefix in xpath expressions? Here's what I'm looking for, in pseudo-code. JXPathContext domContext = JXPathContext.newContext(document); domContext.registerNamespace (http://www.example.com/ns/sample, prefix); domContext.getValue(prefix:a/prefix:b); Thanks chap - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom DOMNodeIterator.java
dmitri 2004/01/16 19:25:14 Modified:jxpath/src/test/org/apache/commons/jxpath/ri/model BeanModelTestCase.java XMLModelTestCase.java jxpath/src/java/org/apache/commons/jxpath/ri/model/dom DOMNodeIterator.java Log: Fixed a bug in DOMNodeIterator.previous(), which caused the function last() to fail. Revision ChangesPath 1.16 +19 -7 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/BeanModelTestCase.java Index: BeanModelTestCase.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/BeanModelTestCase.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- BeanModelTestCase.java9 Oct 2003 21:31:43 - 1.15 +++ BeanModelTestCase.java17 Jan 2004 03:25:14 - 1.16 @@ -99,11 +99,11 @@ } public void setUp() { -if (context == null) { +//if (context == null) { context = JXPathContext.newContext(createContextBean()); context.setLocale(Locale.US); context.setFactory(getAbstractFactory()); -} +//} } protected abstract Object createContextBean(); @@ -673,7 +673,19 @@ boolean(integers[position() 4]), Boolean.FALSE); -assertXPathValue(context, sum(integers), new Double(10)); +assertXPathValue(context, sum(integers), new Double(10)); + +assertXPathValueAndPointer( +context, +integers[last()], +new Integer(4), +/integers[4]); + +assertXPathValueAndPointer( +context, +//strings[last()], +String 3, +/beans[1]/strings[3]); } public void testBooleanPredicate() { 1.14 +14 -7 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java Index: XMLModelTestCase.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- XMLModelTestCase.java 9 Oct 2003 21:31:43 - 1.13 +++ XMLModelTestCase.java 17 Jan 2004 03:25:14 - 1.14 @@ -108,10 +108,10 @@ protected DocumentContainer createDocumentContainer() { return new DocumentContainer( -JXPathTestCase.class.getResource(Vendor.xml), -getModel()); +JXPathTestCase.class.getResource(Vendor.xml), +getModel()); } - + protected abstract AbstractFactory getAbstractFactory(); protected JXPathContext createContext() { @@ -759,5 +759,12 @@ context, boolean(vendor//promotion[../@stores = 'some']), Boolean.FALSE); +} + +public void testFunctionsLastAndPosition() { +assertXPathPointer( +context, +vendor//location[last()], +/vendor[1]/location[2]); } } 1.9 +17 -10 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodeIterator.java Index: DOMNodeIterator.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodeIterator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DOMNodeIterator.java 9 Oct 2003 21:31:41 - 1.8 +++ DOMNodeIterator.java 17 Jan 2004 03:25:14 - 1.9 @@ -97,13 +97,12 @@ } public NodePointer getNodePointer() { +if (position == 0) { +setPosition(1); +} if (child == null) { -if (!setPosition(1)) { -return null; -} -position = 0; +return null; } - return new DOMNodePointer(parent, child); } @@ -128,7 +127,15 @@ private boolean previous() { position--; if (!reverse) { -child = child.getPreviousSibling(); +if (position == 0) { +child = null; +} +else if (child == null) { +child = node.getLastChild(); +} +else { +child = child.getPreviousSibling(); +} while (child != null !testChild()) { child = child.getPreviousSibling
cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util MethodLookupUtils.java
dmitri 2004/01/16 19:25:51 Modified:jxpath/src/java/org/apache/commons/jxpath/util MethodLookupUtils.java Log: Allowed null to be passed as the parameters argument Revision ChangesPath 1.6 +12 -9 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/MethodLookupUtils.java Index: MethodLookupUtils.java === RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/util/MethodLookupUtils.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MethodLookupUtils.java9 Oct 2003 21:31:42 - 1.5 +++ MethodLookupUtils.java17 Jan 2004 03:25:51 - 1.6 @@ -88,7 +88,7 @@ Object[] parameters) { boolean tryExact = true; -int count = parameters.length; +int count = parameters == null ? 0 : parameters.length; Class types[] = new Class[count]; for (int i = 0; i count; i++) { Object param = parameters[i]; @@ -150,7 +150,7 @@ Object[] parameters) { boolean tryExact = true; -int count = parameters.length; +int count = parameters == null ? 0 : parameters.length; Class types[] = new Class[count]; for (int i = 0; i count; i++) { Object param = parameters[i]; @@ -214,7 +214,9 @@ String name, Object[] parameters) { -if (parameters.length 1 || parameters[0] == null) { +if (parameters == null +|| parameters.length 1 +|| parameters[0] == null) { return null; } @@ -295,11 +297,12 @@ ExpressionContext.class.isAssignableFrom(types[0])) { pi++; } -if (types.length != parameters.length + pi) { +int length = parameters == null ? 0 : parameters.length; +if (types.length != length + pi) { return NO_MATCH; } int totalMatch = EXACT_MATCH; -for (int i = 0; i parameters.length; i++) { +for (int i = 0; i length; i++) { int match = matchType(types[i + pi], parameters[i]); if (match == NO_MATCH) { return NO_MATCH; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]