title: Translate XPath to JXPath
body: <p>I've got the following XML:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
          &lt;CreateReservation&gt;
             &lt;NewReservation&gt;
                &lt;Profile op="D"&gt;
                   &lt;ProfileID&gt;ID&lt;/ProfileID&gt;
                   &lt;ProfileType&gt;TYPE&lt;/ProfileType&gt;
                &lt;/Profile&gt;
                &lt;Number&gt;123456&lt;/Number&gt;
             &lt;/NewReservation&gt;
  </code></pre>
  
  <p></p>
  
  <p>marshalled with JAXB from <code>CreateReservation</code> class in the following way:</p>
  
  <pre><code>CreateReservation request = new CreateReservation("123456", "D");
  String xpathExpr = "boolean(//*[local-name()='CreateReservationRQ']//@op='D')"
  JAXBContext context = JAXBContext.newInstance(CreateReservation.class);
  marshaller = context.createMarshaller();    
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  Document document = db.newDocument();
  marshaller.marshal(request, document); //line creates xml presented above
  
  //EVALUATION
  XPath xPath = XPathFactory.newInstance().newXPath();
  xPath.evaluate(xpathExpr, document, XPathConstants.BOOLEAN); //line evaluates xpath and returns true
  </code></pre>
  
  <p>Summing everythig up, presented code marshalls <code>CreateReservation</code> class, create corresponding XML out of it, and with xpath expression checks if created xml has any <code>&lt;CreateReservation&gt;</code> node, which has any child with <code>op="D"</code> attribute. The check is done with the following xpath expression:    </p>
  
  <pre><code>boolean(//*[local-name()='CreateReservationRQ']//@op='D')
  </code></pre>
  
  <p>The condition works fine, fot presented code sample. Right now I would like to get rid of unnecessary marshalling of <code>CreateReservation</code> class. To do so, I would like to switch from JAXB to JXPath:</p>
  
  <pre><code>PathContext jXPathContext = JXPathContext.newContext(obj);
  Object obj = jXPathContext.getValue(CONDITION);
  if (obj != null) {
     //code should behave exactly the same, as my previous model
  }
  </code></pre>
  
  <p><code>obj</code>- member of <code>CreateReservation</code> class (it's structure is exactly the same as presented in xml above)</p>
  
  <p><code>CONDITION</code>- my JXPath query</p>
  
  <p>The idea is, that line:</p>
  
  <pre><code>  Object obj = jXPathContext.getValue(CONDITION);
  </code></pre>
  
  <p>Returns any node, when <code>CreateREservation</code> class has <code>op</code> field equal to 'D'. If no node is present null is returned. Functionally code should behave exactly the same as previously. Could you tell me how my <code>CONDITION</code> should look like?</p>