home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / xinclude-transformer.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  4.2 KB  |  148 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.0//EN" "document-v10.dtd">
  18.  
  19. <document>
  20.  <header>
  21.   <title>XInclude Transformer</title>
  22.   <subtitle>in @doctitle@</subtitle>
  23.   <version>0.9</version>
  24.   <type>Technical document</type>
  25.   <authors>
  26.   <person name="Carsten Ziegeler" email="cziegeler@apache.org"/>
  27.   </authors>
  28.   <abstract>This document describes the XInclude transformer.</abstract>
  29.  </header>
  30.  <body>
  31.   <s1 title="XInclude Transformer">
  32.    <p>
  33.     This transformer works according to the XInclude specification.
  34.    </p>
  35.    <p>
  36.     For more information refer to the
  37.     <link href="http://www.w3.org/TR/xinclude">XInclude specification</link>.
  38.    </p>
  39.    <ul>
  40.     <li>Name : xinclude</li>
  41.     <li>Class: org.apache.cocoon.transformation.XIncludeTransformer</li>
  42.     <li>Cacheable: no.</li>
  43.    </ul>
  44.    <p>
  45.     You can include either simple text, or xml content. 
  46.     Including xml content -- which is the default --
  47.     gives you the option to define an xpointer in the href attribute. Some
  48.     quick xinclude examples should reveal the possibilities of xinclude. 
  49.    </p>
  50.    <ul>
  51.     <li>
  52.      Include an xml content as-is: 
  53.      <code><![CDATA[<xi:include href="include.xml"/>]]></code>
  54.     </li>
  55.     <li>
  56.      Include an xml content but pick the strong element only:
  57.      <code><![CDATA[<xi:include href="include.xml#xpointer(/p/strong)"/>]]></code>
  58.     </li>
  59.     <li>
  60.      Include text content:
  61.      <code><![CDATA[<xi:include parse="text" href="include.txt"/>]]></code>
  62.     </li>
  63.    </ul>
  64.  
  65.    <p>
  66.     A simple example using xinclude might help to use this transfomer
  67.     effectively:
  68.    </p>
  69.    <p>
  70.     Add the XIncludetransfomer to the components in your sitemap.xmap
  71.    </p>
  72. <source><![CDATA[
  73. ...
  74. <map:components>
  75. ...
  76.   <map:transformers default="xslt">
  77.   ...
  78.     <map:transformer name="xinclude"
  79.       src="org.apache.cocoon.transformation.XIncludeTransformer"/>
  80.   ...
  81. ]]></source>
  82.  
  83.    <p>
  84.     Next define in your pipeline to use the XIncludeTransformer
  85.    </p>
  86. <source><![CDATA[
  87. <map:match pattern="xinc/simple-xinc">
  88.   <map:generate src="xinc/simple-xinc.xml"/>
  89.   <map:transform type="xinclude"/>
  90.   <map:transform src="stylesheets/page/simple-page2html.xsl"/>
  91.   <map:serialize/>
  92. </map:match>
  93. ]]></source>
  94.  
  95.    <p>
  96.     In this example pipeline it assumed that simple-xinc.xml contains
  97.     the include element. As well as defining the include element,
  98.     it defines the namespace URI "http://www.w3.org/2001/XInclude".
  99.     This helps the XIncludeTransformer to find the include element to 
  100.     get replaced by the included content.
  101.     The simple-xinc.xml may look like this:
  102.    </p>
  103. <source><![CDATA[
  104. <?xml version="1.0" encoding="UTF-8"?>
  105. <page 
  106.   xmlns:xi="http://www.w3.org/2001/XInclude">
  107.   <title>Hello</title>
  108.   <content>
  109.     <para>This is my first Cocoon page!</para>
  110.     <xi:include href="include.xml"/>
  111.   </content>
  112. </page>
  113. ]]></source>
  114.  
  115.    <p>
  116.     Next you should define the include.xml file which is included.
  117.     A simple include.xml might look like this:
  118.    </p>
  119. <source><![CDATA[
  120. <?xml version="1.0"?>
  121. <p>
  122.   I am <strong>included</strong> by XIncludeTransformer.
  123.   I come from "include.xml".
  124. </p>
  125. ]]></source>
  126.  
  127.    <p>
  128.     Now finally we have everything put together the xml content after the 
  129.     XIncludeTransformer processing will look like this:
  130.    </p>
  131. <source><![CDATA[
  132. <?xml version="1.0" encoding="UTF-8"?>
  133. <page 
  134.   xmlns:xi="http://www.w3.org/2001/XInclude">
  135.   <title>Hello</title>
  136.   <content>
  137.     <para>This is my first Cocoon page!</para>
  138.       <p>
  139.        I am <strong>included</strong> by XIncludeTransformer.
  140.        I come from "include.xml".
  141.       </p>
  142.   </content>
  143. </page>
  144. ]]></source>
  145.   </s1>
  146.  </body>
  147. </document>
  148.