A document has been updated:
http://cocoon.zones.apache.org/daisy/documentation/985.html
Document ID: 985
Branch: main
Language: default
Name: XIncludeTransformer (unchanged)
Document Type: Sitemap Component (unchanged)
Updated on: 6/4/07 8:29:10 PM
Updated by: Alexander Klimetschek
A new version has been created, state: draft
Parts
=====
Short description
-----------------
This part has been updated.
Mime type: text/xml (unchanged)
File name: (unchanged)
Size: 81 bytes (previous version: 3073 bytes)
Content diff:
<html>
<body>
--- <p>This transformer works according to the XInclude specification.</p>
+++ <p>Implementation of an XInclude transformer.</p>
--- <p>For more information refer to the
--- <a href="http://www.w3.org/TR/xinclude">XInclude specification</a>.</p>
---
--- <ul>
--- <li>Name : xinclude</li>
--- <li>Class: org.apache.cocoon.transformation.XIncludeTransformer</li>
--- <li>Cacheable: yes.</li>
--- </ul>
---
--- <p>You can include either simple text, or xml content. Including xml
content --
--- which is the default -- gives you the option to define an xpointer in the
href
--- attribute. Some quick xinclude examples should reveal the possibilities of
--- xinclude.</p>
---
--- <ul>
--- <li>Include an xml content as-is: <tt><xi:include
--- href="include.xml"/></tt></li>
--- <li>Include an xml content but pick the strong element only:
<tt><xi:include
--- href="include.xml#xpointer(/p/strong)"/></tt></li>
--- <li>Include text content: <tt><xi:include parse="text"
--- href="include.txt"/></tt></li>
--- </ul>
---
--- <p>A simple example using xinclude might help to use this transfomer
--- effectively:</p>
---
--- <p>Add the XIncludetransfomer to the components in your sitemap.xmap</p>
---
--- <pre>...
--- <map:components>
--- ...
--- <map:transformers default="xslt">
--- ...
--- <map:transformer name="xinclude"
--- src="org.apache.cocoon.transformation.XIncludeTransformer"/>
--- ...
--- </pre>
---
--- <p>Next define in your pipeline to use the XIncludeTransformer</p>
---
--- <pre><map:match pattern="xinc/simple-xinc">
--- <map:generate src="xinc/simple-xinc.xml"/>
--- <map:transform type="xinclude"/>
--- <map:transform src="stylesheets/page/simple-page2html.xsl"/>
--- <map:serialize/>
--- </map:match>
--- </pre>
---
--- <p>In this example pipeline it assumed that simple-xinc.xml contains the
include
--- element. As well as defining the include element, it defines the namespace
URI
--- "http://www.w3.org/2001/XInclude". This helps the XIncludeTransformer to
find
--- the include element to get replaced by the included content. The
simple-xinc.xml
--- may look like this:</p>
---
--- <pre><?xml version="1.0" encoding="UTF-8"?>
--- <page
--- xmlns:xi="http://www.w3.org/2001/XInclude">
--- <title>Hello</title>
--- <content>
--- <para>This is my first Cocoon page!</para>
--- <xi:include href="include.xml"/>
--- </content>
--- </page>
--- </pre>
---
--- <p>Next you should define the include.xml file which is included. A simple
--- include.xml might look like this:</p>
---
--- <pre><?xml version="1.0"?>
--- <p>
--- I am <strong>included</strong> by XIncludeTransformer.
--- I come from "include.xml".
--- </p>
--- </pre>
---
--- <p>Now finally we have everything put together the xml content after the
--- XIncludeTransformer processing will look like this:</p>
---
--- <pre><?xml version="1.0" encoding="UTF-8"?>
--- <page
--- xmlns:xi="http://www.w3.org/2001/XInclude">
--- <title>Hello</title>
--- <content>
--- <para>This is my first Cocoon page!</para>
--- <p>
--- I am <strong>included</strong> by XIncludeTransformer.
--- I come from "include.xml".
--- </p>
--- </content>
--- </page>
--- </pre>
---
</body>
</html>
Long description
----------------
This part has been added.
Mime type: text/xml
File name: null
Size: 3073 bytes
Content:
<html>
<body>
<p>This transformer works according to the XInclude specification.</p>
<p>For more information refer to the
<a href="http://www.w3.org/TR/xinclude">XInclude specification</a>.</p>
<ul>
<li>Name : xinclude</li>
<li>Class: org.apache.cocoon.transformation.XIncludeTransformer</li>
<li>Cacheable: yes.</li>
</ul>
<p>You can include either simple text, or xml content. Including xml content --
which is the default -- gives you the option to define an xpointer in the href
attribute. Some quick xinclude examples should reveal the possibilities of
xinclude.</p>
<ul>
<li>Include an xml content as-is: <tt><xi:include
href="include.xml"/></tt></li>
<li>Include an xml content but pick the strong element only: <tt><xi:include
href="include.xml#xpointer(/p/strong)"/></tt></li>
<li>Include text content: <tt><xi:include parse="text"
href="include.txt"/></tt></li>
</ul>
<p>A simple example using xinclude might help to use this transfomer
effectively:</p>
<p>Add the XIncludetransfomer to the components in your sitemap.xmap</p>
<pre>...
<map:components>
...
<map:transformers default="xslt">
...
<map:transformer name="xinclude"
src="org.apache.cocoon.transformation.XIncludeTransformer"/>
...
</pre>
<p>Next define in your pipeline to use the XIncludeTransformer</p>
<pre><map:match pattern="xinc/simple-xinc">
<map:generate src="xinc/simple-xinc.xml"/>
<map:transform type="xinclude"/>
<map:transform src="stylesheets/page/simple-page2html.xsl"/>
<map:serialize/>
</map:match>
</pre>
<p>In this example pipeline it assumed that simple-xinc.xml contains the include
element. As well as defining the include element, it defines the namespace URI
"http://www.w3.org/2001/XInclude". This helps the XIncludeTransformer to find
the include element to get replaced by the included content. The simple-xinc.xml
may look like this:</p>
<pre><?xml version="1.0" encoding="UTF-8"?>
<page
xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Hello</title>
<content>
<para>This is my first Cocoon page!</para>
<xi:include href="include.xml"/>
</content>
</page>
</pre>
<p>Next you should define the include.xml file which is included. A simple
include.xml might look like this:</p>
<pre><?xml version="1.0"?>
<p>
I am <strong>included</strong> by XIncludeTransformer.
I come from "include.xml".
</p>
</pre>
<p>Now finally we have everything put together the xml content after the
XIncludeTransformer processing will look like this:</p>
<pre><?xml version="1.0" encoding="UTF-8"?>
<page
xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Hello</title>
<content>
<para>This is my first Cocoon page!</para>
<p>
I am <strong>included</strong> by XIncludeTransformer.
I come from "include.xml".
</p>
</content>
</page>
</pre>
</body>
</html>