Use XPath from JSR
Brought to you by:
farrukh_najmi,
sethp
This patch changes the XPath dependency of the SelectorModule from the sun/apache XPathAPI to the JAXP-1.3 API.
See further:
http://java.sun.com/developer/technicalArticles/xml/jaxp1-3/#XPath%20Support
The patch for SelectorModule.java
Logged In: YES
user_id=1705816
Originator: NO
how to patch it..???
Logged In: YES
user_id=156825
Originator: YES
In SelectorModule.java
Replace
import com.sun.org.apache.xpath.internal.XPathAPI;
With
import java.util.Iterator;
import javax.xml.namespace.NamespaceContext;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
And Replace
NodeList matches = null;
try {
// NOTE: see comments in XALAN docs about why this is slow
matches = XPathAPI.selectNodeList(root, rootPath + path, nsNode);
} catch (Exception e) {
// in the case of any exception, we need to return an error
return createProcessingError("error in XPath: " + e.getMessage());
}
With
// now do the query, pre-pending the root path to the context path
XPathFactory pathFactory = XPathFactory.newInstance();
XPath xpath = pathFactory.newXPath();
XPathExpression pathExpression = null;
xpath.setNamespaceContext(new NamespaceContext() {
public String getNamespaceURI(String prefix) {
return "urn:oasis:names:tc:xacml:2.0:context:schema:os";
}
public String getPrefix(String namespaceURI) {
return null;
}
public Iterator getPrefixes(String namespaceURI) {
return null;
}
});
try {
pathExpression = xpath.compile(rootPath + path);
} catch (Exception e) {
// in the case of any exception, we need to return an error
return createProcessingError("error in XPath: " + e.getMessage());
}
NodeList matches = null;
try {
matches = (NodeList) pathExpression.evaluate(root,
XPathConstants.NODESET);
} catch (Exception e) {
// in the case of any exception, we need to return an error
return createProcessingError("error in XPath: " + e.getMessage());
}
Please notify me whether this was helpful.
Logged In: YES
user_id=1705816
Originator: NO
thanks a lot sir...
it worked and i am able to build the source again with this debugging
earlier i was getting 2 errors along with 74 warnings
this time i didn't get any error but the warnings were still there...
one more Q i want to ask how to pack the build source into jar file
... i tried to pack the previous build that was unsuccessful into jar
it did pack into jar but one thing that i still didn't get is how to
produce that meta-inf ....
regards
Arun Kumar
Logged In: YES
user_id=156825
Originator: YES
Hi Arun,
This question does not seem patch related. Maybe you should ask in the fora. Anyhow, my best guess would be to use ant on the build.xml file to get the jar.
Do you use the Netbeans IDE for development?
Best regards,
kriegel
Logged In: YES
user_id=1705816
Originator: NO
thanks for replying sir..
yeah i just started using Netbeans IDE for development.. :)
but not that much comfortable still
Arun