bdelacretaz 2003/08/06 05:59:13
Modified: . gump.xml
Added: src/blocks/slop/conf slop-generator.xmap slop.xsamples
src/blocks/slop/java/org/apache/cocoon/slop/generation
SlopGenerator.java
src/blocks/slop/java/org/apache/cocoon/slop/interfaces
SlopConstants.java SlopParser.java
src/blocks/slop/java/org/apache/cocoon/slop/parsing
SimpleSlopParser.java
src/blocks/slop/lib .cvsignore
src/blocks/slop/samples email-example.txt sitemap.xmap
special-chars.txt tc-example.txt welcome.xml
Log:
slop block added (SlopGenerator + samples)
Revision Changes Path
1.73 +20 -1 cocoon-2.1/gump.xml
Index: gump.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/gump.xml,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- gump.xml 4 Aug 2003 08:39:41 -0000 1.72
+++ gump.xml 6 Aug 2003 12:59:13 -0000 1.73
@@ -960,6 +960,25 @@
<nag from="Gump" to="[EMAIL PROTECTED]"/>
</project>
+ <project name="cocoon-block-slop" status="unstable">
+ <package>org.apache.cocoon</package>
+
+ <ant target="gump-block">
+ <property name="block-name" value="slop"/>
+ <property name="version" value="@@DATE@@"/>
+ </ant>
+
+ <depend project="cocoon" inherit="all"/>
+
+ <work nested="tools/anttasks"/>
+ <home nested="build/cocoon-@@DATE@@"/>
+
+ <jar name="blocks/slop-block.jar"/>
+
+ <nag from="Gump" to="[EMAIL PROTECTED]"/>
+ </project>
+
+
<!--
********************************************
******** COCOON SUPPLIED PROJECTS ********
1.1 cocoon-2.1/src/blocks/slop/conf/slop-generator.xmap
Index: slop-generator.xmap
===================================================================
<?xml version="1.0"?>
<xmap xpath="/sitemap/components/generators" unless="[EMAIL PROTECTED]'slop']">
<map:generator
name="slop"
logger="sitemap.generator.slop"
src="org.apache.cocoon.slop.generation.SlopGenerator"
/>
</xmap>
1.1 cocoon-2.1/src/blocks/slop/conf/slop.xsamples
Index: slop.xsamples
===================================================================
<?xml version="1.0"?>
<xsamples xpath="/samples" unless="[EMAIL PROTECTED]'Slop']">
<group name="Slop">
<sample name="Slop Text Parser" href="slop/">
Examples showing how to use SLOP
(the Simple Line Oriented Parser)
to parse text files
</sample>
</group>
</xsamples>
1.1
cocoon-2.1/src/blocks/slop/java/org/apache/cocoon/slop/generation/SlopGenerator.java
Index: SlopGenerator.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.slop.generation;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.slop.parsing.SimpleSlopParser;
import org.apache.cocoon.slop.interfaces.SlopParser;
import org.apache.cocoon.generation.ComposerGenerator;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceValidity;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.LocatorImpl;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Serializable;
import java.util.Map;
/**
* SlopGenerator: Simple Line-Oriented Parsing of text files.
* General code structure lifted from the Chaperon TextGenerator - thanks Stephan!
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bertrand Delacretaz</a>
* @version CVS $Id: SlopGenerator.java,v 1.1 2003/08/06 12:59:13 bdelacretaz Exp $
*/
public class SlopGenerator extends ComposerGenerator
implements CacheableProcessingComponent {
private Source inputSource = null;
private String encoding = null;
private SlopParser parser = null;
/**
* Recycle this component.
* All instance variables are set to <code>null</code>.
*/
public void recycle() {
if (inputSource != null) {
super.resolver.release(inputSource);
}
inputSource = null;
encoding = null;
parser = null;
super.recycle();
}
/**
* Set the SourceResolver, objectModel Map, the source and sitemap
* Parameters used to process the request.
*
* @param resolver Source resolver
* @param objectmodel Object model
* @param src Source
* @param parameters Parameters
*
* @throws java.io.IOException
* @throws org.apache.cocoon.ProcessingException
* @throws org.xml.sax.SAXException
*/
public void setup(SourceResolver resolver, Map objectmodel, String src,
Parameters parameters)
throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectmodel, src, parameters);
try {
encoding = parameters.getParameter("encoding", null);
inputSource = resolver.resolveURI(src);
parser = new SimpleSlopParser();
} catch (SourceException se) {
throw new ProcessingException("Error during resolving of '" + src +
"'.", se);
}
}
/**
* Generate the unique key.
* This key must be unique inside the space of this component.
*
* @return The generated key hashes the src
*/
public Serializable getKey() {
return inputSource.getURI();
}
/**
* Generate the validity object.
*
* @return The generated validity object or <code>null</code> if the
* component is currently not cacheable.
*/
public SourceValidity getValidity() {
return this.inputSource.getValidity();
}
/**
* Generate XML data.
*
* @throws java.io.IOException
* @throws org.apache.cocoon.ProcessingException
* @throws org.xml.sax.SAXException
*/
public void generate()
throws IOException, SAXException, ProcessingException {
// access input data, using specified encoding if any
InputStreamReader in = null;
try {
if (this.inputSource.getInputStream() == null) {
throw new ProcessingException("Source '" + this.inputSource.getURI()
+ "' not found");
}
if (encoding != null) {
in = new InputStreamReader(this.inputSource.getInputStream(),
encoding);
} else {
in = new InputStreamReader(this.inputSource.getInputStream());
}
} catch (SourceException se) {
throw new ProcessingException("Error during resolving of '" +
this.source + "'.", se);
}
// setup a Locator in case parser detects input errors
final LocatorImpl locator = new LocatorImpl();
locator.setSystemId(this.inputSource.getURI());
locator.setLineNumber(1);
locator.setColumnNumber(1);
contentHandler.setDocumentLocator(locator);
// start parsing, read and process all input lines
parser.startDocument(contentHandler);
LineNumberReader reader = new LineNumberReader(in);
String line, newline = null;
while (true) {
if (newline == null) {
line = reader.readLine();
} else {
line = newline;
}
if (line == null) {
break;
}
newline = reader.readLine();
locator.setLineNumber(reader.getLineNumber());
locator.setColumnNumber(1);
parser.processLine(line);
if (newline == null) {
break;
}
}
// done parsing
parser.endDocument();
}
}
1.1
cocoon-2.1/src/blocks/slop/java/org/apache/cocoon/slop/interfaces/SlopConstants.java
Index: SlopConstants.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.slop.interfaces;
/** General constants for the SLOP block
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bertrand Delacretaz</a>
* @version CVS $Id: SlopConstants.java,v 1.1 2003/08/06 12:59:13 bdelacretaz Exp $
*/
public interface SlopConstants {
String SLOP_NAMESPACE_URI = "http://apache.org/cocoon/slop/parser/1.0";
// element names
String SLOP_ROOT_ELEMENT = "parsed-text";
String SLOP_LINE_ELEMENT = "line";
String SLOP_EMPTY_LINE_ELEMENT = "empty-line";
}
1.1
cocoon-2.1/src/blocks/slop/java/org/apache/cocoon/slop/interfaces/SlopParser.java
Index: SlopParser.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.slop.interfaces;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.apache.cocoon.ProcessingException;
/** Interface to SLOP parsers
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bertrand Delacretaz</a>
* @version CVS $Id: SlopParser.java,v 1.1 2003/08/06 12:59:13 bdelacretaz Exp $
*/
public interface SlopParser {
/** must be called before any call to processLine() */
public void startDocument(ContentHandler destination)
throws SAXException, ProcessingException;
/** must be called once all calls to processLine() are done */
public void endDocument()
throws SAXException, ProcessingException;
/** call this to process input lines, does the actual parsing */
public void processLine(String line)
throws SAXException, ProcessingException;
}
1.1
cocoon-2.1/src/blocks/slop/java/org/apache/cocoon/slop/parsing/SimpleSlopParser.java
Index: SimpleSlopParser.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.slop.parsing;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.slop.interfaces.SlopParser;
import org.apache.cocoon.slop.interfaces.SlopConstants;
/** Simplistic SLOP parser, recognizes the following constructs:
*
* Field: a line starting with letters and : is considered a field
*
* Empty lines are detected.
* Other lines are output as line elements
*
* This is sufficient for basic parsing of RFC 822 headers,
* but a configurable rfc822 mode would be good to differentiate
* between the header and body of the email message and parse them
* with different rules.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bertrand Delacretaz</a>
* @version CVS $Id: SimpleSlopParser.java,v 1.1 2003/08/06 12:59:13 bdelacretaz Exp
$
*/
public class SimpleSlopParser implements SlopParser,SlopConstants {
private ContentHandler contentHandler;
/** chars that can be part of a field name (other than letters) */
private final static String FIELD_CHARS = "-_";
/** result of parsing a line */
static class ParsedLine {
final String name;
final String contents;
ParsedLine(String elementName, String elementContents) {
name = elementName;
contents = elementContents;
}
}
/** must be called before any call to processLine() */
public void startDocument(ContentHandler destination)
throws SAXException, ProcessingException {
contentHandler = destination;
contentHandler.startDocument();
contentHandler.startPrefixMapping("", SLOP_NAMESPACE_URI);
final AttributesImpl atts = new AttributesImpl();
contentHandler.startElement(SLOP_NAMESPACE_URI, SLOP_ROOT_ELEMENT,
SLOP_ROOT_ELEMENT, atts);
}
/** must be called once all calls to processLine() are done */
public void endDocument()
throws SAXException, ProcessingException {
contentHandler.endElement(SLOP_NAMESPACE_URI, SLOP_ROOT_ELEMENT,
SLOP_ROOT_ELEMENT);
contentHandler.endPrefixMapping("");
contentHandler.endDocument();
contentHandler = null;
}
/** call this to process input lines, does the actual parsing */
public void processLine(String line)
throws SAXException, ProcessingException {
if(contentHandler == null) {
throw new ProcessingException("SimpleSlopParser content handler is null
(startDocument not called?)");
}
// find out which element name to use, based on the contents of the line
final ParsedLine p = parseLine(line);
// generate the element and its contents
final AttributesImpl atts = new AttributesImpl();
contentHandler.startElement(SLOP_NAMESPACE_URI, p.name, p.name, atts);
contentHandler.characters(p.contents.toCharArray(),0,p.contents.length());
contentHandler.endElement(SLOP_NAMESPACE_URI, p.name, p.name);
}
/** parse a line, extract element name and contents */
protected ParsedLine parseLine(String line) {
ParsedLine result = null;
// empty lines
if(line == null || line.trim().length()==0) {
result = new ParsedLine(SLOP_EMPTY_LINE_ELEMENT,"");
}
// simple extraction of field names, lines starting with alpha chars followed
// by a colon are parsed as follows:
//
// input:
// field-name: this line is a field
// output:
// <field-name>this line is a field</field-name>
if(result == null) {
final int colonPos = line.indexOf(':');
if(colonPos > 0) {
boolean fieldFound = true;
for(int i=0; i < colonPos; i++) {
final char c = line.charAt(i);
final boolean isFieldChar = Character.isLetter(c) ||
FIELD_CHARS.indexOf(c) >= 0;
if(!isFieldChar) {
fieldFound = false;
break;
}
}
if(fieldFound) {
String contents = "";
if(line.length() > colonPos + 1) {
contents = line.substring(colonPos+1).trim();
}
result = new ParsedLine(line.substring(0,colonPos),contents);
}
}
}
// default: output a line element
if(result == null) {
result = new ParsedLine(SLOP_LINE_ELEMENT,line.trim());
}
return result;
}
}
1.1 cocoon-2.1/src/blocks/slop/lib/.cvsignore
<<Binary file>>
1.1 cocoon-2.1/src/blocks/slop/samples/email-example.txt
Index: email-example.txt
===================================================================
From [EMAIL PROTECTED] Wed Aug 6 14:11:14 2003
Return-Path: <[EMAIL PROTECTED]>
Received: (from [EMAIL PROTECTED])
by confixx.bestiole.ch (8.11.6/8.11.6) id h76CB1o01988
for bdmail; Wed, 6 Aug 2003 14:11:01 +0200
Received: from minotaur.apache.org ([209.237.227.194])
by confixx.bestiole.ch (8.11.6/8.11.6) with SMTP id h76CAwu01796
for <[EMAIL PROTECTED]>; Wed, 6 Aug 2003 14:10:58 +0200
Received: (qmail 87793 invoked by uid 1401); 6 Aug 2003 12:11:00 -0000
Date: 6 Aug 2003 12:11:00 -0000
Message-ID: <[EMAIL PROTECTED]>
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: SlopGenerator test
X-Spam-Status: No, hits=0.8 required=5.0
tests=NO_REAL_NAME
version=2.55
X-Spam-Level:
X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)
Hello SlopGenerator!
This is a test sent from cvs.apache.org, let's see how
you can handle this.
1.1 cocoon-2.1/src/blocks/slop/samples/sitemap.xmap
Index: sitemap.xmap
===================================================================
<?xml version="1.0"?>
<!-- sitemap for slop block samples -->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:pipelines>
<map:pipeline type="caching">
<map:match pattern="">
<map:redirect-to uri="welcome"/>
</map:match>
<map:match pattern="welcome">
<map:generate src="welcome.xml"/>
<map:transform
src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
<map:parameter name="contextPath" value="{request:contextPath}"/>
</map:transform>
<map:serialize/>
</map:match>
<!--
use the same pipeline for rfc822 and tc for now, they can later
be separated to use different configurations of the SlopParser
-->
<map:match pattern="*/*.xml">
<map:generate type="slop" src="{2}.txt">
<map:parameter name="encoding" value="iso-8859-1"/>
</map:generate>
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
1.1 cocoon-2.1/src/blocks/slop/samples/special-chars.txt
Index: special-chars.txt
===================================================================
title: Test SlopGenerator with special characters
Of course, the SlopParser must escape special chars properly, as in
<element-names> or equations: x < y & y < z implies x < z.
And, provided the encoding is set correctly, accented chars
must be processed cleanly:
french-test: Les �l�ments d�cha�n�s se sont r�v�l�s.
german-test: �mterkonsultation wird �bergeben.
1.1 cocoon-2.1/src/blocks/slop/samples/tc-example.txt
Index: tc-example.txt
===================================================================
title: Interactive test example
description: Use the Cocoon SlopParser to format descriptions of interactive tests
written as structured ASCII files
prerequisite: test-421
prerequisite: test-426
test-steps:
IN: Click JXClient icon to start the program
IN: Enter username "test" in login window
IN: Enter password "test" in login window
IN: Click "login" button
OUT: JXClient starts in less than 4 seconds
IMG: jx-client-screenshot
IN: Close JXclient, restart using icon
IN: Enter username "wrong" in login window
IN: Enter password "bad" in login window
OUT: Login dialog displays "user not authorized"
1.1 cocoon-2.1/src/blocks/slop/samples/welcome.xml
Index: welcome.xml
===================================================================
<?xml version="1.0" encoding="iso-8859-1"?>
<samples xmlns:xlink="http://www.w3.org/1999/xlink">
<group name="Main examples page.">
<sample name="Back" href="..">to Cocoon examples main page</sample>
<note>
As of August 6, 2003 the SlopGenerator (Simple Line Oriented Parser)
is functional but somewhat limited.
RFC822 parsing does not properly take continuation lines
(like "by..." after Received-From) into account, and a specific
rfc822 mode should be implemented to avoid parsing the message body.
On the other hand, the code is very simple and thus should be quite fast.
</note>
</group>
<group name="Email parsing using SLOP">
<sample name="email-example.xml" href="rfc822/email-example.xml">
XML result of parsing an RFC 822 message
</sample>
</group>
<group name="Test catalog example">
<sample name="tc-example.xml" href="tc/tc-example.xml">
Example using Slop to describe interactive tests easily using ASCII files
</sample>
</group>
<group name="Special characters">
<sample name="special.chars.xml" href="test/special-chars.xml">
Test Slop with special and accented characters
</sample>
</group>
</samples>