The following code in BaseXPath worries me:

    public BaseXPath addNamespace(String prefix,
                                  String uri) throws JaxenException
    {
        NamespaceContext nsContext = getNamespaceContext();

        if ( nsContext instanceof SimpleNamespaceContext )
        {
            ((SimpleNamespaceContext)nsContext).addNamespace( prefix,
                                                              uri );
           
            return this;
        }

        throw new JaxenException("Operation not permitted while using a 
custom namespace context.");
    }

It seems to me that the NamespaceContext interface should declare an 
addNamespacePrefix() method of its own so that none of these type checks 
and exceptions are necessary. This could be a little tricky if a custom 
NamespaceContext were based on a DOM or JDOM node or some other thing 
you could not or did not want to add a new mapping to. However, in this 
case you'd just need to make the custom NamespaceContext a wraper around 
both the node and a SimpleContext. The SimpleContext could hold any 
additional or overridden mappings.

-- 
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | [EMAIL PROTECTED] | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|           The XML Bible, 2nd Edition (IDG Books, 2001)             |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:   http://www.cafeaulait.org/     | 
|  Read Cafe con Leche for XML News:  http://www.cafeconleche.org/   |
+----------------------------------+---------------------------------+



_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to