Changeset 2953

Show
Ignore:
Timestamp:
09/27/08 22:28:48 (3 months ago)
Author:
david
Message:

made _common.xsl more modular, with callable templates for migrating elements to new namespcaes and separate templates for each envelope element

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/src/config/xsl/_common.xsl

    r2832 r2953  
    99  <xsl:variable name="envelope_1_0" select="'http://agavi.org/agavi/config/global/envelope/1.0'" /> 
    1010   
    11   <xsl:template match="envelope_0_11:configurations | envelope_0_11:configuration | envelope_0_11:sandbox | envelope_0_11:parameters | envelope_0_11:parameter"> 
    12     <xsl:element name="{local-name()}" namespace="{$envelope_1_0}"> 
     11  <!-- callable template for migrating envelope nodes --> 
     12  <xsl:template name="_common-migrate-envelope-element"> 
     13    <!-- param for the target namespace; defaults to 1.0 --> 
     14    <xsl:param name="namespace"><xsl:value-of select="$envelope_1_0" /></xsl:param> 
     15     
     16    <xsl:call-template name="_common-migrate-element"> 
     17      <xsl:with-param name="namespace"><xsl:value-of select="$namespace" /></xsl:with-param> 
     18    </xsl:call-template> 
     19  </xsl:template> 
     20   
     21  <xsl:template name="_common-migrate-element"> 
     22    <!-- param for the target namespace; no default --> 
     23    <xsl:param name="namespace" /> 
     24     
     25    <!-- create an element of the same name --> 
     26    <xsl:element name="{local-name()}" namespace="{$namespace}"> 
    1327      <xsl:copy-of select="@*" /> 
    1428      <!-- also copy all namespace declarations, except the one of the current element (otherwise, we'd overwrite the namespace in the <element> above if it's just xmlns etc) --> 
     
    1832  </xsl:template> 
    1933   
     34  <xsl:template match="envelope_0_11:configurations"> 
     35    <xsl:call-template name="_common-migrate-envelope" /> 
     36  </xsl:template> 
     37  <xsl:template match="envelope_0_11:configuration"> 
     38    <xsl:call-template name="_common-migrate-envelope" /> 
     39  </xsl:template> 
     40  <xsl:template match="envelope_0_11:sandbox"> 
     41    <xsl:call-template name="_common-migrate-envelope" /> 
     42  </xsl:template> 
     43  <xsl:template match="envelope_0_11:parameters"> 
     44    <xsl:call-template name="_common-migrate-envelope" /> 
     45  </xsl:template> 
     46  <xsl:template match="envelope_0_11:parameter"> 
     47    <xsl:call-template name="_common-migrate-envelope" /> 
     48  </xsl:template> 
     49   
    2050  <xsl:template match="*"> 
    2151    <xsl:copy-of select="." />