stephan     2003/05/10 04:34:10

  Modified:    src/webapp/samples/i18n menu.xml multi.xml simple.xml
                        simple.xsp sitemap.xmap
  Added:       src/webapp/samples/i18n simple2page.xsl
  Removed:     src/webapp/samples/i18n menu2html.xsl page.css simple.xsl
                        site2html.xsl
               src/webapp/samples/i18n/images chapter.gif chapter_open.gif
                        current.gif page.gif
  Log:
  Refactoring i18n samples.
  
  Revision  Changes    Path
  1.5       +4 -4      cocoon-2.1/src/webapp/samples/i18n/menu.xml
  
  Index: menu.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/i18n/menu.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- menu.xml  27 Mar 2003 07:33:09 -0000      1.4
  +++ menu.xml  10 May 2003 11:34:09 -0000      1.5
  @@ -39,14 +39,14 @@
     </menu>
   
     <menu label="Documentation" i18n:attr="label">
  -    <external label="i18n transformer docs" 
href="http://cocoon.apache.org/userdocs/transformers/i18n-transformer.html"; 
i18n:attr="label"/>   
  -    <external label="i18n transformer Javadoc" 
href="http://cocoon.apache.org/apidocs/org/apache/cocoon/transformation/I18nTransformer.html";
 i18n:attr="label"/>   
  -    <external label="LocaleAction Javadoc" 
href="http://cocoon.apache.org/apidocs/org/apache/cocoon/acting/LocaleAction.html";
 i18n:attr="label"/>   
  +    <external label="i18n transformer docs" 
href="http://cocoon.apache.org/2.1/userdocs/transformers/i18n-transformer.html"; 
i18n:attr="label"/>   
  +    <external label="i18n transformer Javadoc" 
href="http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/transformation/I18nTransformer.html";
 i18n:attr="label"/>   
  +    <external label="LocaleAction Javadoc" 
href="http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/acting/LocaleAction.html";
 i18n:attr="label"/>   
     </menu>
     
     <menu label="Credits" i18n:attr="label">
       <menu-item label="Konstantin Piroumian" href="mailto:[EMAIL PROTECTED]" 
i18n:attr="label" />  
  -    <menu-item label="Many others..." 
href="http://cocoon.apache.org/who.html"; i18n:attr="label"/>      
  +    <menu-item label="Many others..." 
href="http://cocoon.apache.org/2.1/who.html"; i18n:attr="label"/>      
     </menu>  
      
   </book>
  
  
  
  1.2       +2 -2      cocoon-2.1/src/webapp/samples/i18n/multi.xml
  
  Index: multi.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/i18n/multi.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- multi.xml 9 Mar 2003 00:11:09 -0000       1.1
  +++ multi.xml 10 May 2003 11:34:09 -0000      1.2
  @@ -1,5 +1,5 @@
   <?xml version="1.0" encoding="UTF-8"?>
  -<root xmlns:i18n="http://apache.org/cocoon/i18n/2.1"; i18n:attr="language" 
language="language">
  +<document xmlns:i18n="http://apache.org/cocoon/i18n/2.1"; 
i18n:attr="language" language="language">
        <title>
                <i18n:text>titletext</i18n:text>
        </title>
  @@ -10,4 +10,4 @@
       <para>Here we take the key 'language' from the default (= messages) 
catalogue: <i18n:text>language</i18n:text>.</para>
       <para>Here we take the key 'Documentation' from the menu catalogue: 
<i18n:text i18n:catalogue="menu">Documentation</i18n:text>.</para>
     </content>
  -</root>
  +</document>
  
  
  
  1.2       +3 -3      cocoon-2.1/src/webapp/samples/i18n/simple.xml
  
  Index: simple.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/i18n/simple.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- simple.xml        9 Mar 2003 00:11:09 -0000       1.1
  +++ simple.xml        10 May 2003 11:34:09 -0000      1.2
  @@ -1,5 +1,5 @@
   <?xml version="1.0" encoding="UTF-8"?>
  -<root xmlns:i18n="http://apache.org/cocoon/i18n/2.1"; i18n:attr="language" 
language="language">
  +<document xmlns:i18n="http://apache.org/cocoon/i18n/2.1"; 
i18n:attr="language" language="language">
        <title>
                <i18n:text>titletext</i18n:text>
        </title>
  @@ -11,7 +11,7 @@
                        <i18n:text i18n:key="doclink"/>
                        <i18n:param>
                                <link>
  -                                     
<href>http://cocoon.apache.org/userdocs/transformers/i18n-transformer.html</href>
  +                                     
<href>http://cocoon.apache.org/2.1/userdocs/transformers/i18n-transformer.html</href>
                                        <title>Cocoon 2 Web Site</title>
                                </link>
                        </i18n:param>
  @@ -63,4 +63,4 @@
                        <i18n:text>copyright</i18n:text>
                </copyright>
        </bottom>
  -</root>
  +</document>
  
  
  
  1.2       +3 -3      cocoon-2.1/src/webapp/samples/i18n/simple.xsp
  
  Index: simple.xsp
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/i18n/simple.xsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- simple.xsp        9 Mar 2003 00:11:09 -0000       1.1
  +++ simple.xsp        10 May 2003 11:34:09 -0000      1.2
  @@ -7,7 +7,7 @@
       <xsp:logic>
           private static int count = 0;
       </xsp:logic>
  -    <root i18n:attr="language" language="language">
  +    <document i18n:attr="language" language="language">
           <xsp-request:get-session/>
           <xsp:logic>
               synchronized (this) {
  @@ -28,7 +28,7 @@
                   <i18n:text i18n:key="doclink"/>
                   <i18n:param>
                       <link>
  -                        
<href>http://cocoon.apache.org/userdocs/transformers/i18n-transformer.html</href>
  +                        
<href>http://cocoon.apache.org/2.1/userdocs/transformers/i18n-transformer.html</href>
                           <title>Cocoon 2 Web Site</title>
                       </link>
                   </i18n:param>
  @@ -101,5 +101,5 @@
                   <i18n:text>copyright</i18n:text>
               </copyright>
           </bottom>
  -    </root>
  +    </document>
   </xsp:page>
  
  
  
  1.3       +127 -142  cocoon-2.1/src/webapp/samples/i18n/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/i18n/sitemap.xmap,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- sitemap.xmap      26 Mar 2003 21:21:40 -0000      1.2
  +++ sitemap.xmap      10 May 2003 11:34:09 -0000      1.3
  @@ -1,146 +1,131 @@
   <?xml version="1.0"?>
   <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0";>
  -
  -    <!-- =========================== Components 
================================ -->
  -    <map:components>
  -        <map:generators default="file"/>
  -        
  -        <map:transformers default="xslt">
  -            <!-- Configure i18n transformer -->
  -            <map:transformer name="i18n" logger="sitemap.transformer.i18n" 
  -                src="org.apache.cocoon.transformation.I18nTransformer">
  -                <catalogues default="messages">
  -                  <catalogue id="messages" name="messages" 
location="translations"/>
  -                  <catalogue id="menu" name="menu" location="translations"/>
  -                </catalogues>
  -                <cache-at-startup>true</cache-at-startup>
  -            </map:transformer>
  -        </map:transformers>
  -        
  -        <map:readers default="resource"/>
  -        <map:serializers default="html"/>
  -        <map:selectors default="browser"/>
  -        <map:matchers default="wildcard"/>
  -    
  -        <!-- =========================== Actions 
================================= -->   
  -        <map:actions>
  -            <!-- LocaleAction is used to set/get current users locale. See 
Javadocs for details. -->
  -            <map:action name="locale" logger="sitemap.action.locale" 
src="org.apache.cocoon.acting.LocaleAction">
  -                <!-- Creates a new session if needed. Used with 
'store-in-session' param -->
  -                <create-session>true</create-session>
  -                <!-- Stores locale information in session. A session should 
be created before, 
  -                       otherwise 'create-session' should be true.
  -                -->
  -                <store-in-session>true</store-in-session>
  -                <!-- Stores locale information in request attributes -->     
        
  -                <store-in-request>true</store-in-request>
  -                <!-- Stores locale information in a client cookie -->        
     
  -                <store-in-cookie>false</store-in-cookie>
  -            
  -                <!-- Uncomment as needed to override defaults:
  -                <locale-attribute>locale</locale-attribute>
  -                <language-attribute>language</language-attribute>
  -                <country-attribute>country</country-attribute>
  -                <variant-attribute>variant</variant-attribute>
  +  <!-- =========================== Components 
================================ -->
  +  <map:components>
  +    <map:generators default="file"/>
  +    <map:transformers default="xslt">
  +      <!-- Configure i18n transformer -->
  +      <map:transformer name="i18n" logger="sitemap.transformer.i18n" 
src="org.apache.cocoon.transformation.I18nTransformer">
  +        <catalogues default="messages">
  +          <catalogue id="messages" name="messages" location="translations"/>
  +          <catalogue id="menu" name="menu" location="translations"/>
  +        </catalogues>
  +        <cache-at-startup>true</cache-at-startup>
  +      </map:transformer>
  +    </map:transformers>
  +    <map:readers default="resource"/>
  +    <map:serializers default="html"/>
  +    <map:selectors default="browser"/>
  +    <map:matchers default="wildcard"/>
  +    <!-- =========================== Actions 
================================= -->
  +    <map:actions>
  +      <!-- LocaleAction is used to set/get current users locale. See 
Javadocs for details. -->
  +      <map:action name="locale" logger="sitemap.action.locale" 
src="org.apache.cocoon.acting.LocaleAction">
  +        <!-- Creates a new session if needed. Used with 'store-in-session' 
param -->
  +        <create-session>true</create-session>
  +        <!-- Stores locale information in session. A session should be 
created before, 
  +             otherwise 'create-session' should be true.
                   -->
  -            </map:action>
  -        </map:actions>
  -    </map:components>
  -
  -    <!-- =========================== Resources 
=============================== -->
  -    <map:resources>
  -        <!-- This resource is used to create a composite page from menu and 
content -->
  -        <map:resource name="composite">
  -            <map:aggregate element="site">
  -                <map:part src="cocoon:/menu/{../0}"/>
  -                <map:part src="cocoon:/content/{../0}" label="content"/>
  -            </map:aggregate>
  -            <map:transform src="site2html.xsl">
  -                <map:parameter name="page" value="{../0}" />
  -                <map:parameter name="locale" value="{../../locale}" />       
         
  -            </map:transform>
  -            <map:serialize/>
  -        </map:resource>
  -    </map:resources>
  -
  -    <!-- =========================== Pipelines 
================================= -->
  -    <map:pipelines>
  -        <!-- Locale aware content generation pipeline -->            
  -        <map:pipeline>
  -            <map:act type="locale">
  -            
  -                <!-- Default pipeline -->
  -                <map:match pattern="">
  -                    <map:redirect-to uri="simple.xml"/>
  -                </map:match>
  -            
  -                <!-- Generate static output (simple.xml) -->
  -                <map:match pattern="*.xml">
  -                    <map:call resource="composite" />
  -                </map:match>
  -            
  -                <!-- Generate dynamic output (simple.xsp) -->            
  -                <map:match pattern="*.xsp">
  -                    <map:call resource="composite" />
  -                </map:match>                
  -                
  -                <!-- A helper matcher for static content translation and 
generation -->
  -                <map:match pattern="content/*.xml">
  -                        <map:generate src="{1}.xml"/>
  -                        <map:transform type="i18n">
  -                            <map:parameter name="locale" 
value="{../locale}"/>
  -                        </map:transform>
  -                        <map:transform src="simple.xsl"/>
  -                        <map:serialize/>
  -                </map:match>
  -            
  -                <!-- A helper matcher for dynamic content translation and 
generation -->
  -                <map:match pattern="content/*.xsp">
  -                        <map:generate type="serverpages" src="{1}.xsp"/>
  -                        <map:transform type="i18n">
  -                            <map:parameter name="locale" 
value="{../locale}"/>
  -                        </map:transform>
  -                        <map:transform src="simple.xsl"/>
  -                        <map:serialize/>
  -                </map:match>
  -    
  -                <!-- Menu generation -->
  -                <map:match pattern="menu/*">
  -                        <map:generate src="menu.xml"/>
  -                        <map:transform type="i18n">
  -                            <!-- Override default catalogue for this 
pipeline -->
  -                            <map:parameter name="default-catalogue-id" 
value="menu"/>
  -                            <map:parameter name="locale" 
value="{../locale}"/>
  -                        </map:transform>
  -                        <map:transform src="menu2html.xsl">
  -                            <map:parameter name="locale" value="{../locale}" 
/>
  -                            <map:parameter name="page" value="{1}" />
  -                        </map:transform>
  -                        <map:serialize/>
  -                </map:match>
  -            </map:act>
  -        </map:pipeline>                
  -               
  -        <!-- General purpose pipeline  -->        
  -        <map:pipeline>
  -            
  -            <!-- Display this sitemap source-->
  -            <map:match pattern="sitemap.xmap">
  -                <map:generate src="sitemap.xmap"/>
  -                <map:transform 
src="context://stylesheets/system/xml2html.xslt"/>
  -                <map:serialize/>
  -            </map:match>            
  -            
  -            <map:match pattern="*.css">
  -                <map:read src="{1}.css" mime-type="text/css"/>
  -            </map:match>
  -            
  -            <map:match pattern="images/*.gif">
  -                <map:read src="images/{1}.gif" mime-type="image/gif"/>
  -            </map:match>
  -        </map:pipeline>
  -        
  -    </map:pipelines>
  -    
  -</map:sitemap>
  +        <store-in-session>true</store-in-session>
  +        <!-- Stores locale information in request attributes -->
  +        <store-in-request>true</store-in-request>
  +        <!-- Stores locale information in a client cookie -->
  +        <store-in-cookie>false</store-in-cookie>
  +        <!-- Uncomment as needed to override defaults:
  +             <locale-attribute>locale</locale-attribute>
  +             <language-attribute>language</language-attribute>
  +             <country-attribute>country</country-attribute>
  +             <variant-attribute>variant</variant-attribute>
  +          -->
  +      </map:action>
  +    </map:actions>
  +  </map:components>
  +
  +  <!-- =========================== Resources =============================== 
-->
  +  <map:resources>
  +    <!-- This resource is used to create a composite page from menu and 
content -->
  +    <map:resource name="composite">
  +      <map:aggregate element="root">
  +        <map:part src="cocoon:/menu/{../0}"/>
  +        <map:part src="cocoon:/content/{../0}" label="content"/>
  +      </map:aggregate>
  +      <map:transform type="xalan" src="simple2page.xsl">
  +        <map:parameter name="page" value="{../0}"/>
  +        <map:parameter name="locale" value="{../../locale}"/>
  +      </map:transform>
  +      <map:transform 
src="context://samples/common/style/xsl/html/complex-page2html.xsl">
  +        <map:parameter name="contextPath" value="{request:contextPath}"/>
  +      </map:transform>
  +      <map:serialize type="html"/>
  +    </map:resource>
  +  </map:resources>
  +
  +  <!-- =========================== Pipelines 
================================= -->
  +  <map:pipelines>
  +    <!-- Locale aware content generation pipeline -->
  +    <map:pipeline>
  +      <map:act type="locale">
  +
  +        <!-- Default pipeline -->
  +        <map:match pattern="">
  +          <map:redirect-to uri="simple.xml"/>
  +        </map:match>
   
  +        <!-- Generate static output (simple.xml) -->
  +        <map:match pattern="*.xml">
  +          <map:call resource="composite"/>
  +        </map:match>
  +
  +        <!-- Generate dynamic output (simple.xsp) -->
  +        <map:match pattern="*.xsp">
  +          <map:call resource="composite"/>
  +        </map:match>
  +
  +        <!-- A helper matcher for static content translation and generation 
-->
  +        <map:match pattern="content/*.xml">
  +          <map:generate src="{1}.xml"/>
  +          <map:transform type="i18n">
  +            <map:parameter name="locale" value="{../locale}"/>
  +          </map:transform>
  +          <map:serialize/>
  +        </map:match>
  +
  +        <!-- A helper matcher for dynamic content translation and generation 
-->
  +        <map:match pattern="content/*.xsp">
  +          <map:generate type="serverpages" src="{1}.xsp"/>
  +          <map:transform type="i18n">
  +            <map:parameter name="locale" value="{../locale}"/>
  +          </map:transform>
  +          <map:serialize/>
  +        </map:match>
  +
  +        <!-- Menu generation -->
  +        <map:match pattern="menu/*">
  +          <map:generate src="menu.xml"/>
  +          <map:transform type="i18n">
  +            <!-- Override default catalogue for this pipeline -->
  +            <map:parameter name="default-catalogue-id" value="menu"/>
  +            <map:parameter name="locale" value="{../locale}"/>
  +          </map:transform>
  +          <map:serialize/>
  +        </map:match>
  +      </map:act>
  +    </map:pipeline>
  +
  +    <!-- General purpose pipeline  -->
  +    <map:pipeline>
  +      <!-- Display this sitemap source-->
  +      <map:match pattern="sitemap.xmap">
  +        <map:generate src="sitemap.xmap"/>
  +        <map:transform src="context://stylesheets/system/xml2html.xslt"/>
  +        <map:serialize/>
  +      </map:match>
  +      <map:match pattern="*.css">
  +        <map:read src="{1}.css" mime-type="text/css"/>
  +      </map:match>
  +      <map:match pattern="images/*.gif">
  +        <map:read src="images/{1}.gif" mime-type="image/gif"/>
  +      </map:match>
  +    </map:pipeline>
  +  </map:pipelines>
  +</map:sitemap>
  
  
  
  1.1                  cocoon-2.1/src/webapp/samples/i18n/simple2page.xsl
  
  Index: simple2page.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">
    <xsl:param name="locale"/>
    <xsl:param name="page"/>
  
    <xsl:template match="root">
      <document>
        <header>
          <title>Internationalization (i18n) and Localization (l10n)</title>
        </header>
        <body>
          <row>
            <column title="Menu">
              <xsl:apply-templates select="book"/>
            </column>
            <column title="{document/title}">
              <xsl:apply-templates select="document"/>
            </column>
          </row>
        </body>
      </document>
    </xsl:template>
  
    <xsl:template match="document">
      <h2>
        <font color="navy">
          <xsl:value-of select="title"/>
        </font>
        <xsl:apply-templates select="form"/>
      </h2>
      <h5>
        <xsl:value-of select="sub-title"/>
      </h5>
      <hr align="left" noshade="noshade" size="1"/>
      <small>
        <font color="red">
          <i>
            <xsl:apply-templates select="annotation"/>
          </i>
        </font>
      </small>
      <xsl:apply-templates select="content"/>
      <hr align="left" noshade="noshade" size="1"/>
      <xsl:apply-templates select="bottom"/>
    </xsl:template>
  
    <xsl:template match="book">
      <xsl:apply-templates select="menu"/>
    </xsl:template>
  
    <!-- Current (open) menu -->
    <xsl:template match="menu">
      <xsl:if test="@icon">
        <img src="[EMAIL PROTECTED]" align="middle"/>
        <xsl:text> </xsl:text>
      </xsl:if>
      <h3>
        <xsl:value-of select="@label"/>
      </h3>
      <ul>
        <xsl:apply-templates/>
      </ul>
    </xsl:template>
  
    <!-- Display a link to a page -->
    <xsl:template match="menu-item[substring-after(@href, 'locale=') = $locale 
or @href=$page or (@href='' and $locale='')]">
      <li class="current" title="[EMAIL PROTECTED]">
        <xsl:if test="@icon">
          <img src="[EMAIL PROTECTED]" align="middle"/>
          <xsl:text> </xsl:text>
        </xsl:if>
        <xsl:value-of select="@label"/>
      </li>
    </xsl:template>
  
    <xsl:template match="menu-item | external">
      <li class="page">
        <xsl:if test="@icon">
          <img src="[EMAIL PROTECTED]" align="middle"/>
          <xsl:text> </xsl:text>
        </xsl:if>
        <a href="[EMAIL PROTECTED]" class="page">
          <xsl:value-of select="@label"/>
        </a>
      </li>
    </xsl:template>
  
    <xsl:template match="node()|@*" priority="-1">
      <xsl:copy>
        <xsl:apply-templates select="@*"/>
        <xsl:apply-templates/>
      </xsl:copy>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  

Reply via email to