title: XPath how to check if an ancestor element has a certain name
body: <p>I have an element structure like so:</p>
  
  <pre><code>&lt;template&gt;
      &lt;x name="foo"&gt;
          &lt;y&gt;
              &lt;x&gt;
                  &lt;a&gt;
                      &lt;b number="1" /&gt;
                      &lt;c&gt;2&lt;/c&gt;
                  &lt;/a&gt;
              &lt;/x&gt;
              &lt;c&gt;5&lt;/c&gt;
          &lt;/y&gt;
      &lt;/x&gt;
  &lt;/template&gt;
  </code></pre>
  
  <p>I need it so that a <code>b</code> element can only exist in <code>a</code> as long as one of the ancestors is an <code>x</code> with a name.  I have a set of alternatives written, but I can't get the test to work.  This is what I thought would work: </p>
  
  <pre><code>ancestor::x[@name]
  </code></pre>
  
  <p>but I get no result.  The only xpath I've had luck with is this:</p>
  
  <pre><code>ancestor::node()
  </code></pre>
  
  <p>Can anyone tell me what I'm missing?</p>
  
  <p>Edit:</p>
  
  <p>I'm using a java xerces 2.11 library to load an xsd file which includes  tags.</p>