cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gree...@locus.apache.org
Subject cvs commit: xml-cocoon/xdocs faq.xml
Date Wed, 01 Nov 2000 12:04:08 GMT
greenrd     00/11/01 04:04:07

  Modified:    xdocs    faq.xml
  Log:
  alternative XSLT way of selecting stylesheets at request-time
  
  Revision  Changes    Path
  1.25      +43 -1     xml-cocoon/xdocs/faq.xml
  
  Index: faq.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/xdocs/faq.xml,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- faq.xml	2000/10/29 11:19:09	1.24
  +++ faq.xml	2000/11/01 12:04:05	1.25
  @@ -750,7 +750,7 @@
     <question>Is is possible to specify the stylesheet to be used by means
      of a request parameter?</question>
     <answer>
  -   <p>Yes. You'll need to use XSP, as follows:</p>
  +   <p>Yes. You can either use XSP, as follows...</p>
   
      <source>
       <![CDATA[
  @@ -765,6 +765,48 @@
           </xsp:pi> 
          </page>
        </xsp:page>
  +    ]]>
  +   </source>
  +
  +   <p>... or XSLT, as follows:</p>
  +
  +   <source>
  +    <![CDATA[
  +  <?xml version="1.0"?>
  +  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  +  version="1.0">
  +
  +    <xsl:param name="style"/>
  +      <xsl:template match="/">
  +        <xsl:choose>
  +          <!-- when style is specified -->
  +          <xsl:when test="$style">
  +            <xsl:processing-instruction name="xml-stylesheet">
  +              href="<xsl:value-of select="$style"/>" type="text/xsl"
  +            </xsl:processing-instruction>
  +            <xsl:processing-instruction name="cocoon-process">
  +              type="xslt"
  +            </xsl:processing-instruction>
  +          </xsl:when>
  +          <!-- Otherwise use default.xsl -->
  +          <xsl:otherwise>
  +            <xsl:processing-instruction name="xml-stylesheet">
  +              href="default.xsl" type="text/xsl"
  +            </xsl:processing-instruction>
  +            <xsl:processing-instruction name="cocoon-process">
  +              type="xslt"
  +            </xsl:processing-instruction>
  +          </xsl:otherwise>
  +        </xsl:choose>
  +
  +        <xsl:apply-templates/>
  +      </xsl:template>
  +
  +      <!-- copy all elements -->
  +      <xsl:template match="@*|*|text">
  +        <xsl:copy-of select="."/>
  +      </xsl:template>
  +    </xsl:stylesheet>
       ]]>
      </source>
     </answer>
  
  
  

Mime
View raw message