You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gr...@apache.org on 2001/01/23 20:41:06 UTC
cvs commit: xml-cocoon/xdocs xmlfragment.xml site-book.xml docs-book.xml faq.xml
greenrd 01/01/23 11:41:04
Modified: . changes.xml
xdocs site-book.xml docs-book.xml faq.xml
Added: xdocs xmlfragment.xml
Log:
documented xmlfragment
Revision Changes Path
1.196 +4 -1 xml-cocoon/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/changes.xml,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -r1.195 -r1.196
--- changes.xml 2001/01/23 19:21:26 1.195
+++ changes.xml 2001/01/23 19:40:41 1.196
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.195 2001/01/23 19:21:26 greenrd Exp $
+ $Id: changes.xml,v 1.196 2001/01/23 19:40:41 greenrd Exp $
-->
<changes title="History of Changes">
@@ -18,6 +18,9 @@
</devs>
<release version="@version@" date="@date@">
+ <action dev="RDG" type="add" due-to="Sylvain Wallez" due-to-email="sylvain.wallez@anyware-tech.com">
+ Added XMLFragment page to documentation.
+ </action>
<action dev="RDG" type="fix" due-to="Roberto Viana" due-to-email="rviana@agency.com">
Fixed JRun 3.0 installation instructions.
</action>
1.26 +1 -0 xml-cocoon/xdocs/site-book.xml
Index: site-book.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/xdocs/site-book.xml,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- site-book.xml 2001/01/10 23:24:02 1.25
+++ site-book.xml 2001/01/23 19:40:50 1.26
@@ -24,6 +24,7 @@
<separator/>
<page id="xsp" label="XSP Processor" source="xspprocessor.xml"/>
<spec id="wd-xsp" label="XSP WD" source="WD-xsp.xml"/>
+ <page id="xmlfragment" label="XMLFragments" source="xmlfragment.xml"/>
<page id="esql" label="ESQL Taglib" source="esql.xml"/>
<page id="connection-pool" label="SQL Conn Pool" source="connection-pool.xml"/>
<page id="fp" label="FP Taglib" source="fptaglib.xml"/>
1.25 +1 -0 xml-cocoon/xdocs/docs-book.xml
Index: docs-book.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/xdocs/docs-book.xml,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- docs-book.xml 2001/01/10 23:24:02 1.24
+++ docs-book.xml 2001/01/23 19:40:52 1.25
@@ -20,6 +20,7 @@
<separator/>
<page id="xsp" label="XSP Processor" source="xspprocessor.xml"/>
<spec id="wd-xsp" label="XSP WD" source="WD-xsp.xml"/>
+ <page id="xmlfragment" label="XMLFragments" source="xmlfragment.xml"/>
<page id="esql" label="ESQL Taglib" source="esql.xml"/>
<page id="connection-pool" label="SQL Conn Pool" source="connection-pool.xml"/>
<page id="fp" label="FP Taglib" source="fptaglib.xml"/>
1.47 +2 -1 xml-cocoon/xdocs/faq.xml
Index: faq.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/xdocs/faq.xml,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- faq.xml 2001/01/19 16:13:56 1.46
+++ faq.xml 2001/01/23 19:40:54 1.47
@@ -249,7 +249,8 @@
of this documentation (except insofar as it documents the specification of
<code><xsp:expr></code>) - see the DOM link above, and also the question on
<jump anchor="faq-goodbooks">"good books"</jump>. You can also generate
- <code>org.apache.cocoon.xml.XMLFragment</code>s, and return both DOM and SAX,
+ <connect href="xmlfragment.xml">
+ <code>org.apache.cocoon.xml.XMLFragment</code>s</connect>, and return both DOM and SAX,
thus making your code (hopefully) more forward-compatible with Cocoon 2, which will be
SAX-based. (Actually using SAX is not strictly necessary, since DOM can always be
converted to SAX and vice-versa, but you will pay a performance penalty in Cocoon 2
1.1 xml-cocoon/xdocs/xmlfragment.xml
Index: xmlfragment.xml
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE document SYSTEM "./dtd/document-v10.dtd">
<document><header><title>ESQL Taglib</title>
<authors>
<person name="Sylvain Wallez" email="sylvain.wallez@anyware-tech.com"/>
<person name="Robin Green" email="greenrd@hotmail.com"/>
</authors></header><body>
<s1 title="Implementing the org.apache.cocoon.xml.XMLFragment interface">
<p>An <code>XMLFragment</code> is an object that can be represented as a XML document
fragment. The main purpose of this standard interface is to provide a
uniform way of inserting dynamically-generated XML into XSP pages. See
the <link href="faqs.html#faq-xspinsertxml">relevant FAQ</link> for more
details and alternatives.</p>
<p>As described in the Javadoc documentation, the <code>toDOM()</code> method (used by Cocoon
1) should append the XML
representation of the object as children of the given node, and the
<code>toSAX()</code> method (used by Cocoon 2) should generate the XML representation as
SAX events.</p>
<p>A typical XMLFragment implementation might look like this:</p>
<source>
public class FragmentTest implements XMLFragment
{
public void toDOM(Node node)
{
Document doc = node.getOwnerDocument();
Element e = doc.createElement("foo");
e.appendChild(doc.createTextNode("bar"));
node.appendChild(e);
}
public void toSAX(ContentHandler handler)
{
AttributesImpl attr = new AttributesImpl();
handler.startElement("","foo","foo",attr);
String content = "bar";
handler.characters(content.toCharArray(), 0, content.length());
handler.endElement("","foo","foo");
}
}
</source>
<p>Both methods result in <code><foo>bar</foo></code> being inserted in the resulting
document.</p>
<p>Of course, it is very wasteful to write two methods to do exactly the same thing!
That is why we suggest people implement only toSAX directly, and then form a DOM tree from the SAX
events in the toDOM method. An XMLFragmentBase
class is in development to simplify this.</p>
</s1>
</body></document>