Hi,

IIRC Axiom does not support the feature of creating an OMNode if it does not
exist when queried using an XPath expression. Is this DOMUtil class that you
have mention, the main class which is used to handle XPath in DOM? I mean is
it the similar DOM version of AXIOMXPath class?

Modifying the existing selectSingleNode() method may introduce certain
backward compatibility issues. So it would be better to come up with an
overloaded method like selectSingleNode(OMElement root, boolean create).
That way the exisiting method will equal to selectSingleNode(root, false).

Thanks,
Saliya

On Mon, Sep 22, 2008 at 5:12 PM, Thorsten Scherler <
[EMAIL PROTECTED]> wrote:

> Hi all,
>
> I started to use AXIOM in Forrest to replace some old DOM code that is
> still lurking around.
>
> Now I am trying to select a node with a given xpath:
> ...
>  String xlocation = iterator.next();
>  AXIOMXPath xpath = new AXIOMXPath(xlocation);
>  OMElement injection = (OMElement)xpath.selectSingleNode(root);
> ...
>  if(null==injection){
>   log.debug("Path is not already contained, "+
>       "so we need to create it.");
>      }
> ...
>
> I searched a bit in the code but could not find any method that will
> create a element if the xpath expression is not given. Well much like:
>
> http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/xml/dom/DOMUtil.html#selectSingleNode(org.w3c.dom.Node<http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/xml/dom/DOMUtil.html#selectSingleNode%28org.w3c.dom.Node>,
> java.lang.String, org.apache.excalibur.xml.xpath.XPathProcessor) but only
> for StAX/Axiom.
>
> I there something that I can reuse?
>
> If not, is there interest that I create a patch for AXIOMXPath and
> implement this functionality?
>
> salu2
> --
> Thorsten Scherler                                 thorsten.at.apache.org
> Open Source Java                      consulting, training and solutions
>
>


-- 
Saliya Ekanayake
http://www.esaliya.blogspot.com
http://www.esaliya.wordpress.com

Reply via email to