All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] config/tools/xml: validate resulting cluster.rng with relaxng.rng
@ 2013-02-06 20:47 Jan Pokorný
  2013-02-07  8:24 ` Fabio M. Di Nitto
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Pokorný @ 2013-02-06 20:47 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Doing so will guarantee the file is valid RELAX NG schema, not just
a valid XML.

Validating schema, relaxng.rng, was obtained directly from [1] and
matches directly to a version bundled with xmlcopyeditor in Fedora 17.
The same (modulo VCS headers, comments and spacing details) can be
obtained by combining schema as in the specification [2] and its
errata [3].

[1] http://relaxng.org/relaxng.rng
[2] http://relaxng.org/spec-20011203.html
[3] http://relaxng.org/spec-20011203-errata.html

Signed-off-by: Jan Pokorn? <jpokorny@redhat.com>
---
 config/tools/xml/Makefile             |   2 +-
 config/tools/xml/ccs_update_schema.in |   3 +-
 config/tools/xml/relaxng.rng          | 335 ++++++++++++++++++++++++++++++++++
 3 files changed, 338 insertions(+), 2 deletions(-)
 create mode 100644 config/tools/xml/relaxng.rng

diff --git a/config/tools/xml/Makefile b/config/tools/xml/Makefile
index 3c9e97c..a86eb01 100644
--- a/config/tools/xml/Makefile
+++ b/config/tools/xml/Makefile
@@ -7,7 +7,7 @@ TARGET4 = cluster.rng
 
 SBINDIRT = $(TARGET1) $(TARGET2) $(TARGET3)
 SHAREDIRSYMT = $(TARGET4)
-RELAXNGDIRT = cluster.rng.in.head cluster.rng.in.tail
+RELAXNGDIRT = cluster.rng.in.head cluster.rng.in.tail relaxng.rng
 
 all: $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4)
 
diff --git a/config/tools/xml/ccs_update_schema.in b/config/tools/xml/ccs_update_schema.in
index a5aa351..16ce9f7 100644
--- a/config/tools/xml/ccs_update_schema.in
+++ b/config/tools/xml/ccs_update_schema.in
@@ -316,7 +316,8 @@ build_schema() {
 		return 1
 	}
 
-	xmllint --noout $outputdir/cluster.rng || {
+	xmllint --noout --relaxng $rngdir/relaxng.rng $outputdir/cluster.rng \
+	  || {
 		echo "generated schema does not pass xmllint validation" >&2
 		return 1
 	}
diff --git a/config/tools/xml/relaxng.rng b/config/tools/xml/relaxng.rng
new file mode 100644
index 0000000..ee6fbde
--- /dev/null
+++ b/config/tools/xml/relaxng.rng
@@ -0,0 +1,335 @@
+<?xml version="1.0"?>
+<!-- RELAX NG for RELAX NG -->
+<!-- $Id: relaxng.rng,v 1.31 2002/05/30 06:07:43 jjc Exp $ -->
+<grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
+         ns="http://relaxng.org/ns/structure/1.0"
+         xmlns="http://relaxng.org/ns/structure/1.0">
+  <start>
+    <ref name="pattern"/>
+  </start>
+
+  <define name="pattern">
+    <choice>
+      <element name="element">
+        <choice>
+          <attribute name="name">
+            <data type="QName"/>
+          </attribute>
+          <ref name="open-name-class"/>
+        </choice>
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="attribute">
+        <ref name="common-atts"/>
+        <choice>
+	  <attribute name="name">
+	    <data type="QName"/>
+	  </attribute>
+          <ref name="open-name-class"/>
+        </choice>
+        <interleave>
+          <ref name="other"/>
+          <optional>
+            <ref name="pattern"/>
+          </optional>
+        </interleave>
+      </element>
+      <element name="group">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="interleave">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="choice">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="optional">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="zeroOrMore">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="oneOrMore">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="list">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="mixed">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="ref">
+        <attribute name="name">
+          <data type="NCName"/>
+        </attribute>
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="parentRef">
+        <attribute name="name">
+          <data type="NCName"/>
+        </attribute>
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="empty">
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="text">
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="value">
+        <optional>
+          <attribute name="type">
+            <data type="NCName"/>
+          </attribute>
+        </optional>
+        <ref name="common-atts"/>
+        <text/>
+      </element>
+      <element name="data">
+        <attribute name="type">
+          <data type="NCName"/>
+        </attribute>
+        <ref name="common-atts"/>
+        <interleave>
+          <ref name="other"/>
+          <group>
+	    <zeroOrMore>
+	      <element name="param">
+		<attribute name="name">
+		  <data type="NCName"/>
+		</attribute>
+                <ref name="common-atts"/>
+		<text/>
+	      </element>
+	    </zeroOrMore>
+            <optional>
+              <element name="except">
+		<ref name="common-atts"/>
+		<ref name="open-patterns"/>
+              </element>
+            </optional>
+          </group>
+        </interleave>
+      </element>
+      <element name="notAllowed">
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="externalRef">
+        <attribute name="href">
+          <data type="anyURI"/>
+        </attribute>
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="grammar">
+        <ref name="common-atts"/>
+        <ref name="grammar-content"/>
+      </element>
+    </choice>
+  </define>
+
+  <define name="grammar-content">
+    <interleave>
+      <ref name="other"/>
+      <zeroOrMore>
+        <choice>
+          <ref name="start-element"/>
+          <ref name="define-element"/>
+          <element name="div">
+            <ref name="common-atts"/>
+            <ref name="grammar-content"/>
+          </element>
+          <element name="include">
+            <attribute name="href">
+              <data type="anyURI"/>
+            </attribute>
+            <ref name="common-atts"/>
+            <ref name="include-content"/>
+          </element>
+        </choice>
+      </zeroOrMore>
+    </interleave>
+  </define>
+
+  <define name="include-content">
+    <interleave>
+      <ref name="other"/>
+      <zeroOrMore>
+        <choice>
+          <ref name="start-element"/>
+          <ref name="define-element"/>
+          <element name="div">
+            <ref name="common-atts"/>
+            <ref name="include-content"/>
+          </element>
+        </choice>
+      </zeroOrMore>
+    </interleave>
+  </define>
+
+  <define name="start-element">
+    <element name="start">
+      <ref name="combine-att"/>
+      <ref name="common-atts"/>
+      <ref name="open-pattern"/>
+    </element>
+  </define>
+
+  <define name="define-element">
+    <element name="define">
+      <attribute name="name">
+        <data type="NCName"/>
+      </attribute>
+      <ref name="combine-att"/>
+      <ref name="common-atts"/>
+      <ref name="open-patterns"/>
+    </element>
+  </define>
+
+  <define name="combine-att">
+    <optional>
+      <attribute name="combine">
+        <choice>
+          <value>choice</value>
+          <value>interleave</value>
+        </choice>
+      </attribute>
+    </optional>
+  </define>
+  
+  <define name="open-patterns">
+    <interleave>
+      <ref name="other"/>
+      <oneOrMore>
+        <ref name="pattern"/>
+      </oneOrMore>
+    </interleave>
+  </define>
+
+  <define name="open-pattern">
+    <interleave>
+      <ref name="other"/>
+      <ref name="pattern"/>
+    </interleave>
+  </define>
+
+  <define name="name-class">
+    <choice>
+      <element name="name">
+        <ref name="common-atts"/>
+        <data type="QName"/>
+      </element>
+      <element name="anyName">
+        <ref name="common-atts"/>
+        <ref name="except-name-class"/>
+      </element>
+      <element name="nsName">
+        <ref name="common-atts"/>
+        <ref name="except-name-class"/>
+      </element>
+      <element name="choice">
+        <ref name="common-atts"/>
+        <ref name="open-name-classes"/>
+      </element>
+    </choice>
+  </define>
+
+  <define name="except-name-class">
+    <interleave>
+      <ref name="other"/>
+      <optional>
+        <element name="except">
+          <ref name="open-name-classes"/>
+        </element>
+      </optional>
+    </interleave>
+  </define>
+
+  <define name="open-name-classes">
+    <interleave>
+      <ref name="other"/>
+      <oneOrMore>
+        <ref name="name-class"/>
+      </oneOrMore>
+    </interleave>
+  </define>
+
+  <define name="open-name-class">
+    <interleave>
+      <ref name="other"/>
+      <ref name="name-class"/>
+    </interleave>
+  </define>
+
+  <define name="common-atts">
+    <optional>
+      <attribute name="ns"/>
+    </optional>
+    <optional>
+      <attribute name="datatypeLibrary">
+        <data type="anyURI"/>
+      </attribute>
+    </optional>
+    <zeroOrMore>
+      <attribute>
+        <anyName>
+          <except>
+            <nsName/>
+            <nsName ns=""/>
+          </except>
+        </anyName>
+      </attribute>
+    </zeroOrMore>
+  </define>
+
+  <define name="other">
+    <zeroOrMore>
+      <element>
+        <anyName>
+          <except>
+            <nsName/>
+          </except>
+        </anyName>
+        <zeroOrMore>
+          <choice>
+            <attribute>
+              <anyName/>
+            </attribute>
+            <text/>
+            <ref name="any"/>
+          </choice>
+        </zeroOrMore>
+      </element>
+    </zeroOrMore>
+  </define>
+
+  <define name="any">
+    <element>
+      <anyName/>
+      <zeroOrMore>
+        <choice>
+          <attribute>
+            <anyName/>
+          </attribute>
+          <text/>
+          <ref name="any"/>
+        </choice>
+      </zeroOrMore>
+    </element>
+  </define>
+
+</grammar>
-- 
1.7.11.7



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Cluster-devel] [PATCH] config/tools/xml: validate resulting cluster.rng with relaxng.rng
  2013-02-06 20:47 [Cluster-devel] [PATCH] config/tools/xml: validate resulting cluster.rng with relaxng.rng Jan Pokorný
@ 2013-02-07  8:24 ` Fabio M. Di Nitto
  2013-02-07 10:49   ` Jan Pokorný
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio M. Di Nitto @ 2013-02-07  8:24 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi Jan,

On 2/6/2013 9:47 PM, Jan Pokorn? wrote:
> Doing so will guarantee the file is valid RELAX NG schema, not just
> a valid XML.
> 
> Validating schema, relaxng.rng, was obtained directly from [1] and
> matches directly to a version bundled with xmlcopyeditor in Fedora 17.
> The same (modulo VCS headers, comments and spacing details) can be
> obtained by combining schema as in the specification [2] and its
> errata [3].
> 
> [1] http://relaxng.org/relaxng.rng
> [2] http://relaxng.org/spec-20011203.html
> [3] http://relaxng.org/spec-20011203-errata.html

this looks like a good idea, but i have one question.

Is there a specific reason why we need to ship/embed the file with our
tarball? How bad is it to require the one installed on a system?

I can see it?s rather stable and hardly updated, but i prefer to avoid
duplication if we can.

Fabio

> 
> Signed-off-by: Jan Pokorn? <jpokorny@redhat.com>
> ---
>  config/tools/xml/Makefile             |   2 +-
>  config/tools/xml/ccs_update_schema.in |   3 +-
>  config/tools/xml/relaxng.rng          | 335 ++++++++++++++++++++++++++++++++++
>  3 files changed, 338 insertions(+), 2 deletions(-)
>  create mode 100644 config/tools/xml/relaxng.rng
> 
> diff --git a/config/tools/xml/Makefile b/config/tools/xml/Makefile
> index 3c9e97c..a86eb01 100644
> --- a/config/tools/xml/Makefile
> +++ b/config/tools/xml/Makefile
> @@ -7,7 +7,7 @@ TARGET4 = cluster.rng
>  
>  SBINDIRT = $(TARGET1) $(TARGET2) $(TARGET3)
>  SHAREDIRSYMT = $(TARGET4)
> -RELAXNGDIRT = cluster.rng.in.head cluster.rng.in.tail
> +RELAXNGDIRT = cluster.rng.in.head cluster.rng.in.tail relaxng.rng
>  
>  all: $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4)
>  
> diff --git a/config/tools/xml/ccs_update_schema.in b/config/tools/xml/ccs_update_schema.in
> index a5aa351..16ce9f7 100644
> --- a/config/tools/xml/ccs_update_schema.in
> +++ b/config/tools/xml/ccs_update_schema.in
> @@ -316,7 +316,8 @@ build_schema() {
>  		return 1
>  	}
>  
> -	xmllint --noout $outputdir/cluster.rng || {
> +	xmllint --noout --relaxng $rngdir/relaxng.rng $outputdir/cluster.rng \
> +	  || {
>  		echo "generated schema does not pass xmllint validation" >&2
>  		return 1
>  	}



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Cluster-devel] [PATCH] config/tools/xml: validate resulting cluster.rng with relaxng.rng
  2013-02-07  8:24 ` Fabio M. Di Nitto
@ 2013-02-07 10:49   ` Jan Pokorný
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Pokorný @ 2013-02-07 10:49 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hello ,

On 07/02/13 09:24 +0100, Fabio M. Di Nitto wrote:
> Hi Jan,
> 
> On 2/6/2013 9:47 PM, Jan Pokorn? wrote:
>> Doing so will guarantee the file is valid RELAX NG schema, not just
>> a valid XML.
>> 
>> Validating schema, relaxng.rng, was obtained directly from [1] and
>> matches directly to a version bundled with xmlcopyeditor in Fedora 17.
>> The same (modulo VCS headers, comments and spacing details) can be
>> obtained by combining schema as in the specification [2] and its
>> errata [3].
>> 
>> [1] http://relaxng.org/relaxng.rng
>> [2] http://relaxng.org/spec-20011203.html
>> [3] http://relaxng.org/spec-20011203-errata.html
> 
> this looks like a good idea, but i have one question.
> 
> Is there a specific reason why we need to ship/embed the file with our
> tarball? How bad is it to require the one installed on a system?

It is not bad at all, but you can hardly find it system-wide.  AFAIK
there is no standard in packaging such standalone single files
anywhere yet (see also, e.g., JavaScript libraries, everything is
usually bundled).  Once there is a wide-spread standard (if ever)
where such files are located within the distributions, relaxng.rng
can be dropped and dependency can be added.

> I can see it?s rather stable and hardly updated, but i prefer to avoid
> duplication if we can.

I share the same intention, however current situation does not seem
to be offering any other choice.

-- 
Jan



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-02-07 10:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-06 20:47 [Cluster-devel] [PATCH] config/tools/xml: validate resulting cluster.rng with relaxng.rng Jan Pokorný
2013-02-07  8:24 ` Fabio M. Di Nitto
2013-02-07 10:49   ` Jan Pokorný

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.