Hi all,

 

I need some urgent help.

I am using the following code to locate document elements using SAXON XPath capabilities.

The problem is that for some reason the 'manifest' element is never found and NULL is returned from the 'evaluate' function.

 

What am I doing wrong?

 

Private Object test(Element bsElement){

String expression = "//manifest";

XPathFactory factory=null;

factory = XPathFactory.newInstance(XPathConstants.DOM_OBJECT_MODEL);

XPath xPath = factory.newXPath();

XPathExpression expr = xPath.compile(expression);

Object evalResult = expr.evaluate(bsElement, XPathConstants.NODE);

 

Return evalResult;

}

 

<?xml version="1.0" encoding="UTF-8"?>

<Service name="PO" namespace="http://www.primagrid.com/services/three/po" xmlns="http://www.primagrid.optimus/runtimeengine/metadata">

            <manifest>

                        <dependencies>

                                    <referencedServices>

                                                <referencedService name=""/>

                                    </referencedServices>

                                    <referencedPackages>

                                    </referencedPackages>

                                    <referencedSchemas>

                                                <schemaReference namespace="http://www.w3.org/2001/XMLSchema" alias="nat"/>

                                                <schemaReference namespace="http://www.pg.com/test/purchaseorder" alias="po"/>

                                    </referencedSchemas>

                        </dependencies>

                        <ServiceVersion/>

            </manifest>

</Service>

 

Thanks in advance,

Asaf