title: JAXB XJC - XPath evaluation results in empty target node?
body: <p>I've got the following simple XSD document (<code>foo.xsd</code>):</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              targetNamespace="urn:foo"&gt;
    &lt;xsd:element name="Person"&gt;
      &lt;xsd:complexType&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="Name" type="xsd:string"/&gt;
          &lt;xsd:element name="Height"&gt;
            &lt;xsd:simpleType&gt;
              &lt;xsd:restriction base="xsd:string"&gt;
                &lt;xsd:enumeration value="Short"/&gt;
                &lt;xsd:enumeration value="Average"/&gt;
                &lt;xsd:enumeration value="Tall"/&gt;
              &lt;/xsd:restriction&gt;
            &lt;/xsd:simpleType&gt;
          &lt;/xsd:element&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p>And I'd like to hint to the XJC JAXB compiler that the "Height" element should use a type safe enum class by using an external bindings file, like so (<code>foo.xjb</code>):</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jxb:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
                xmlns:xsd="http://www.w3c.org/2001/XMLSchema"
                jxb:version="2.0"&gt;
    &lt;jxb:bindings schemaLocation="foo.xsd"&gt;
      &lt;jxb:bindings node="//xsd:element[@name='Height']/xsd:simpleType"&gt;
        &lt;jxb:typesafeEnumClass name="Height" /&gt;
      &lt;/jxb:bindings&gt;
    &lt;/jxb:bindings&gt;
  &lt;/jxb:bindings&gt;
  </code></pre>
  
  <p>But when I run the command "<code>xjc -b foo.xjb foo.xsd</code>" I get the following error:</p>
  
  <pre><code>parsing a schema...
  [ERROR] XPath evaluation of "//xsd:element[@name='Height']/xsd:simpleType" results in empty target node
    line 6 of file:/Users/maerics/src/java/jaxb/foo.xjb
  
  Failed to parse a schema.
  </code></pre>
  
  <p>The XPath expression looks fine to me so I'm guessing there is some subtle problem related to XML namespaces?  I've tried a few combinations of using (or not) a default namespace, targetNamespace, etc. but always the same error.  Note that <code>xjc</code> generates Java source for the XSD file by itself, without the external bindings file, as expected.  Similarly, using embedded binding definitions in the XSD file works as expected.</p>
  
  <p>Note that I am using Java version "1.6.0_26" and xjc version "JAXB 2.1.10 in JDK 6" on Mac OS 10.6.8.</p>
  
  <p><strong>Can someone explain how to achieve this goal without modifying the original XSD?</strong></p>