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 Changes Path 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.java 9 Oct 2003 21:31:38 -0000 1.19 +++ JXPathContext.java 18 Jan 2004 01:43:29 -0000 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, * if and wherever such third-party acknowledgements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation and was * originally based on software copyright (c) 2001, Plotnix, Inc, * <http://www.plotnix.com/>. * For more information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.commons.jxpath; import java.util.HashMap; /** * The default implementation of NamespaceManager based on a simple HashMap. * * @author Dmitri Plotnikov * @version $Revision: 1.1 $ $Date: 2004/01/18 01:43:29 $ */ public class BasicNamespaceManager implements NamespaceManager { private HashMap prefixMap = new HashMap(); /** * @see NamespaceManager#getNamespaceURI(String, Pointer) */ public String getNamespaceURI(String prefix, Pointer context) { return (String) prefixMap.get(prefix); } /** * @see NamespaceManager#registerNamespace(String, String) */ public void registerNamespace(String prefix, String namespaceURI) { prefixMap.put(prefix, namespaceURI); } } 1.1 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/NamespaceManager.java Index: NamespaceManager.java =================================================================== /* * $Header: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/NamespaceManager.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, * if and wherever such third-party acknowledgements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation and was * originally based on software copyright (c) 2001, Plotnix, Inc, * <http://www.plotnix.com/>. * For more information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.commons.jxpath; /** * A delegate of JXPathContext that resolves prefixes into namespaceURI's. * * @author Dmitri Plotnikov * @version $Revision: 1.1 $ $Date: 2004/01/18 01:43:29 $ */ public interface NamespaceManager { /** * Given a prefix, returns a registered namespace URI. * @param prefix The namespace prefix to look up * @param context The location in the object graph (or XML file) defining * the context for the lookup. * @return namespace URI or null if the prefix is undefined. */ String getNamespaceURI(String prefix, Pointer context); /** * Registers a namespace defined in the global context. * * @param prefix * @param namespaceURI */ void registerNamespace(String prefix, String namespaceURI); } 1.14 +9 -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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- RootContext.java 9 Oct 2003 21:31:39 -0000 1.13 +++ RootContext.java 18 Jan 2004 01:43:29 -0000 1.14 @@ -136,8 +136,11 @@ pointer = (NodePointer) constant; } else { - pointer = - NodePointer.newNodePointer(new QName(null, ""), constant, null); + pointer = NodePointer.newNodePointer( + new QName(null, ""), + constant, + null, + jxpathContext.getNamespaceManager()); } return new InitialContext(new RootContext(jxpathContext, pointer)); } 1.20 +51 -7 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.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- NodePointer.java 9 Oct 2003 21:31:40 -0000 1.19 +++ NodePointer.java 18 Jan 2004 01:43:30 -0000 1.20 @@ -65,6 +65,7 @@ import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathException; +import org.apache.commons.jxpath.NamespaceManager; import org.apache.commons.jxpath.Pointer; import org.apache.commons.jxpath.ri.Compiler; import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl; @@ -94,21 +95,42 @@ /** * Allocates an entirely new NodePointer by iterating through all installed * NodePointerFactories until it finds one that can create a pointer. + * + * @deprecated Use instead + * [EMAIL PROTECTED] #newNodePointer(QName, Object, Locale, NamespaceManager) + * newNodePointer(QName, Object, Locale, NamespaceManager)} */ public static NodePointer newNodePointer( QName name, Object bean, Locale locale) { + return newNodePointer(name, bean, locale, null); + } + + /** + * Allocates an entirely new NodePointer by iterating through all installed + * NodePointerFactories until it finds one that can create a pointer. + */ + public static NodePointer newNodePointer( + QName name, + Object bean, + Locale locale, + NamespaceManager namespaceManager) + { + NodePointer pointer = null; if (bean == null) { - return new NullPointer(name, locale); + pointer = new NullPointer(name, locale); + pointer.setNamespaceManager(namespaceManager); + return pointer; } + NodePointerFactory[] factories = JXPathContextReferenceImpl.getNodePointerFactories(); for (int i = 0; i < factories.length; i++) { - NodePointer pointer = - factories[i].createNodePointer(name, bean, locale); + pointer = factories[i].createNodePointer(name, bean, locale); if (pointer != null) { + pointer.setNamespaceManager(namespaceManager); return pointer; } } @@ -142,6 +164,7 @@ protected NodePointer parent; protected Locale locale; + private NamespaceManager namespaceManager; protected NodePointer(NodePointer parent) { this.parent = parent; @@ -514,6 +537,27 @@ return name.toUpperCase().startsWith(lang.toUpperCase()); } + /** + * Installs the supplied manager as the namespace manager for this node + * pointer. The [EMAIL PROTECTED] #getNamespaceURI(String) getNamespaceURI(prefix)} + * uses this manager to resolve namespace prefixes. + * + * @param namespaceManager + */ + public void setNamespaceManager(NamespaceManager namespaceManager) { + this.namespaceManager = namespaceManager; + } + + public NamespaceManager getNamespaceManager() { + if (namespaceManager != null) { + return namespaceManager; + } + if (parent != null) { + return parent.getNamespaceManager(); + } + return null; + } + /** * Returns a NodeIterator that iterates over all children or all children * that match the given NodeTest, starting with the specified one. 1.6 +6 -6 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/NodePointerFactory.java Index: NodePointerFactory.java =================================================================== RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/NodePointerFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- NodePointerFactory.java 9 Oct 2003 21:31:40 -0000 1.5 +++ NodePointerFactory.java 18 Jan 2004 01:43:30 -0000 1.6 @@ -76,13 +76,13 @@ public interface NodePointerFactory { /** - * The factory name determines its position between other factories. + * The factory order number determines its position between other factories. */ int getOrder(); /** * Create a NodePointer for the supplied object. The node will represent - * the "root" object a path. + * the "root" object for a path. * * @return null if this factory does not recognize objects of the supplied * type. 1.10 +6 -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.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ExtensionFunctionTest.java 9 Oct 2003 21:31:43 -0000 1.9 +++ ExtensionFunctionTest.java 18 Jan 2004 01:43:30 -0000 1.10 @@ -391,7 +391,8 @@ return NodePointer.newNodePointer( null, object, - Locale.getDefault()); + Locale.getDefault(), + null); } public List getContextNodeList() { 1.7 +5 -5 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- CoreFunctionTest.java 9 Oct 2003 21:31:43 -0000 1.6 +++ CoreFunctionTest.java 18 Jan 2004 01:43:30 -0000 1.7 @@ -179,7 +179,7 @@ String key, String value) { - return NodePointer.newNodePointer(null, "42", null); + return NodePointer.newNodePointer(null, "42", null, null); } }); 1.15 +52 -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.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- XMLModelTestCase.java 17 Jan 2004 03:25:14 -0000 1.14 +++ XMLModelTestCase.java 18 Jan 2004 01:43:30 -0000 1.15 @@ -66,6 +66,7 @@ import org.apache.commons.jxpath.IdentityManager; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathTestCase; +import org.apache.commons.jxpath.NamespaceManager; import org.apache.commons.jxpath.Pointer; import org.apache.commons.jxpath.Variables; import org.apache.commons.jxpath.xml.DocumentContainer; @@ -113,7 +114,9 @@ } protected abstract AbstractFactory getAbstractFactory(); - + + protected abstract boolean isExternalNamespaceSupported(); + protected JXPathContext createContext() { JXPathContext context = JXPathContext.newContext(createDocumentContainer()); @@ -326,12 +329,13 @@ context, "vendor/location/address/city", "Fruit Market"); + // local-name(qualified) assertXPathValue( context, "local-name(vendor/product/price:amount)", "amount"); - + // local-name(non-qualified) assertXPathValue(context, "local-name(vendor/location)", "location"); @@ -352,7 +356,7 @@ // default namespace does not affect search assertXPathValue(context, "vendor/product/prix", "934.99"); - + // child:: with a wildcard assertXPathValue( context, @@ -766,5 +770,46 @@ context, "vendor//location[last()]", "/vendor[1]/location[2]"); + } + + public void testExternalNamespace() { + if (isExternalNamespaceSupported()) { + DocumentContainer container = new DocumentContainer( + XMLModelTestCase.class.getResource("ExternalNamespaceTest.xml"), + getModel()); + JXPathContext context = JXPathContext.newContext(container); + NamespaceManager nsm = context.getNamespaceManager(); + nsm.registerNamespace("quality", "qualityNS"); + nsm.registerNamespace("money", "priceNS"); + + assertXPathValueAndPointer( + context, + "//quality:color", + "orange", + "/vendor[1]/product[1]/quality:color[1]"); + + // It is supposed to figure out that the prefixes "money" and + // "value" map to the same namespaceURI + assertXPathValueAndPointer( + context, + "//value:price", + "1000.00", + "/vendor[1]/product[1]/money:price[1]"); + + assertXPathValue( + context, + "local-name(vendor/product/value:price)", + "price"); + + assertXPathValue( + context, + "name(vendor/product/quality:color)", + "qualityNS:color"); + + assertXPathValue( + context, + "namespace-uri(vendor/product/value:price)", + "priceNS"); + } } } 1.17 +8 -6 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.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- BeanModelTestCase.java 17 Jan 2004 03:25:14 -0000 1.16 +++ BeanModelTestCase.java 18 Jan 2004 01:43:30 -0000 1.17 @@ -138,7 +138,8 @@ (PropertyOwnerPointer) NodePointer.newNodePointer( new QName(null, "root"), createContextBean(), - Locale.getDefault()); + Locale.getDefault(), + null); NodeIterator it; @@ -200,7 +201,8 @@ (PropertyOwnerPointer) NodePointer.newNodePointer( new QName(null, "root"), createContextBean(), - Locale.getDefault()); + Locale.getDefault(), + null); NodeIterator it; PropertyPointer start = null; 1.1 jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/ExternalNamespaceTest.xml Index: ExternalNamespaceTest.xml =================================================================== <?xml version="1.0" ?> <vendor name="fruitco"> <product xmlns="productNS" xmlns:price="priceNS" xmlns:value="priceNS"> <price:amount price:discount="10%" discount="20%">45.95</price:amount> <price:sale stores="all"> <saleEnds>never</saleEnds> <promotion></promotion> </price:sale> <quality:color>orange</quality:color> <money:price>1000.00</money:price> </product> </vendor> 1.9 +9 -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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DOMModelTest.java 9 Oct 2003 21:31:44 -0000 1.8 +++ DOMModelTest.java 18 Jan 2004 01:43:30 -0000 1.9 @@ -80,6 +80,7 @@ */ public class DOMModelTest extends XMLModelTestCase { + /** * Construct a new instance of this test case. * @@ -104,6 +105,10 @@ return new TestDOMFactory(); } + protected boolean isExternalNamespaceSupported() { + return true; + } + protected String getXMLSignature( Object node, boolean elements, 1.9 +9 -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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- JDOMModelTest.java 9 Oct 2003 21:31:44 -0000 1.8 +++ JDOMModelTest.java 18 Jan 2004 01:43:30 -0000 1.9 @@ -102,7 +102,11 @@ protected String getModel() { return DocumentContainer.MODEL_JDOM; } - + + protected boolean isExternalNamespaceSupported() { + return false; // Until a bug preventing external NS in JDOM B9 is fixed + } + public void testID() { // id() is not supported by JDOM } 1.11 +10 -4 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.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JDOMNodePointer.java 9 Oct 2003 21:31:41 -0000 1.10 +++ JDOMNodePointer.java 18 Jan 2004 01:43:30 -0000 1.11 @@ -68,6 +68,7 @@ import org.apache.commons.jxpath.AbstractFactory; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathException; +import org.apache.commons.jxpath.NamespaceManager; import org.apache.commons.jxpath.ri.Compiler; import org.apache.commons.jxpath.ri.QName; import org.apache.commons.jxpath.ri.compiler.NodeNameTest; @@ -156,6 +157,11 @@ Element element = (Element) node; Namespace ns = element.getNamespace(prefix); if (ns == null) { + NamespaceManager manager = getNamespaceManager(); + if (manager != null) { + return manager.getNamespaceURI(prefix, this); + } + return null; } return ns.getURI(); 1.19 +11 -4 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.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- DOMNodePointer.java 9 Oct 2003 21:31:41 -0000 1.18 +++ DOMNodePointer.java 18 Jan 2004 01:43:30 -0000 1.19 @@ -68,6 +68,7 @@ import org.apache.commons.jxpath.AbstractFactory; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathException; +import org.apache.commons.jxpath.NamespaceManager; import org.apache.commons.jxpath.Pointer; import org.apache.commons.jxpath.ri.Compiler; import org.apache.commons.jxpath.ri.QName; @@ -274,6 +275,12 @@ } } aNode = aNode.getParentNode(); + } + if (namespace == null) { + NamespaceManager manager = getNamespaceManager(); + if (manager != null) { + namespace = manager.getNamespaceURI(prefix, this); + } } if (namespace == null || namespace.equals("")) { namespace = NodePointer.UNKNOWN_NAMESPACE; 1.36 +13 -7 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.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- JXPathContextReferenceImpl.java 9 Oct 2003 21:31:38 -0000 1.35 +++ JXPathContextReferenceImpl.java 18 Jan 2004 01:43:30 -0000 1.36 @@ -181,14 +181,16 @@ NodePointer.newNodePointer( new QName(null, "root"), contextPointer.getRootNode(), - getLocale()); + getLocale(), + getNamespaceManager()); } else { this.contextPointer = NodePointer.newNodePointer( new QName(null, "root"), contextBean, - getLocale()); + getLocale(), + getNamespaceManager()); this.rootPointer = this.contextPointer; } } @@ -374,7 +376,11 @@ return (Pointer) result; } else { - return NodePointer.newNodePointer(null, result, getLocale()); + return NodePointer.newNodePointer( + null, + result, + getLocale(), + getNamespaceManager()); } } 1.8 +24 -5 jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/compiler/Expression.java Index: Expression.java =================================================================== RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/compiler/Expression.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Expression.java 9 Oct 2003 21:31:39 -0000 1.7 +++ Expression.java 18 Jan 2004 01:43:30 -0000 1.8 @@ -61,6 +61,7 @@ */ package org.apache.commons.jxpath.ri.compiler; +import org.apache.commons.jxpath.NamespaceManager; import org.apache.commons.jxpath.Pointer; import org.apache.commons.jxpath.ri.EvalContext; import org.apache.commons.jxpath.ri.model.NodePointer; @@ -139,11 +140,25 @@ private Iterator iterator; private QName qname; private Locale locale; + private NamespaceManager namespaceManager; + /** + * @deprecated Use the method that takes a NamespaceManager + */ public PointerIterator(Iterator it, QName qname, Locale locale) { + this(it, qname, locale, null); + } + + public PointerIterator( + Iterator it, + QName qname, + Locale locale, + NamespaceManager namespaceManager) + { this.iterator = it; this.qname = qname; this.locale = locale; + this.namespaceManager = namespaceManager; } public boolean hasNext() { @@ -152,7 +167,11 @@ public Object next() { Object o = iterator.next(); - return NodePointer.newNodePointer(qname, o, locale); + return NodePointer.newNodePointer( + qname, + o, + locale, + namespaceManager); } public void remove() {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]