[yelp-tools] mal-rng.xsl: Exclude non-combine start from non-first



commit ad40d353782b022398e8fad31b494f6a4daad808
Author: Shaun McCance <shaunm gnome org>
Date:   Thu May 5 20:01:24 2011 -0400

    mal-rng.xsl: Exclude non-combine start from non-first

 xslt/mal-rng.xsl |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/xslt/mal-rng.xsl b/xslt/mal-rng.xsl
index bc75c4d..e80e44c 100644
--- a/xslt/mal-rng.xsl
+++ b/xslt/mal-rng.xsl
@@ -60,8 +60,10 @@
   <xsl:variable name="nss" select="exsl:node-set($nss_)/*[not(@ns = preceding-sibling::*/@ns)]"/>
   <grammar>
     <xsl:for-each select="str:split($uris)">
+      <xsl:variable name="first" select="position() = 1"/>
       <xsl:for-each select="document(.)/rng:grammar">
         <xsl:apply-templates mode="rng.mode" select="*">
+          <xsl:with-param name="first" select="$first"/>
           <xsl:with-param name="ns" select="string(@ns)"/>
           <xsl:with-param name="nss" select="$nss"/>
         </xsl:apply-templates>
@@ -75,6 +77,7 @@
 </xsl:template>
 
 <xsl:template mode="rng.mode" match="*">
+  <xsl:param name="first"/>
   <xsl:param name="ns"/>
   <xsl:param name="nss"/>
   <xsl:variable name="nsmunge" select="self::rng:element or self::rng:attribute"/>
@@ -107,13 +110,33 @@
       </xsl:choose>
     </xsl:if>
     <xsl:apply-templates mode="rng.mode">
+      <xsl:with-param name="first" select="$first"/>
       <xsl:with-param name="ns" select="$ns"/>
       <xsl:with-param name="nss" select="$nss"/>
     </xsl:apply-templates>
   </xsl:copy>
 </xsl:template>
 
+<xsl:template mode="rng.mode" match="rng:start">
+  <xsl:param name="first"/>
+  <xsl:param name="ns"/>
+  <xsl:param name="nss"/>
+  <xsl:if test="$first or @combine = 'choice' or @combine = 'interleave'">
+    <xsl:copy>
+      <xsl:for-each select="@*">
+        <xsl:copy-of select="."/>
+      </xsl:for-each>
+      <xsl:apply-templates mode="rng.mode">
+        <xsl:with-param name="first" select="$first"/>
+        <xsl:with-param name="ns" select="$ns"/>
+        <xsl:with-param name="nss" select="$nss"/>
+      </xsl:apply-templates>
+    </xsl:copy>
+  </xsl:if>
+</xsl:template>
+
 <xsl:template mode="rng.mode" match="rng:anyName/rng:except">
+  <xsl:param name="first"/>
   <xsl:param name="ns"/>
   <xsl:param name="nss"/>
   <except>



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