You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ba...@locus.apache.org on 2000/09/16 20:24:32 UTC

cvs commit: xml-cocoon/samples/xinclude index.xml line1.txt line2.xml line6.txt poem.xml poem.xsl xinclude_poem.xml xinclude_poem.xsl

balld       00/09/16 11:24:31

  Added:       samples/xinclude index.xml line1.txt line2.xml line6.txt
                        poem.xml poem.xsl xinclude_poem.xml
                        xinclude_poem.xsl
  Log:
  added xinclude example courtesy of fleur diana dragan
  
  Revision  Changes    Path
  1.1                  xml-cocoon/samples/xinclude/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  <?xml-stylesheet href="../index.xsl" type="text/xsl"?>
  <?cocoon-process type="xslt"?>
  
  <samples>
   <group name="XInclude Example">
    <sample name="A Poem" url="xinclude_poem.xml">
     This is an example of xinclude (combined with xslt, so you get 
     some browser-renderable output).  There are three xinclude 
     directives in it: a simple include parsed as text, a simple 
     include parsed as xml and a more complicated include using 
     xpointer parsed as xml.  Plus the xpointer included stanza 
     itself has an xinclude in it, illustrating nested xinclude.
    </sample>
   </group>
  
  </samples>
  
  
  
  1.1                  xml-cocoon/samples/xinclude/line1.txt
  
  Index: line1.txt
  ===================================================================
  there was a little girl
  
  
  
  1.1                  xml-cocoon/samples/xinclude/line2.xml
  
  Index: line2.xml
  ===================================================================
  <?xml version="1.0" encoding="utf-8"?>
  
  <!--
       This file is included via xinclude in the xinclude_poem.xml
       document.
    -->
  
  <line>who had a little curl</line>
  
  
  
  1.1                  xml-cocoon/samples/xinclude/line6.txt
  
  Index: line6.txt
  ===================================================================
  and when she was bad, she was horrid.
  
  
  
  1.1                  xml-cocoon/samples/xinclude/poem.xml
  
  Index: poem.xml
  ===================================================================
  <?xml version="1.0"?>
  <?xml-stylesheet href="poem.xsl" type="text/xsl"?>
  <?cocoon-process type="xinclude"?>
  <?cocoon-process type="xslt"?>
  
  <!--
       This file is provided to illustrate XInclude using XPointer.
       The second stanza of this poem is included in xinclude_poem.xml.
  
       This also works by itself as an xslt example, but that's 
       just for completeness.
    -->
  
  <poem xmlns:xinclude="http://www.w3.org/1999/XML/xinclude" title="A Poem">
  
    <stanza id="1">
      <line>there was a little girl</line>
  	  <line>who had a little curl</line>
  	  <line>right in the middle of her forehead</line>
    </stanza>
  
    <stanza id="2">
      <line>and when she was good</line>
      <line>she was very very good</line>
      <line><whatever xinclude:href="line6.txt" xinclude:parse="text" /></line>
    </stanza>
  
  </poem>
  
  
  
  1.1                  xml-cocoon/samples/xinclude/poem.xsl
  
  Index: poem.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0" 
                  id="poem_style"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <!--
       This file is provided purely to make the "poem.xml" file a 
       complete xslt example, which is not, in fact, the point of this 
       exercise.
    -->
  
    <xsl:template match="poem">
     <html>
      <head>
       <title>
        <xsl:value-of select="@title"/>
       </title>
      </head>
      <body bgcolor="#ffffff">
       <h1><xsl:value-of select="@title"/></h1>
       <xsl:apply-templates select="stanza"/>
      </body>
     </html>
    </xsl:template>
  
    <xsl:template match="stanza">
      <p>
        <xsl:apply-templates />
      </p>
    </xsl:template>
  
    <xsl:template match="line">
      <xsl:value-of select="." /><br></br>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-cocoon/samples/xinclude/xinclude_poem.xml
  
  Index: xinclude_poem.xml
  ===================================================================
  <?xml version="1.0"?>
  <?xml-stylesheet href="xinclude_poem.xsl" type="text/xsl"?>
  <?cocoon-process type="xinclude"?>
  <?cocoon-process type="xslt"?>
  
  <!--
       This file illustrates the xinclude filter, including 
       parse="text", parse="xml" and a href containing an XPointer
       expression.  The bit included by the xpointer include itself 
       contains an include.
  
       This document is also processed a second time (as evidenced 
       by the cocoon PIs above) using xslt to produce nice output, 
       which isn't strictly necessary for the example, but it's nice 
       to get something to see in your browser when you hit xinclude_poem.xml.
    -->
  
  <poem xmlns:xinclude="http://www.w3.org/1999/XML/xinclude" title="A Poem">
  
    <stanza>
      <line><whatever xinclude:href="line1.txt" xinclude:parse="text" /></line>
  	  <whatever xinclude:href="line2.xml" xinclude:parse="xml" />
  	  <line>right in the middle of her forehead</line>
    </stanza>
  
    <include xinclude:parse="xml" 
             xinclude:href="poem.xml#xpointer(//stanza[@id='2'])" />
  
  </poem>
  
  
  
  1.1                  xml-cocoon/samples/xinclude/xinclude_poem.xsl
  
  Index: xinclude_poem.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <!--
       This file is the stylesheet for the xinclude_poem.xml example
       so that something browser-renderable comes out.
    -->
  
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <xsl:template match="poem">
     <html>
      <head>
       <title>
        <xsl:value-of select="@title"/>
       </title>
      </head>
      <body bgcolor="#ffffff">
       <h1><xsl:value-of select="@title"/></h1>
       <xsl:apply-templates select="stanza"/>
      </body>
     </html>
    </xsl:template>
  
    <xsl:template match="stanza">
      <p>
        <xsl:apply-templates />
      </p>
    </xsl:template>
  
    <xsl:template match="line">
      <xsl:value-of select="." /><br></br>
    </xsl:template>
  
  </xsl:stylesheet>