commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmi...@apache.org
Subject cvs commit: jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/container ContainerPointer.java
Date Thu, 01 Apr 2004 02:55:32 GMT
dmitri      2004/03/31 18:55:32

  Modified:    jxpath/src/test/org/apache/commons/jxpath Vendor.xml
               jxpath/src/java/org/apache/commons/jxpath/ri/axes
                        SimplePathInterpreter.java RootContext.java
               jxpath/src/java/org/apache/commons/jxpath JXPathContext.java
               jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom
                        JDOMNamespaceIterator.java
                        JDOMNamespacePointer.java JDOMAttributePointer.java
                        JDOMNodePointer.java
               jxpath/src/java/org/apache/commons/jxpath/ri
                        JXPathContextReferenceImpl.java
               jxpath/src/java/org/apache/commons/jxpath/ri/model
                        NodePointer.java
               jxpath/src/test/org/apache/commons/jxpath/ri/model
                        XMLModelTestCase.java
               jxpath/src/java/org/apache/commons/jxpath/ri/model/dom
                        DOMNodeIterator.java DOMNodePointer.java
                        NamespacePointer.java DOMNamespaceIterator.java
                        DOMAttributePointer.java
               jxpath/src/java/org/apache/commons/jxpath/ri/compiler
                        NodeNameTest.java Path.java
               jxpath/src/java/org/apache/commons/jxpath/ri/model/beans
                        LangAttributePointer.java
               jxpath/src/java/org/apache/commons/jxpath/ri/model/container
                        ContainerPointer.java
  Added:       jxpath/src/java/org/apache/commons/jxpath/ri
                        NamespaceResolver.java
  Removed:     jxpath/src/test/org/apache/commons/jxpath/ri/model
                        ExternalNamespaceTest.xml
  Log:
  Introduced prefix registration with JXPathContext
  Fixed a number or problems with namespace matching
  
  Revision  Changes    Path
  1.9       +4 -4      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Vendor.xml	20 Jan 2003 00:00:27 -0000	1.8
  +++ Vendor.xml	1 Apr 2004 02:55:31 -0000	1.9
  @@ -12,7 +12,7 @@
     <!ELEMENT product ANY>
   ]>
   
  -<vendor name="fruitco">
  +<vendor name="fruitco" xmlns:price="priceNS">
     <contact>John</contact>
     <contact name='jack'>Jack</contact>
     <contact name='jim'>Jim</contact>
  @@ -33,11 +33,11 @@
       Text after address.
     </location>
   
  -  <product xmlns="productNS" xmlns:price="priceNS" xmlns:value="priceNS">
  -     <name>Box of oranges</name>
  +  <product xmlns:value="priceNS">
  +     <name xmlns="productNS">Box of oranges</name>
        We love this product.
        <!-- We are not buying this product, ever -->
  -     <price:amount price:discount="10%" discount="20%">45.95</price:amount>
  +     <value:amount price:discount="10%" discount="20%">45.95</value:amount>
        <prix xml:lang="fr">934.99</prix>
        <price:sale stores="all">
           <saleEnds>never</saleEnds>
  
  
  
  1.16      +15 -4     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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SimplePathInterpreter.java	25 Mar 2004 03:49:50 -0000	1.15
  +++ SimplePathInterpreter.java	1 Apr 2004 02:55:31 -0000	1.16
  @@ -27,6 +27,7 @@
   import org.apache.commons.jxpath.ri.compiler.Expression;
   import org.apache.commons.jxpath.ri.compiler.NameAttributeTest;
   import org.apache.commons.jxpath.ri.compiler.NodeNameTest;
  +import org.apache.commons.jxpath.ri.compiler.NodeTest;
   import org.apache.commons.jxpath.ri.compiler.Step;
   import org.apache.commons.jxpath.ri.model.NodeIterator;
   import org.apache.commons.jxpath.ri.model.NodePointer;
  @@ -252,7 +253,7 @@
   
           int bestQuality = 0;
           NodePointer bestMatch = null;
  -        NodeIterator it = getNodeIterator(parentPointer, step);
  +        NodeIterator it = getNodeIterator(context, parentPointer, step);
           if (it != null) {
               for (int i = 1; it.setPosition(i); i++) {
                   NodePointer childPointer = it.getNodePointer();
  @@ -368,7 +369,7 @@
           // It is a very common use case, so it deserves individual
           // attention
           if (predicates.length == 1) {
  -            NodeIterator it = getNodeIterator(parent, step);
  +            NodeIterator it = getNodeIterator(context, parent, step);
               NodePointer pointer = null;
               if (it != null) {
                   if (predicate instanceof NameAttributeTest) { // [@name = key]
  @@ -393,7 +394,7 @@
               }
           }
           else {
  -            NodeIterator it = getNodeIterator(parent, step);
  +            NodeIterator it = getNodeIterator(context, parent, step);
               if (it != null) {
                   List list = new ArrayList();
                   for (int i = 1; it.setPosition(i); i++) {
  @@ -806,11 +807,21 @@
       }
   
       private static NodeIterator getNodeIterator(
  +        EvalContext context,
           NodePointer pointer,
           Step step) 
       {
           if (step.getAxis() == Compiler.AXIS_CHILD) {
  -            return pointer.childIterator(step.getNodeTest(), false, null);
  +            NodeTest nodeTest = step.getNodeTest();
  +            QName qname = ((NodeNameTest) nodeTest).getNodeName();
  +            String prefix = qname.getPrefix();
  +            if (prefix != null) {
  +                String namespaceURI = context.getJXPathContext()
  +                        .getNamespaceURI(prefix);
  +                nodeTest = new NodeNameTest(qname, namespaceURI);
  +
  +            }
  +            return pointer.childIterator(nodeTest, false, null);
           }
           else { // Compiler.AXIS_ATTRIBUTE
               if (!(step.getNodeTest() instanceof NodeNameTest)) {
  
  
  
  1.18      +6 -1      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- RootContext.java	25 Mar 2004 05:42:01 -0000	1.17
  +++ RootContext.java	1 Apr 2004 02:55:31 -0000	1.18
  @@ -20,6 +20,7 @@
   import org.apache.commons.jxpath.NodeSet;
   import org.apache.commons.jxpath.ri.EvalContext;
   import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
  +import org.apache.commons.jxpath.ri.NamespaceResolver;
   import org.apache.commons.jxpath.ri.QName;
   import org.apache.commons.jxpath.ri.model.NodePointer;
   
  @@ -34,6 +35,7 @@
       private NodePointer pointer;
       private Object registers[];
       private int availableRegister = 0;
  +    private NamespaceResolver namespaceResolver;
       public static final Object UNKNOWN_VALUE = new Object();
       private static final int MAX_REGISTER = 4;
   
  @@ -44,6 +46,9 @@
           super(null);
           this.jxpathContext = jxpathContext;
           this.pointer = pointer;
  +        if (pointer != null) {
  +            pointer.setNamespaceResolver(jxpathContext.getNamespaceResolver());
  +        }
       }
   
       public JXPathContext getJXPathContext() {
  
  
  
  1.23      +52 -26    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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JXPathContext.java	29 Feb 2004 14:17:42 -0000	1.22
  +++ JXPathContext.java	1 Apr 2004 02:55:31 -0000	1.23
  @@ -386,7 +386,6 @@
       protected IdentityManager idManager;
       protected KeyManager keyManager;
       protected HashMap decimalFormats;
  -//    protected NamespaceManager namespaceManager;
   
       private static JXPathContextFactory contextFactory;
       private static JXPathContext compilationContext;
  @@ -765,28 +764,55 @@
           }
       }
   
  -// 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;
  -//    }
  -
  +    /**
  +     * Registers a namespace prefix.
  +     * 
  +     * @param prefix A namespace prefix
  +     * @param namespaceURI A URI for that prefix
  +     */
  +    public void registerNamespace(String prefix, String namespaceURI) {
  +        throw new UnsupportedOperationException(
  +                "Namespace registration is not implemented by " + getClass());
  +    }
  +    
  +    /**
  +     * Given a prefix, returns a registered namespace URI. If the requested
  +     * prefix was not defined explicitly using the registerNamespace method,
  +     * JXPathContext will then check the context node to see if the prefix is
  +     * defined there. See
  +     * {@link #setNamespaceContextPointer(Pointer) setNamespaceContextPointer}.
  +     * 
  +     * @param prefix The namespace prefix to look up
  +     * @return namespace URI or null if the prefix is undefined.
  +     */
  +    public String getNamespaceURI(String prefix) {
  +        throw new UnsupportedOperationException(
  +                "Namespace registration is not implemented by " + getClass());
  +    }
  +    
  +    /**
  +     * Namespace prefixes can be defined implicitly by specifying a pointer to a
  +     * context where the namespaces are defined. By default,
  +     * NamespaceContextPointer is the same as the Context Pointer, see
  +     * {@link #getContextPointer() getContextPointer()}
  +     * 
  +     * @param contextPointer The pointer to the context where prefixes used in
  +     *        XPath expressions should be resolved.
  +     */
  +    public void setNamespaceContextPointer(Pointer namespaceContextPointer) {
  +        throw new UnsupportedOperationException(
  +                "Namespace registration is not implemented by " + getClass());
  +    }
  +    
  +    /**
  +     * Returns the namespace context pointer set with
  +     * {@link #setNamespaceContextPointer(Pointer) setNamespaceContextPointer()}
  +     * or, if none has been specified, the context pointer otherwise.
  +     * 
  +     * @return The namespace context pointer.
  +     */
  +    public Pointer getNamespaceContextPointer() {
  +        throw new UnsupportedOperationException(
  +                "Namespace registration is not implemented by " + getClass());
  +    }
   }
  
  
  
  1.9       +9 -2      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JDOMNamespaceIterator.java	4 Mar 2004 01:01:27 -0000	1.8
  +++ JDOMNamespaceIterator.java	1 Apr 2004 02:55:31 -0000	1.9
  @@ -22,6 +22,7 @@
   
   import org.apache.commons.jxpath.ri.model.NodeIterator;
   import org.apache.commons.jxpath.ri.model.NodePointer;
  +import org.jdom.Document;
   import org.jdom.Element;
   import org.jdom.Namespace;
   
  @@ -40,10 +41,13 @@
       public JDOMNamespaceIterator(NodePointer parent) {
           this.parent = parent;
           Object node = parent.getNode();
  +        if (node instanceof Document) {
  +            node = ((Document)node).getRootElement();
  +        }
           if (node instanceof Element) {
               namespaces = new ArrayList();
               prefixes = new HashSet();
  -            collectNamespaces((Element) parent.getNode());
  +            collectNamespaces((Element) node);
           }
       }
   
  @@ -87,6 +91,9 @@
       }
   
       public boolean setPosition(int position) {
  +        if (namespaces == null) {
  +            return false;
  +        }
           this.position = position;
           return position >= 1 && position <= namespaces.size();
       }
  
  
  
  1.9       +2 -2      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNamespacePointer.java
  
  Index: JDOMNamespacePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNamespacePointer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JDOMNamespacePointer.java	29 Feb 2004 14:17:40 -0000	1.8
  +++ JDOMNamespacePointer.java	1 Apr 2004 02:55:31 -0000	1.9
  @@ -44,7 +44,7 @@
       }
   
       public QName getName() {
  -        return new QName(getNamespaceURI(), prefix);
  +        return new QName(prefix);
       }
   
       public Object getBaseValue() {
  
  
  
  1.10      +1 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMAttributePointer.java
  
  Index: JDOMAttributePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMAttributePointer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JDOMAttributePointer.java	29 Feb 2004 14:17:40 -0000	1.9
  +++ JDOMAttributePointer.java	1 Apr 2004 02:55:31 -0000	1.10
  @@ -40,10 +40,6 @@
               JDOMNodePointer.getLocalName(attr));
       }
   
  -    public QName getExpandedName() {
  -        return new QName(getNamespaceURI(),  attr.getName());
  -    }
  -
       public String getNamespaceURI() {
           String uri = attr.getNamespaceURI();
           if (uri != null && uri.equals("")) {
  
  
  
  1.16      +68 -33    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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JDOMNodePointer.java	25 Mar 2004 05:41:29 -0000	1.15
  +++ JDOMNodePointer.java	1 Apr 2004 02:55:31 -0000	1.16
  @@ -94,6 +94,10 @@
       }
   
       public String getNamespaceURI() {
  +        return getNamespaceURI(node);
  +    }
  +    
  +    private static String getNamespaceURI(Object node) {
           if (node instanceof Element) {
               Element element = (Element) node;
               String ns = element.getNamespaceURI();
  @@ -106,18 +110,19 @@
       }
   
       public String getNamespaceURI(String prefix) {
  -        if (node instanceof Element) {
  +        if (node instanceof Document) {
  +            Element element = ((Document)node).getRootElement(); 
  +            Namespace ns = element.getNamespace(prefix);
  +            if (ns != null) {
  +                return ns.getURI();
  +            }
  +        }        
  +        else if (node instanceof Element) {
               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;
  +            if (ns != null) {
  +                return ns.getURI();
               }
  -            return ns.getURI();
           }
           return null;
       }
  @@ -222,10 +227,6 @@
           return new QName(ns, ln);
       }
   
  -    public QName getExpandedName() {
  -        return new QName(getNamespaceURI(), getName().getName());
  -    }
  -
       /**
        * @see org.apache.commons.jxpath.ri.model.NodePointer#getNode()
        */
  @@ -353,27 +354,20 @@
   
               NodeNameTest nodeNameTest = (NodeNameTest) test;
               QName testName = nodeNameTest.getNodeName();
  +            String namespaceURI = nodeNameTest.getNamespaceURI();
               boolean wildcard = nodeNameTest.isWildcard();
  -            if (wildcard && testName.getPrefix() == null) {
  +            String testPrefix = testName.getPrefix();
  +            if (wildcard && testPrefix == null) {
                   return true;
               }
   
               if (wildcard
  -                || testName.getName().equals(
  -                    JDOMNodePointer.getLocalName((Element) node))) {
  -                String testPrefix = testName.getPrefix();
  -                String nodePrefix = JDOMNodePointer.getPrefix((Element) node);
  -                if (equalStrings(testPrefix, nodePrefix)) {
  -                    return true;
  -                }
  -
  -                String testNS = pointer.getNamespaceURI(testPrefix);
  -                if (testNS == null) {
  -                    return false;
  -                }
  -                String nodeNS = pointer.getNamespaceURI(nodePrefix);
  -                return equalStrings(testNS, nodeNS);
  +                || testName.getName()
  +                        .equals(JDOMNodePointer.getLocalName(node))) {
  +                String nodeNS = JDOMNodePointer.getNamespaceURI(node);
  +                return equalStrings(namespaceURI, nodeNS);
               }
  +
           }
           else if (test instanceof NodeTypeTest) {
               switch (((NodeTypeTest) test).getNodeType()) {
  @@ -583,10 +577,32 @@
                       || buffer.charAt(buffer.length() - 1) != '/') {
                       buffer.append('/');
                   }
  -                buffer.append(getName());
  -                buffer.append('[');
  -                buffer.append(getRelativePositionByName());
  -                buffer.append(']');
  +                String nsURI = getNamespaceURI();
  +                String ln = JDOMNodePointer.getLocalName(node);
  +                
  +                if (nsURI == null) {
  +                    buffer.append(ln);
  +                    buffer.append('[');
  +                    buffer.append(getRelativePositionByName()).append(']');
  +                }
  +                else {
  +                    String prefix = getNamespaceResolver().getPrefix(nsURI);
  +                    if (prefix != null) {
  +                        buffer.append(prefix);
  +                        buffer.append(':');
  +                        buffer.append(ln);
  +                        buffer.append('[');
  +                        buffer.append(getRelativePositionByName());
  +                        buffer.append(']');
  +                    }
  +                    else {
  +                        buffer.append("node()");
  +                        buffer.append('[');
  +                        buffer.append(getRelativePositionOfElement());
  +                        buffer.append(']');
  +                    }
  +                }
  +
               }
           }
           else if (node instanceof Text || node instanceof CDATA) {
  @@ -647,6 +663,25 @@
               return count;
           }
           return 1;
  +    }
  +    
  +    private int getRelativePositionOfElement() {
  +        Element parent = (Element) ((Element) node).getParent();
  +        if (parent == null) {
  +            return 1;
  +        }
  +        List children = parent.getContent();
  +        int count = 0;
  +        for (int i = 0; i < children.size(); i++) {
  +            Object child = children.get(i);
  +            if (child instanceof Element) {
  +                count++;
  +            }
  +            if (child == node) {
  +                break;
  +            }
  +        }
  +        return count;
       }
   
       private int getRelativePositionOfTextNode() {
  
  
  
  1.41      +40 -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.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- JXPathContextReferenceImpl.java	25 Mar 2004 03:49:50 -0000	1.40
  +++ JXPathContextReferenceImpl.java	1 Apr 2004 02:55:32 -0000	1.41
  @@ -109,6 +109,8 @@
   
       private Pointer rootPointer;
       private Pointer contextPointer;
  +    
  +    protected NamespaceResolver namespaceResolver;
   
       // The frequency of the cache cleanup
       private static final int CLEANUP_THRESHOLD = 500;
  @@ -146,6 +148,10 @@
                       getLocale());
               this.rootPointer = this.contextPointer;
           }
  +        
  +        namespaceResolver = new NamespaceResolver();
  +        namespaceResolver
  +                .setNamespaceContextPointer((NodePointer) this.contextPointer);
       }
   
       private static void createNodeFactoryArray() {
  @@ -591,13 +597,13 @@
       }
   
       private EvalContext getEvalContext() {
  -        return new InitialContext(
  -            new RootContext(this, (NodePointer) getContextPointer()));
  +        return new InitialContext(new RootContext(this,
  +                (NodePointer) getContextPointer()));
       }
   
       public EvalContext getAbsoluteRootContext() {
  -        return new InitialContext(
  -            new RootContext(this, getAbsoluteRootPointer()));
  +        return new InitialContext(new RootContext(this,
  +                getAbsoluteRootPointer()));
       }
   
       public NodePointer getVariablePointer(QName name) {
  @@ -643,11 +649,37 @@
           throw new JXPathException(
               "Undefined function: " + functionName.toString());
       }
  +    
  +    public void registerNamespace(String prefix, String namespaceURI) {
  +        if (namespaceResolver.isSealed()) {            
  +            namespaceResolver = (NamespaceResolver) namespaceResolver.clone();
  +        }
  +        namespaceResolver.registerNamespace(prefix, namespaceURI);
  +    }
  +    
  +    public String getNamespaceURI(String prefix) {
  +        return namespaceResolver.getNamespaceURI(prefix);
  +    }
  +    
  +    public void setNamespaceContextPointer(Pointer pointer) {
  +        if (namespaceResolver.isSealed()) {
  +            namespaceResolver = (NamespaceResolver) namespaceResolver.clone();
  +        }
  +        namespaceResolver.setNamespaceContextPointer((NodePointer) pointer);
  +    }
  +    
  +    public Pointer getNamespaceContextPointer() {
  +        return namespaceResolver.getNamespaceContextPointer();
  +    }
   
  +    public NamespaceResolver getNamespaceResolver() {
  +        namespaceResolver.seal();
  +        return namespaceResolver;
  +    }
  +    
       /**
  -     * Checks if existenceCheckClass exists on the class path. If so,
  -     * allocates an instance of the specified class, otherwise
  -     * returns null.
  +     * Checks if existenceCheckClass exists on the class path. If so, allocates
  +     * an instance of the specified class, otherwise returns null.
        */
       public static Object allocateConditionally(
               String className,
  
  
  
  1.1                  jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
  
  Index: NamespaceResolver.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;
  
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.commons.jxpath.Pointer;
  import org.apache.commons.jxpath.ri.model.NodeIterator;
  import org.apache.commons.jxpath.ri.model.NodePointer;
  
  /**
   * The reference implementation of JXPathContext.
   *
   * @author Dmitri Plotnikov
   * @version $Revision: 1.1 $ $Date: 2004/04/01 02:55:32 $
   */
  public class NamespaceResolver implements Cloneable {
      
      protected HashMap namespaceMap = new HashMap();
      protected HashMap reverseMap;
      protected NodePointer pointer;
      private boolean sealed;
      
      /**
       * Registers a namespace prefix.
       * 
       * @param prefix A namespace prefix
       * @param namespaceURI A URI for that prefix
       */
      public void registerNamespace(String prefix, String namespaceURI) {
          namespaceMap.put(prefix, namespaceURI);
      }
      
      /**
       * Register a namespace for the expression context.
       */
      public void setNamespaceContextPointer(NodePointer pointer) {
          this.pointer = pointer;
      }
      
      public Pointer getNamespaceContextPointer() {
          return pointer;
      }
      
      /**
       * Given a prefix, returns a registered namespace URI. If the requested
       * prefix was not defined explicitly using the registerNamespace method,
       * JXPathContext will then check the context node to see if the prefix is
       * defined there. See
       * {@link #setNamespaceContextPointer(Pointer) setNamespaceContextPointer}.
       * 
       * @param prefix The namespace prefix to look up
       * @return namespace URI or null if the prefix is undefined.
       */
      public String getNamespaceURI(String prefix) {
          String uri = (String) namespaceMap.get(prefix);
          if (uri == null && pointer != null) {
              uri = pointer.getNamespaceURI(prefix);
          }
  //        System.err.println("For prefix " + prefix + " URI=" + uri);
          return uri;
      }
      
      public String getPrefix(String namespaceURI) {
          if (reverseMap == null) {
              reverseMap = new HashMap();
              NodeIterator ni = pointer.namespaceIterator();
              if (ni != null) {
                  for (int position = 1; ni.setPosition(position); position++) {
                      NodePointer nsPointer = ni.getNodePointer();
                      QName qname = nsPointer.getName();
                      reverseMap.put(qname.getPrefix(), qname.getName());
                  }
              }
              Iterator it = namespaceMap.entrySet().iterator();
              while (it.hasNext()) {
                  Map.Entry entry = (Map.Entry) it.next();
                  reverseMap.put(entry.getValue(), entry.getKey());
              }
          }
          String prefix = (String) reverseMap.get(namespaceURI);
          return prefix;
      }
      
      public boolean isSealed() {
          return sealed;
      }
      
      public void seal() {
          sealed = true;
      }
      
      public Object clone() {
          try {
              return super.clone();
          }
          catch (CloneNotSupportedException e) {
              // Of course, it's supported.
              e.printStackTrace();
              return null;
          }
      }
  }
  
  
  1.25      +15 -10    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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- NodePointer.java	25 Mar 2004 05:41:29 -0000	1.24
  +++ NodePointer.java	1 Apr 2004 02:55:32 -0000	1.25
  @@ -22,6 +22,7 @@
   import org.apache.commons.jxpath.Pointer;
   import org.apache.commons.jxpath.ri.Compiler;
   import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
  +import org.apache.commons.jxpath.ri.NamespaceResolver;
   import org.apache.commons.jxpath.ri.QName;
   import org.apache.commons.jxpath.ri.compiler.NodeNameTest;
   import org.apache.commons.jxpath.ri.compiler.NodeTest;
  @@ -44,7 +45,8 @@
       public static final String UNKNOWN_NAMESPACE = "<<unknown namespace>>";
       private boolean attribute = false;
       private transient Object rootNode;
  -
  +    private NamespaceResolver namespaceResolver;
  +    
       /**
        * Allocates an entirely new NodePointer by iterating through all installed
        * NodePointerFactories until it finds one that can create a pointer.
  @@ -109,6 +111,17 @@
           this.locale = locale;
       }
   
  +    public NamespaceResolver getNamespaceResolver() {
  +        if (namespaceResolver == null && parent != null) {
  +            namespaceResolver = parent.getNamespaceResolver();
  +        }
  +        return namespaceResolver;
  +    }
  +    
  +    public void setNamespaceResolver(NamespaceResolver namespaceResolver) {
  +        this.namespaceResolver = namespaceResolver;
  +    }
  +    
       public NodePointer getParent() {
           NodePointer pointer = parent;
           while (pointer != null && pointer.isContainer()) {
  @@ -580,14 +593,6 @@
   
       protected String getDefaultNamespaceURI() {
           return null;
  -    }
  -
  -    /**
  -     * Returns a name that consists of the namespaceURI and the local name
  -     * of the node.  For non-XML pointers, returns the Pointer's qualified name.
  -     */
  -    public QName getExpandedName() {
  -        return getName();
       }
   
       /**
  
  
  
  1.21      +32 -22    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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- XMLModelTestCase.java	2 Mar 2004 01:32:20 -0000	1.20
  +++ XMLModelTestCase.java	1 Apr 2004 02:55:32 -0000	1.21
  @@ -72,6 +72,7 @@
           JXPathContext context =
               JXPathContext.newContext(createDocumentContainer());
           context.setFactory(getAbstractFactory());
  +        context.registerNamespace("product", "productNS");
           return context;
       }
   
  @@ -231,9 +232,9 @@
           
           assertXPathCreatePathAndSetValue(
               context,
  -            "vendor/product/name/attribute::price:language",
  +            "vendor/product/product:name/attribute::price:language",
               "English",
  -            "/vendor[1]/product[1]/name[1]/@price:language");
  +            "/vendor[1]/product[1]/product:name[1]/@price:language");
       }
   
       /**
  @@ -306,7 +307,7 @@
           assertXPathValue(
               context,
               "name(vendor/product/price:amount)",
  -            "priceNS:amount");
  +            "value:amount");
   
           // name (non-qualified)
           assertXPathValue(
  @@ -351,12 +352,6 @@
               "count(vendor/product/price:*)",
               new Double(2));
   
  -        // child:: with a namespace and wildcard
  -        assertXPathValue(
  -            context,
  -            "count(vendor/product/value:*)",
  -            new Double(2));
  -
           // child:: with the default namespace
           assertXPathValue(context, "count(vendor/product/*)", new Double(4));
   
  @@ -467,11 +462,7 @@
               context,
               "vendor/product/price:amount/@price:discount",
               "10%");
  -        assertXPathValue(
  -            context,
  -            "vendor/product/value:amount/@value:discount",
  -            "10%");
  -
  +        
           // namespace uri for an attribute
           assertXPathValue(
               context,
  @@ -488,7 +479,7 @@
           assertXPathValue(
               context,
               "name(vendor/product/price:amount/@price:discount)",
  -            "priceNS:discount");
  +            "price:discount");
   
           // attribute:: with the default namespace
           assertXPathValue(
  @@ -566,7 +557,7 @@
           assertXPathValue(
               context,
               "name(vendor/product/prix/namespace::price)",
  -            "priceNS:price");
  +            "price");
   
           // local name of namespace
           assertXPathValue(
  @@ -760,10 +751,29 @@
                   "/vendor[1]/location[2]");
       }
   
  -// TODO: either complete the external namespace functionality, or get rid of
  -// this test.
  -//
  -//    public void testExternalNamespace() {
  +    public void testNamespaceMapping() {
  +        context.registerNamespace("rate", "priceNS");
  +        context.registerNamespace("goods", "productNS");
  +
  +        assertEquals("Context node namespace resolution", 
  +                "priceNS", 
  +                context.getNamespaceURI("price"));        
  +        
  +        assertEquals("Registered namespace resolution", 
  +                "priceNS", 
  +                context.getNamespaceURI("rate"));
  +
  +        // child:: with a namespace and wildcard
  +        assertXPathValue(context, 
  +                "count(vendor/product/rate:*)", 
  +                new Double(2));
  +
  +        // Preference for externally registered namespace prefix
  +        assertXPathValueAndPointer(context,
  +                "//product:name",
  +                "Box of oranges",
  +                "/vendor[1]/product[1]/goods:name[1]");
  +        
   //        if (isExternalNamespaceSupported()) {
   //             DocumentContainer container = new DocumentContainer(
   //                    XMLModelTestCase.class.getResource("ExternalNamespaceTest.xml"),
  @@ -802,5 +812,5 @@
   //                    "namespace-uri(vendor/product/value:price)",
   //                    "priceNS");
   //        }
  -//    }
  +    }
   }
  
  
  
  1.11      +2 -3      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DOMNodeIterator.java	29 Feb 2004 14:17:44 -0000	1.10
  +++ DOMNodeIterator.java	1 Apr 2004 02:55:32 -0000	1.11
  @@ -29,7 +29,6 @@
   public class DOMNodeIterator implements NodeIterator {
       private NodePointer parent;
       private NodeTest nodeTest;
  -    private String namespaceURI;
       private Node node;
       private Node child = null;
       private boolean reverse;
  @@ -141,6 +140,6 @@
       }
   
       private boolean testChild() {
  -        return DOMNodePointer.testNode(parent, child, nodeTest);
  +        return DOMNodePointer.testNode(child, nodeTest);
       }
   }
  
  
  
  1.23      +103 -33   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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DOMNodePointer.java	25 Mar 2004 05:41:29 -0000	1.22
  +++ DOMNodePointer.java	1 Apr 2004 02:55:32 -0000	1.23
  @@ -74,14 +74,12 @@
           super(parent);
           this.node = node;
       }
  -
  +    
       public boolean testNode(NodeTest test) {
  -        return testNode(this, node, test);
  +        return testNode(node, test);
       }
   
  -    public static boolean testNode(
  -            NodePointer pointer, Node node, NodeTest test)
  -    {
  +    public static boolean testNode(Node node, NodeTest test) {
           if (test == null) {
               return true;
           }
  @@ -92,6 +90,7 @@
   
               NodeNameTest nodeNameTest = (NodeNameTest) test;
               QName testName = nodeNameTest.getNodeName();
  +            String namespaceURI = nodeNameTest.getNamespaceURI();
               boolean wildcard = nodeNameTest.isWildcard();
               String testPrefix = testName.getPrefix();
               if (wildcard && testPrefix == null) {
  @@ -101,14 +100,8 @@
               if (wildcard
                   || testName.getName()
                           .equals(DOMNodePointer.getLocalName(node))) {
  -                String nodePrefix = DOMNodePointer.getPrefix(node);
  -                if (equalStrings(testPrefix, nodePrefix)) {
  -                    return true;
  -                }
  -
  -                String testNS = pointer.getNamespaceURI(testPrefix);
  -                String nodeNS = pointer.getNamespaceURI(nodePrefix);
  -                return equalStrings(testNS, nodeNS);
  +                String nodeNS = DOMNodePointer.getNamespaceURI(node);
  +                return equalStrings(namespaceURI, nodeNS);
               }
           }
           else if (test instanceof NodeTypeTest) {
  @@ -166,14 +159,7 @@
       }
   
       public String getNamespaceURI() {
  -        if (node.getNodeType() == Node.ELEMENT_NODE) {
  -            return getNamespaceURI(getName().getPrefix());
  -        }
  -        return null;
  -    }
  -
  -    public QName getExpandedName() {
  -        return new QName(getNamespaceURI(), getName().getName());
  +        return getNamespaceURI(node);
       }
   
       public NodeIterator childIterator(
  @@ -220,6 +206,9 @@
           if (namespace == null) {
               String qname = "xmlns:" + prefix;
               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(qname);
  @@ -230,12 +219,6 @@
                   }
                   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;
               }
  @@ -246,6 +229,25 @@
           return namespace;
       }
   
  +    private String getNamespaceURI(String prefix, String namespace) {
  +        String qname = "xmlns:" + prefix;
  +        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(qname);
  +                if (attr != null) {
  +                    namespace = attr.getValue();
  +                    break;
  +                }
  +            }
  +            aNode = aNode.getParentNode();
  +        }
  +        return namespace;
  +    }
  +
       public String getDefaultNamespaceURI() {
           if (defaultNamespace == null) {
               Node aNode = node;
  @@ -457,14 +459,36 @@
                   // of the path
                   if (parent instanceof DOMNodePointer) {
                       if (buffer.length() == 0
  -                        || buffer.charAt(buffer.length() - 1) != '/') {
  +                            || buffer.charAt(buffer.length() - 1) != '/') {
                           buffer.append('/');
                       }
  -                    buffer.append(getName());
  -                    buffer.append('[');
  -                    buffer.append(getRelativePositionByName()).append(']');
  +                    String nsURI = getNamespaceURI();
  +                    String ln = DOMNodePointer.getLocalName(node);
  +                    
  +                    if (nsURI == null) {
  +                        buffer.append(ln);
  +                        buffer.append('[');
  +                        buffer.append(getRelativePositionByName()).append(']');
  +                    }
  +                    else {
  +                        String prefix = getNamespaceResolver().getPrefix(nsURI);
  +                        if (prefix != null) {
  +                            buffer.append(prefix);
  +                            buffer.append(':');
  +                            buffer.append(ln);
  +                            buffer.append('[');
  +                            buffer.append(getRelativePositionByName());
  +                            buffer.append(']');
  +                        }
  +                        else {
  +                            buffer.append("node()");
  +                            buffer.append('[');
  +                            buffer.append(getRelativePositionOfElement());
  +                            buffer.append(']');
  +                        }
  +                    }
                   }
  -                break;
  +            break;
               case Node.TEXT_NODE :
               case Node.CDATA_SECTION_NODE :
                   buffer.append("/text()");
  @@ -518,6 +542,18 @@
           }
           return count;
       }
  +    
  +    private int getRelativePositionOfElement() {
  +        int count = 1;
  +        Node n = node.getPreviousSibling();
  +        while (n != null) {
  +            if (n.getNodeType() == Node.ELEMENT_NODE) {
  +                count++;
  +            }
  +            n = n.getPreviousSibling();
  +        }
  +        return count;
  +    }
   
       private int getRelativePositionOfTextNode() {
           int count = 1;
  @@ -590,6 +626,40 @@
           }
   
           return name.substring(index + 1);
  +    }
  +    
  +    public static String getNamespaceURI(Node node) {
  +        if (node instanceof Document) {
  +            node = ((Document) node).getDocumentElement();
  +        }
  +
  +        Element element = (Element) node;
  +
  +        String uri = element.getNamespaceURI();
  +        if (uri != null) {
  +            return uri;
  +        }
  +
  +        String qname;
  +        String prefix = getPrefix(node);
  +        if (prefix == null) {
  +            qname = "xmlns";
  +        }
  +        else {
  +            qname = "xmlns:" + prefix;
  +        }
  +
  +        Node aNode = node;
  +        while (aNode != null) {
  +            if (aNode.getNodeType() == Node.ELEMENT_NODE) {
  +                Attr attr = ((Element) aNode).getAttributeNode(qname);
  +                if (attr != null) {
  +                    return attr.getValue();
  +                }
  +            }
  +            aNode = aNode.getParentNode();
  +        }
  +        return null;
       }
   
       public Object getValue() {
  
  
  
  1.13      +2 -2      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/NamespacePointer.java
  
  Index: NamespacePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/NamespacePointer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- NamespacePointer.java	29 Feb 2004 14:17:44 -0000	1.12
  +++ NamespacePointer.java	1 Apr 2004 02:55:32 -0000	1.13
  @@ -47,7 +47,7 @@
       }
   
       public QName getName() {
  -        return new QName(getNamespaceURI(), prefix);
  +        return new QName(prefix);
       }
   
       public Object getBaseValue() {
  
  
  
  1.9       +5 -1      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNamespaceIterator.java
  
  Index: DOMNamespaceIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNamespaceIterator.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DOMNamespaceIterator.java	29 Feb 2004 14:17:44 -0000	1.8
  +++ DOMNamespaceIterator.java	1 Apr 2004 02:55:32 -0000	1.9
  @@ -21,6 +21,7 @@
   import org.apache.commons.jxpath.ri.model.NodeIterator;
   import org.apache.commons.jxpath.ri.model.NodePointer;
   import org.w3c.dom.Attr;
  +import org.w3c.dom.Document;
   import org.w3c.dom.NamedNodeMap;
   import org.w3c.dom.Node;
   
  @@ -45,6 +46,9 @@
           Node parent = node.getParentNode();
           if (parent != null) {
               collectNamespaces(attributes, parent);
  +        }
  +        if (node.getNodeType() == Node.DOCUMENT_NODE) {
  +            node = ((Document) node).getDocumentElement();
           }
           if (node.getNodeType() == Node.ELEMENT_NODE) {
               NamedNodeMap map = node.getAttributes();
  
  
  
  1.15      +1 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributePointer.java
  
  Index: DOMAttributePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributePointer.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DOMAttributePointer.java	29 Feb 2004 14:17:44 -0000	1.14
  +++ DOMAttributePointer.java	1 Apr 2004 02:55:32 -0000	1.15
  @@ -43,10 +43,6 @@
               DOMNodePointer.getLocalName(attr));
       }
   
  -    public QName getExpandedName() {
  -        return new QName(getNamespaceURI(),  DOMNodePointer.getLocalName(attr));
  -    }
  -
       public String getNamespaceURI() {
           String prefix = DOMNodePointer.getPrefix(attr);
           if (prefix == null) {
  
  
  
  1.11      +11 -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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- NodeNameTest.java	25 Mar 2004 05:41:29 -0000	1.10
  +++ NodeNameTest.java	1 Apr 2004 02:55:32 -0000	1.11
  @@ -23,13 +23,23 @@
    */
   public class NodeNameTest extends NodeTest {
       private QName qname;
  +    private String namespaceURI;
   
       public NodeNameTest(QName qname) {
           this.qname = qname;
       }
  +    
  +    public NodeNameTest(QName qname, String namespaceURI) {
  +        this.qname = qname;
  +        this.namespaceURI = namespaceURI;
  +    }
   
       public QName getNodeName() {
           return qname;
  +    }
  +    
  +    public String getNamespaceURI() {
  +        return namespaceURI;
       }
       
       public boolean isWildcard() {
  
  
  
  1.14      +12 -1     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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Path.java	25 Mar 2004 05:41:29 -0000	1.13
  +++ Path.java	1 Apr 2004 02:55:32 -0000	1.14
  @@ -18,6 +18,7 @@
   import org.apache.commons.jxpath.Pointer;
   import org.apache.commons.jxpath.ri.Compiler;
   import org.apache.commons.jxpath.ri.EvalContext;
  +import org.apache.commons.jxpath.ri.QName;
   import org.apache.commons.jxpath.ri.axes.AncestorContext;
   import org.apache.commons.jxpath.ri.axes.AttributeContext;
   import org.apache.commons.jxpath.ri.axes.ChildContext;
  @@ -253,6 +254,16 @@
           int axis,
           NodeTest nodeTest) 
       {
  +        if (nodeTest instanceof NodeNameTest) {
  +            QName qname = ((NodeNameTest) nodeTest).getNodeName();
  +            String prefix = qname.getPrefix();
  +            if (prefix != null) {
  +                String namespaceURI = context.getJXPathContext()
  +                        .getNamespaceURI(prefix);
  +                nodeTest = new NodeNameTest(qname, namespaceURI);
  +            }
  +        }
  +        
           switch (axis) {
           case Compiler.AXIS_ANCESTOR :
               return new AncestorContext(context, false, nodeTest);
  
  
  
  1.13      +1 -5      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/LangAttributePointer.java
  
  Index: LangAttributePointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/LangAttributePointer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- LangAttributePointer.java	29 Feb 2004 14:17:41 -0000	1.12
  +++ LangAttributePointer.java	1 Apr 2004 02:55:32 -0000	1.13
  @@ -35,10 +35,6 @@
           return new QName("xml", "lang");
       }
   
  -    public QName getExpandedName() {
  -        return getName();
  -    }
  -
       public String getNamespaceURI() {
           return null;
       }
  
  
  
  1.12      +6 -2      jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/container/ContainerPointer.java
  
  Index: ContainerPointer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/container/ContainerPointer.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ContainerPointer.java	29 Feb 2004 14:17:45 -0000	1.11
  +++ ContainerPointer.java	1 Apr 2004 02:55:32 -0000	1.12
  @@ -151,7 +151,11 @@
       {
           return pointer1.getIndex() - pointer2.getIndex();
       }
  -
  +    
  +    public String getNamespaceURI(String prefix) {
  +        return getValuePointer().getNamespaceURI(prefix);
  +    }
  +    
       public String asPath() {
           if (parent != null) {
               return parent.asPath();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message