title: JAXP: How to force XPath to validate namespace prefixes?
body: <p>I am relying on the <strong>default JAXP implementation</strong> and using the <strong>Oracle JRE</strong>.
  When evaluating a XPath which contains an unknown namespace prefix, it does not throw an (expected) exception.</p>
  
  <p>When I run the same application on an <strong>IBM JRE, everything is fine</strong> and it throws the expected exception <code>javax.xml.xpath.XPathExpressionException: org.apache.xpath.domapi.XPathStylesheetDOM3Exception: Prefix must resolve to a namespace</code></p>
  
  <p>I am using the following code which tries to access an <strong>invalid namespace unknownns</strong></p>
  
  <pre><code>  DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
        .newInstance();
  
    documentBuilderFactory.setNamespaceAware(true);
    documentBuilderFactory.setValidating(true);
    documentBuilderFactory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
  
    DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
  
    Document doc = builder.parse(xmlFile_);
  
    XPath xpath = XPathFactory.newInstance().newXPath();
    NodeList nodeList = (NodeList) xpath.evaluate("path/to/node/unknowns:@bla", doc,
        XPathConstants.NODESET);
  </code></pre>
  
  <p>Question:</p>
  
  <p><strong>How can I enforce this validation independently from the JAXP implementation?</strong></p>