Re: [xml] validation fails for embedded RELAX NG schema



On Mon, Aug 3, 2009 at 8:34 AM, Michael Ludwig<mlu as-guides com> wrote:
I'd be surprised to discover that embedding RNG schemas in arbitrary
documents is actually supported. What makes you think it is?

I am actually absolutely not sure about this. I am probably making
more a question than a statement. I've never done it before, and I've
never seen an example of a schema embedded in an arbitrary document. I
just took the following information, and put it together:

 * It is valid from the XML point of view (as you agree with me).

 * And xmllint copes perfectly with the opposite case, of arbitrary
content embedded in the RELAX NG schema:

<?xml version='1.0' encoding='UTF-8'?>
<grammar xmlns='http://relaxng.org/ns/structure/1.0'>
   <embedded xmlns='http://namespace.net/something'>
      <!-- Arbitrary content embedded here. -->
   </embedded>
   <start xmlns='http://relaxng.org/ns/structure/1.0'>
      <element name='data'>
         <zeroOrMore>
            <element name='entry'>
               <zeroOrMore>
                  <element name='value'>
                     <text/>
                  </element>
               </zeroOrMore>
            </element>
         </zeroOrMore>
      </element>
   </start>
</grammar>

Adding these two pieces of information, It seems reasonable, or at
least probable, to embed the whole schema in an arbitrary XML
document. At least, from my current use-case, where I have this kind
of documents.

(FYI: I am actually doing some experiments with RELAX NG, writing
little schemas that are heavily documented, sort of literate
programming. In my case, the schemas are really "inside" the
documentation, and not the other way around.)

I know, that I could pre-process my "mixed" document, and extract the
schema with XSLT prior to validation. But this would make the whole
project quite a lot more complex, thus I'd like to avoid it, if
possible.

Extracting a subtree from a document doesn't seem too difficult, and
could probably be done using nothing but DOM.

It's true, that it is not difficult at all. It would be more a matter
of principle and elegance, not to add complexity, and to avoid an
unnecessary(?) step.

Thank you very much, Michael, for your comments.

Regards,
Jerzy



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]