Annotation of kupu/make-jspx.xsl, revision 1.1

1.1     ! dwinter     1: <?xml version="1.0" encoding="utf-8"?>
        !             2: <!--
        !             3: ##############################################################################
        !             4: #
        !             5: # Copyright (c) 2003-2005 Kupu Contributors. All rights reserved.
        !             6: #
        !             7: # This software is distributed under the terms of the Kupu
        !             8: # License. See LICENSE.txt for license text. For a list of Kupu
        !             9: # Contributors see CREDITS.txt.
        !            10: #
        !            11: ##############################################################################
        !            12: 
        !            13: Generate an JSPX template from Kupu distribution files
        !            14: 
        !            15: The main difference from make.xsl itself, is that this creates fmt:message tags for the i18n part.
        !            16: 
        !            17: This means that also the fmt-tags must be available, so your html.kupu must specificy something like:
        !            18:   <kupu:part name="html">
        !            19:     <html xmlns="http://www.w3.org/1999/xhtml"
        !            20:           xmlns:jsp="http://java.sun.com/JSP/Page        !            21:           xmlns:fmt="http://java.sun.com/jsp/jstl/fmt">
        !            22:       <jsp:output doctype-root-element="html"
        !            23:                   doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
        !            24:                   doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
        !            25:       <fmt:bundle basename="org.oscom.kupu.Messages">
        !            26:          <kupu:define-slot name="html" />
        !            27:       </fmt:bundle>
        !            28:     </html>
        !            29:   </kupu:part>
        !            30: 
        !            31: See also: common/kupu.pox.jspx (which can be used by i18n.js)
        !            32: -->
        !            33: <xsl:stylesheet
        !            34:    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        !            35:    xmlns:kupu="http://kupu.oscom.org/namespaces/dist"
        !            36:    xmlns:i18n="http://xml.zope.org/namespaces/i18n        !            37:    xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
        !            38:    xmlns:html="http://www.w3.org/1999/xhtml"
        !            39:    xmlns:jsp="http://java.sun.com/JSP/Page"
        !            40:    exclude-result-prefixes="kupu"
        !            41:    version="1.0"
        !            42:    >
        !            43:   <xsl:import href="make.xsl" />  
        !            44: 
        !            45: 
        !            46:   <xsl:template match="html:*" mode="expand">
        !            47:     <xsl:choose>
        !            48:       <xsl:when test="@i18n:translate">
        !            49:         <xsl:element name="{name()}">
        !            50:           <xsl:copy-of select="@html:*" />
        !            51:           <fmt:message>
        !            52:             <xsl:attribute name="key">
        !            53:               <xsl:choose>
        !            54:                 <xsl:when test="@i18n:translate = ''">
        !            55:                   <xsl:apply-templates select="text()" mode="expand-i18n" />
        !            56:                 </xsl:when>
        !            57:                 <xsl:otherwise>
        !            58:                   <xsl:value-of select="@i18n:translate" />
        !            59:                 </xsl:otherwise>
        !            60:               </xsl:choose>
        !            61:             </xsl:attribute>
        !            62:           </fmt:message>
        !            63:         </xsl:element>
        !            64:       </xsl:when>
        !            65:       <xsl:when test="@i18n:attributes">
        !            66:         <xsl:variable name="attributes"><xsl:value-of select="@i18n:attributes" /></xsl:variable>
        !            67:         <fmt:message var="_">
        !            68:           <xsl:attribute name="key">
        !            69:             <xsl:value-of select="@title" /><!-- should be @$attributes, but that doesn't work -->
        !            70:           </xsl:attribute>
        !            71:         </fmt:message>
        !            72:         <xsl:element name="{name()}">
        !            73:           <xsl:copy-of select="@html:*" />
        !            74:           <xsl:attribute name="{$attributes}">${_}</xsl:attribute>
        !            75:           <xsl:apply-templates  mode="expand" />
        !            76:         </xsl:element>
        !            77:       </xsl:when>
        !            78:       <xsl:otherwise>
        !            79:         <xsl:element name="{name()}">
        !            80:           <xsl:copy-of select="@html:*" />
        !            81:           <xsl:apply-templates  mode="expand" />
        !            82:         </xsl:element>
        !            83:       </xsl:otherwise>
        !            84:     </xsl:choose>
        !            85:   </xsl:template>
        !            86: 
        !            87:   <xsl:template match="html:html" mode="expand"> <!-- to preserve the namespaces-->
        !            88:     <xsl:copy>
        !            89:       <xsl:copy-of select="@*" />
        !            90:       <xsl:apply-templates mode="expand" />
        !            91:     </xsl:copy>
        !            92:   </xsl:template>
        !            93: 
        !            94:   <xsl:template match="html:select" mode="expand">
        !            95:     <!-- in some toolboxes an empty select appears, add jsp:text to avoid that it collapses away, which browsers cannot handle -->
        !            96:     <xsl:copy>
        !            97:       <xsl:copy-of select="@*" />
        !            98:       <jsp:text> </jsp:text>
        !            99:       <xsl:apply-templates mode="expand" />
        !           100:     </xsl:copy>
        !           101:   </xsl:template>
        !           102:   
        !           103:   <xsl:template match="text()" mode="expand-i18n">
        !           104:     <!-- this should probably be trim() rather then normalize-space (but that functions does not natively exist) -->
        !           105:     <xsl:value-of select="normalize-space(.)" />
        !           106:   </xsl:template>
        !           107: 
        !           108: </xsl:stylesheet>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>