W
withtape
Somebody please, please help me. I'm getting started using Relax NG to
describe document schemas. After reading the grammar summarized by
http://www.relaxng.org/spec-20011203.html (Section 5), I conclude that
the following is a valid Relax NG schema:
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<attribute name="wtf"/>
</start>
</grammar>
That is, the grammar defines no document element, and that document
element must have a "wtf" attribute.
Elsewhere in the specification (Appendix A) is a Relax NG schema for
Relax NG schemas, and validating the above XML against the schema for
Relax NG (using Tenuto) indeed declares it a valid Relax NG schema.
Yet, there is no possible XML document that could validate against it!
This doesn't present any problem when validating the eventual documents
that must match the "WTF" schema: no document will ever validate
against it. But (as I understand) it means that anyone writing Relax NG
schemas must take care above and beyond what is demanded by the Relax
NG specification to avoid creating such a "WTF" schema. Otherwise, he
confronts a paradox of having a schema vouch-safed (by the Relax NG
spec) as suitable for validating XML documents, that cannot possibly
validate any XML document.
Why do I care? Well, I am writing a tool that assists in the creation
of valid XML documents by "suggesting" appropriate elements and values
at various points in a document according to a given schema. Included
within will be a tool to assist creating schemas, based on the Relax NG
meta-schema. Am I to understand that, if I desire to avoid allowing the
creation of "impossible" schemas like above, it will be insufficient to
simply implement the Relax NG meta-schema? Must I include additional,
Relax NG-specific fixes to check for such things (I wish to avoid this
because it would not be standard)?
More generally, is this a flaw in Relax NG? Does it make sense for a
schema-definition language to allow schemas that cannot validate any
possible document? Was Relax NG deliberately designed this way, or is
this an oversight? Do other schema-definition languages allow this
situation?
describe document schemas. After reading the grammar summarized by
http://www.relaxng.org/spec-20011203.html (Section 5), I conclude that
the following is a valid Relax NG schema:
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<attribute name="wtf"/>
</start>
</grammar>
That is, the grammar defines no document element, and that document
element must have a "wtf" attribute.
Elsewhere in the specification (Appendix A) is a Relax NG schema for
Relax NG schemas, and validating the above XML against the schema for
Relax NG (using Tenuto) indeed declares it a valid Relax NG schema.
Yet, there is no possible XML document that could validate against it!
This doesn't present any problem when validating the eventual documents
that must match the "WTF" schema: no document will ever validate
against it. But (as I understand) it means that anyone writing Relax NG
schemas must take care above and beyond what is demanded by the Relax
NG specification to avoid creating such a "WTF" schema. Otherwise, he
confronts a paradox of having a schema vouch-safed (by the Relax NG
spec) as suitable for validating XML documents, that cannot possibly
validate any XML document.
Why do I care? Well, I am writing a tool that assists in the creation
of valid XML documents by "suggesting" appropriate elements and values
at various points in a document according to a given schema. Included
within will be a tool to assist creating schemas, based on the Relax NG
meta-schema. Am I to understand that, if I desire to avoid allowing the
creation of "impossible" schemas like above, it will be insufficient to
simply implement the Relax NG meta-schema? Must I include additional,
Relax NG-specific fixes to check for such things (I wish to avoid this
because it would not be standard)?
More generally, is this a flaw in Relax NG? Does it make sense for a
schema-definition language to allow schemas that cannot validate any
possible document? Was Relax NG deliberately designed this way, or is
this an oversight? Do other schema-definition languages allow this
situation?