cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Jan Pokorný <jpokorny@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/2] rgmanager: ra2rng.xsl et al.: obsolete 1 pass in ccs_update_schema
Date: Mon, 16 Dec 2013 13:38:21 +0100	[thread overview]
Message-ID: <1387197502-11551-2-git-send-email-jpokorny@redhat.com> (raw)
In-Reply-To: <1387197502-11551-1-git-send-email-jpokorny@redhat.com>

... in a backward-compatible way, which is done by wrapping the output
of this as-of-now obsoleted pass by element from explicit non-RelaxNG
namespace, which is then, in the validation phase, completely skipped.

Separate patch for cluster.git to actually remove the pass in question
will be provided, but thanks to this backward compatibility, it is not
strictly required -- only informative notes about possibility of outdated
cman package will possibly occur.  The corresponding pass is also removed
directly in the local Makefile mirroring the part of ccs_update_schema
functionality so the resulting resources.rng does not contain the
now-redundant references.

[ It's nice to see how smart the design of Relax NG, allowing
  for such define-ala-mixin, is. ]

NB: the change "optional" -> "zeroOrMore" is because previously
    "optional" was previously pointless (as is chaining '?' + '*'
    in regexp), but now the nested "zeroOrMore" is promoted from
    the definition of CHILDREN block up to its user (the other
    users were already using "zeroOrMore" also before descending
    to such symbol, which was another pointless thing, FWIW)

Signed-off-by: Jan Pokorn? <jpokorny@redhat.com>
---
 rgmanager/src/resources/Makefile.am        | 13 ++++-----
 rgmanager/src/resources/ra2ref.xsl         |  4 +++
 rgmanager/src/resources/ra2rng.xsl         | 42 +++++++++++++++++++++++++++---
 rgmanager/src/resources/resources.rng.mid  |  4 +--
 rgmanager/src/resources/resources.rng.tail |  7 ++---
 5 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/rgmanager/src/resources/Makefile.am b/rgmanager/src/resources/Makefile.am
index 7719f81..caeb947 100644
--- a/rgmanager/src/resources/Makefile.am
+++ b/rgmanager/src/resources/Makefile.am
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2004-2011 Red Hat, Inc.  All rights reserved.
+# Copyright (C) 2004-2013 Red Hat, Inc.  All rights reserved.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -96,6 +96,12 @@ ras-validation: $(RESOURCES) $(TARGET) $(DTD)
 #
 # resources.rng.* should never be distributed by themselves.
 #
+# NOTE: resources.rng.mid and resources.rng.tail not joined for
+#       compatibility with obsolete 2-passes-logic of
+#       ccs_update_schema script from external cman package
+#
+# XXX: race-prone in parallel make
+#
 resources.rng: $(RESOURCES) $(TARGET) utils/config-utils.sh
 resources.rng: $(XSL) $(RESRNG)
 	rm -f resources.rng
@@ -106,11 +112,6 @@ resources.rng: $(XSL) $(RESRNG)
 		bash ./$$f meta-data | xsltproc ra2rng.xsl - >> resources.rng; \
 	done
 	cat resources.rng.mid >> resources.rng
-	@echo Generating per-resource RelaxNG reference information...
-	@for f in $(RESOURCES) $(TARGET); do \
-		echo "    ./$$f"; \
-		bash ./$$f meta-data | xsltproc ra2ref.xsl - >> resources.rng; \
-	done
 	cat resources.rng.tail >> resources.rng
 
 utils/config-utils.sh:
diff --git a/rgmanager/src/resources/ra2ref.xsl b/rgmanager/src/resources/ra2ref.xsl
index 6e61073..a4b84c0 100644
--- a/rgmanager/src/resources/ra2ref.xsl
+++ b/rgmanager/src/resources/ra2ref.xsl
@@ -1,10 +1,14 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="yes"/>
+<xsl:message>NOTE: if you see this, there is some chance you are using outdated cman package</xsl:message>
 <xsl:template name="capitalize">
 	<xsl:param name="value"/>
 	<xsl:variable name="normalized" select="translate($value, '_abcdefghijklmnopqrstuvwrxyz', '-ABCDEFGHIJKLMNOPQRSTUVWRXYZ')"/>
 	<xsl:value-of select="$normalized"/>
 </xsl:template>
+<xsl:template match="/resource-agent[1]">
+        &lt;!-- NOTE: if you see this, there is some chance you are using outdated cman package --&gt;
+        &lt;ref name="<xsl:call-template name="capitalize"><xsl:with-param name="value" select="@name"/></xsl:call-template>"/&gt;</xsl:template>
 <xsl:template match="/resource-agent">
         &lt;ref name="<xsl:call-template name="capitalize"><xsl:with-param name="value" select="@name"/></xsl:call-template>"/&gt;</xsl:template>
 </xsl:stylesheet>
diff --git a/rgmanager/src/resources/ra2rng.xsl b/rgmanager/src/resources/ra2rng.xsl
index 3cb098d..5b9a307 100644
--- a/rgmanager/src/resources/ra2rng.xsl
+++ b/rgmanager/src/resources/ra2rng.xsl
@@ -7,6 +7,7 @@
 
 <xsl:param name="global-init-indent" select="'  '"/>
 <xsl:param name="global-indent" select="'  '"/>
+<xsl:param name="global-ra-children-elem" select="'CHILDREN'"/>
 
 
 <!--
@@ -471,6 +472,10 @@
 <xsl:template match="/resource-agent">
     <xsl:value-of select="$NL"/>
 
+    <!--
+      first define per-RA element itself...
+      -->
+
     <!-- define name=... (start) -->
     <xsl:variable name="capitalized">
         <xsl:call-template name="capitalize">
@@ -666,18 +671,18 @@
 
             <!-- optional (start) -->
             <xsl:call-template name="tag-start">
-                <xsl:with-param name="name" select="'optional'"/>
+                <xsl:with-param name="name" select="'zeroOrMore'"/>
                 <xsl:with-param name="indented"
                                 select="concat($global-init-indent,
                                                $global-indent)"/>
             </xsl:call-template>
             <xsl:value-of select="$NL"/>
 
-                <!-- ref name="CHILDREN" -->
+                <!-- ref name="CHILDREN" (or equiv.) -->
                 <xsl:call-template name="tag">
                     <xsl:with-param name="name" select="'ref'"/>
                     <xsl:with-param name="attrs" select="concat(
-                        'name=', $Q, 'CHILDREN', $Q)"/>
+                        'name=', $Q, $global-ra-children-elem, $Q)"/>
                     <xsl:with-param name="indented"
                                     select="concat($global-init-indent,
                                                    $global-indent,
@@ -687,7 +692,7 @@
 
             <!-- optional (end) -->
             <xsl:call-template name="tag-end">
-                <xsl:with-param name="name" select="'optional'"/>
+                <xsl:with-param name="name" select="'zeroOrMore'"/>
                 <xsl:with-param name="indented"
                                 select="concat($global-init-indent,
                                                $global-indent)"/>
@@ -708,6 +713,35 @@
     </xsl:call-template>
     <xsl:value-of select="$NLNL"/>
 
+    <!--
+      ...then add a reference to such defined symbol to CHILDREN (or equiv.)
+      -->
+
+    <!-- define name="CHILDREN" (or equiv.; start) -->
+    <xsl:call-template name="tag-start">
+        <xsl:with-param name="name" select="'define'"/>
+        <xsl:with-param name="attrs" select="concat(
+            'name=',    $Q, $global-ra-children-elem, $Q, $SP,
+            'combine=', $Q, 'choice',                 $Q)"/>
+    </xsl:call-template>
+    <xsl:value-of select="$NL"/>
+
+        <!-- ref name="$capitalized" -->
+        <xsl:call-template name="tag">
+            <xsl:with-param name="name" select="'ref'"/>
+            <xsl:with-param name="attrs" select="concat(
+                'name=', $Q, $capitalized, $Q)"/>
+            <xsl:with-param name="indented"
+                            select="$global-init-indent"/>
+        </xsl:call-template>
+        <xsl:value-of select="$NL"/>
+
+    <!-- define (end) -->
+    <xsl:call-template name="tag-end">
+        <xsl:with-param name="name" select="'define'"/>
+    </xsl:call-template>
+    <xsl:value-of select="$NLNL"/>
+
 </xsl:template>
 
 </xsl:stylesheet>
diff --git a/rgmanager/src/resources/resources.rng.mid b/rgmanager/src/resources/resources.rng.mid
index cc2dff3..3276eb5 100644
--- a/rgmanager/src/resources/resources.rng.mid
+++ b/rgmanager/src/resources/resources.rng.mid
@@ -1,3 +1 @@
-  <define name="CHILDREN">
-    <zeroOrMore>
-     <choice>
+  <rha:ignore>
diff --git a/rgmanager/src/resources/resources.rng.tail b/rgmanager/src/resources/resources.rng.tail
index d0f41ce..4a1ea22 100644
--- a/rgmanager/src/resources/resources.rng.tail
+++ b/rgmanager/src/resources/resources.rng.tail
@@ -1,7 +1,8 @@
 
-      <ref name="RESOURCEACTION"/>
-     </choice>
-    </zeroOrMore>
+  </rha:ignore>
+
+  <define name="CHILDREN" combine="choice">
+    <ref name="RESOURCEACTION"/>
   </define>
 
   <define name="RESOURCECOMMONPARAMS" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
-- 
1.8.1.4



  reply	other threads:[~2013-12-16 12:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-16 12:38 [Cluster-devel] [resource-agents][PATCH 0/2] rgmanager: ra2rng.xsl et al.: cross-package schema extension Jan Pokorný
2013-12-16 12:38 ` Jan Pokorný [this message]
2013-12-16 12:38 ` [Cluster-devel] [PATCH 2/2] rgmanager: ra2rng.xsl et al.: enforce "forbid child" from RA metadata Jan Pokorný
2013-12-16 12:48   ` Jan Pokorný
2013-12-16 12:58   ` [Cluster-devel] [PATCH] " Jan Pokorný
2013-12-16 15:35     ` [Cluster-devel] [PATCHv3 2/2] " Jan Pokorný
2013-12-16 16:57       ` [Cluster-devel] [PATCHv4 " Jan Pokorný

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387197502-11551-2-git-send-email-jpokorny@redhat.com \
    --to=jpokorny@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).