473,791 Members | 3,193 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Relax NG specification oddity

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?

May 17 '06 #1
4 1627
wi******@gmail. com wrote:
More generally, is this a flaw in Relax NG?


I don't know enough about RELAX NG to answer this, but I would suggest
contacting the folks responsible for its design and posing this question
directly to them. They're the ones who can say for sure whether it's
design or accident, and whether it will be declared acceptable or an
erratum.

http://www.relaxng.org/ points to a mailing list for RELAX NG, as well
as a long list of documents and tools. (I presume you've already looked
at that list, both to make sure your tool isn't redundant and to see
what they do when presented with this schema...)

Good luck. Let us know what you find out.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
May 17 '06 #2
Thanks for the pointer! Actually, I had missed that in the sea of links
on that page. I would say that's exactly what I'm looking for, so I'll
check that out and followup if I get new info.

May 17 '06 #3
Hi,

The Relax NG grammar for Relax NG does not check all the rules for
having a valid grammar. This applies also for XML Schema where if a
document is valid against the schema for schemas that does not mean it
is a valid XML Schema.

The grammar from our example is not valid, Jing reports an error
because the start element contains attribute.
See this also in the specification:
http://www.relaxng.org/spec-20011203.html#context-start
***
7.1.5. start element
The following paths are prohibited:

* start//attribute
[...]
***

A sample schema that will check only that the root element contains a
wtf attribute is:

<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" ns="">
<start>
<element>
<anyName/>
<attribute name="wtf"/>
<zeroOrMore>
<choice>
<attribute>
<anyName>
<except>
<name>wtf</name>
</except>
</anyName>
</attribute>
<text/>
<ref name="any"/>
</choice>
</zeroOrMore>
</element>
</start>
<define name="any">
<element>
<anyName/>
<zeroOrMore>
<choice>
<attribute>
<anyName/>
</attribute>
<text/>
<ref name="any"/>
</choice>
</zeroOrMore>
</element>
</define>
</grammar>

or in compact syntax

start =
element * {
attribute wtf { text },
(attribute * - wtf { text }
| text
| any)*
}
any =
element * {
(attribute * { text }
| text
| any)*
}

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

May 17 '06 #4
George,
Thanks so much for your help! I confess to being overwhelmed by the
specification, so I did not consider those separate prohibitions.

To be clear, your example demonstrating how to ensure that, whatever
the root element of a document is, it must have a "wtf" attribute, is
good reference, but not applicable to my situation. I contrived the
example of a "headless" attribute to point out what I took to be the
deficiency of the grammar, but I thank you for the demonstration.

The main point I wanted to address is whether it is possible to devise
a Relax NG schema that, in itself, ensures valid schemas. I see now
that the grammar given in the spec, expressed as a schema, fails at
this task, for good reasons (for example, I came across a post on the
Relax NG mailing list that, I believe, explains how partial schemas
like my example could be referenced by other schemas, and thus the
grammar allows them). I wonder if that schema/grammar could be refined
so that a schema-producing program would have no external requirements
(such as, "start//attribute is invalid"). Perhaps by adding
restrictions on allowed elements after <start>, at the expense of
allowing external schema references (a trade I would be willing to make
for my purposes)?

Really, I just wanted reassurance that I wasn't crazy in thinking that
the Relax NG schema for Relax NG schemas does something other than what
I initially expected, and you have provided it very nicely.

-Jason Chang

Jun 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2759
by: Olivier Hoarau | last post by:
Hello, I have to validate a xml file, for that I use libxml and its function xmllint which needs the RELAX NG "full" schema of the file. I have only its RelaxNG compact schema, I have to transform it first in Relax NG "full". To transform RelaxNG compact to RelaxNG "full", I use rnc2rng written in Python. I have some difficulties, the file I obtain from a RELAXNG compact file is not conform.
6
2493
by: Pieter | last post by:
I've read a lot of posts on "why relax ng is so very good" and on "why w3c xml schema should be the only schema language". I'm, however, still not clear on why I should prefer one over the other. I've made a small list of some good and bad points of both. These points don't really go into the grammar aspects of these languages, but are more about secondary aspects. The grammar aspects are different, but both are suitable for validating...
0
1115
by: Henri Sivonen | last post by:
I have written a servlet wrapper and a custom entity resolver for Jing. My code needs to decide whether to instantiate a compact syntax schema reader or an XML syntax schema reader. I would very much like to do the Right Thing. Currently, my code does the following; 1. If the HTTP Content-Type of the schema is application/vnd.relax-ng.rnc, the schema is treated as a compact syntax schema. 2. If the HTTP Content-Type of the schema is...
2
1538
by: bauer_markus81 | last post by:
hallo, I have been looking at profound information about the strengths and weaknesses/limitations of Relax NG. I'd be grateful for comments. regards markus b.
5
1747
by: mhuhn.de | last post by:
I am using XML Schema for quite a while but haven't written a single line of Relax NG yet. For what I know, I cannot define static content within an XML Schema. For example, I have the following structure: <colors> <color>green</color> <color>red</color> </colors>
7
2292
by: slitvinov | last post by:
I am learning Relax NG. The problem is that I cannot figure out how to make a schema for a table. In my case I would like to make a table with any name of child elements (columns) but columns should have the same number of child elements (cell). Say this file is valid <table> <column> <cell/> <cell/> </column>
5
1791
by: jmdocherty | last post by:
All, I've been trying to set up a CSS layout and all seems well in Firefox but in Safari it just seems to be plain weird! I hope someone can help tell me whether this is a problem with my code or a Safari oddity (which if it is, any top-tips to fix it would be most welcome!). Objective: I want to have the meat of the viewport divided into 3 columns (a fixed margin (say 140px) and 2 scalable panes on the right each of which
1
1885
by: Torsten Munkelt | last post by:
Hi, I want to validate an XML document applying a combination of RELAX NG and Schematron. I have not found an appropriate validator. Would you please send me links to such validators. I would like to easily access it from within Java and from console. Thank you very much for your answers in advance.
2
1739
by: McSwell | last post by:
We have a small (~50 line) DTD and a slightly larger (~300 line) W3C schema that we need to convert to Relax NG. (And I have a larger W3C schema that I may some day convert.) I was hoping that there would be some tools to get us started, but the list at http://relaxng.org/#conversion is not too promising. The one tool that looks like it would actually do such a conversion, the Sun RELAX NG Converter, appears to have disappeared from the...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9517
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.