I've noticed some strange behavior I can't explain.

The following code fails in the nested <xpath> section (test #2) with the message »The element type "meta" must be terminated by the matching end-tag "</meta>".«.

<config>
  <var-def name="source">
    <![CDATA[
      <html>
        <head/>
        <body>
          <h1>Test</h1>
        </body>
      </html>
    ]]>
  </var-def>

  <!-- test #1 -->
  <xpath expression="/">
    <var name="source"/>
  </xpath>

  <!-- test #2 -->
  <xpath expression="/">
    <xpath expression="/">
      <var name="source"/>
    </xpath>
  </xpath>
</config>

But there is no <meta> tag at all! And execution passes test #1 but fails test #2, although they are identical except for the nesting of another (actually the same) <xpath> evaluation.

However, the same code (with both test cases) is processed correctly if either the <head/> part is left out or the <html> tag is renamed to something else. So, these two versions work fine:

<config>
  <var-def name="source">
    <![CDATA[
      <html>
        <!-- no head here -->
        <body>
          <h1>Test</h1>
        </body>
      </html>
    ]]>
  </var-def>

  <!-- test #1 -->
  <xpath expression="/">
    <var name="source"/>
  </xpath>

  <!-- test #2 -->
  <xpath expression="/">
    <xpath expression="/">
      <var name="source"/>
    </xpath>
  </xpath>
</config>

and

<config>
  <var-def name="source">
    <![CDATA[
      <foobar>
        <!-- root is not called html -->
        <head/>
        <body>
          <h1>Test</h1>
        </body>
      </foobar>
    ]]>
  </var-def>

  <!-- test #1 -->
  <xpath expression="/">
    <var name="source"/>
  </xpath>

  <!-- test #2 -->
  <xpath expression="/">
    <xpath expression="/">
      <var name="source"/>
    </xpath>
  </xpath>
</config>

This behavior seems strange to me as there is obviously some HTML validation/correction involved, which I would have expected if I was using <html-to-xml> here, but I haven't. Actually, employing the <html-to-xml> processor on the source does not remedy the lack of a </meta> end-tag, either.

<config>
  <var-def name="source">
    <!-- transform to valid XML -->
    <html-to-xml>
      <![CDATA[
        <html>
          <head/>
          <body>
            <h1>Test</h1>
          </body>
        </html>
      ]]>
    </html-to-xml>
  </var-def>

  <!-- test #1 -->
  <xpath expression="/">
    <var name="source"/>
  </xpath>

  <!-- test #2 -->
  <xpath expression="/">
    <xpath expression="/">
      <var name="source"/>
    </xpath>
  </xpath>
</config>

Still getting the same error message »The element type "meta" must be terminated by the matching end-tag "</meta>".«.
Does anyone have a clue about this?