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

[Cluster-devel] [PATCH 1/2] rgmanager: ra2rng.xsl et al.: obsolete 1 pass in ccs_update_schema



... 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


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