<?xml version="1.0" encoding="ISO-8859-1"?><parsed-text xmlns="http://apache.org/cocoon/slop/parser/1.0"><line line-number="1">/*</line><line line-number="2">* Copyright 1999-2004 The Apache Software Foundation</line><line line-number="3">*</line><line line-number="4">* Licensed under the Apache License, Version 2.0 (the "License");</line><line line-number="5">* you may not use this file except in compliance with the License.</line><line line-number="6">* You may obtain a copy of the License at</line><line line-number="7">*</line><line line-number="8">*     http://www.apache.org/licenses/LICENSE-2.0</line><line line-number="9">*</line><line line-number="10">* Unless required by applicable law or agreed to in writing, software</line><line line-number="11">* distributed under the License is distributed on an "AS IS" BASIS,</line><line line-number="12">* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</line><line line-number="13">* See the License for the specific language governing permissions and</line><line line-number="14">* limitations under the License.</line><line line-number="15">*/</line><line line-number="16">// (currently lpstart comments at the very start do not work)</line><line line-number="17">package org.nothing;</line><empty-line line-number="18"/><__lpstart line-number="19"/><line line-number="20">//  &lt;h1&gt;What's this?&lt;/h1&gt;</line><line line-number="21">//  Based on the Slop parser, Javateach creates a nice HTML page from the source code of a Java class.</line><line line-number="22">//  The idea is to write explanations of the code inline, allowing explanations and code to stay together,</line><line line-number="23">//  and keeping line numbers accurate.</line><line line-number="24">//</line><line line-number="25">//  &lt;h1&gt;Teaching comments&lt;/h1&gt;</line><line line-number="26">//  Comments like this one, surrounded by lpstart/lpend will be extracted from the source</line><line line-number="27">//  code to create an HTML presentation which mixes teaching comments and code.</line><__lpend line-number="28"/><empty-line line-number="29"/><line line-number="30">import org.xml.sax.ContentHandler;</line><line line-number="31">import org.xml.sax.SAXException;</line><empty-line line-number="32"/><__lpstart line-number="33"/><line line-number="34">//  Here we could explain what class comments are about.</line><__lpend line-number="35"/><empty-line line-number="36"/><line line-number="37">/** Simple example of java code parsing with Slop.</line><line line-number="38"> *  The aim is to create a minimal "literate programming" system for teaching,</line><line line-number="39"> *  where java code is decorated with narrative comments. */</line><empty-line line-number="40"/><__lpstart line-number="41"/><line line-number="42">//  &lt;h2&gt;Here's the class declaration&lt;/h2&gt;</line><line line-number="43">//  This class does nothing useful, it does not even compile, it is only used to</line><line line-number="44">//  test the javateach formatting.</line><line line-number="45">//  &lt;br/&gt;</line><line line-number="46">//  Code indentation is preserved, this is set by SlopGenerator parameters</line><line line-number="47">//  in the sitemap.</line><__lpend line-number="48"/><empty-line line-number="49"/><line line-number="50">public class SomeTest implements SlopParser,SlopConstants {</line><line line-number="51">    private ContentHandler contentHandler;</line><empty-line line-number="52"/><line line-number="53">    /** chars that can be part of a field name (other than letters) */</line><line line-number="54">    private final static String DEFAULT_TAGNAME_CHARS = "-_";</line><line line-number="55">    private String tagnameChars = DEFAULT_TAGNAME_CHARS;</line><empty-line line-number="56"/><__lpstart line-number="57"/><line line-number="58">// lp markers have to start in column 1.</line><line line-number="59">// &lt;br/&gt;</line><line line-number="60">// HTML constructs are &lt;b&gt;allowed&lt;/b&gt; in lp comments:</line><line line-number="61">// &lt;ul&gt;</line><line line-number="62">// &lt;li&gt;You like bullet points, I'm sure...&lt;/li&gt;</line><line line-number="63">// &lt;li&gt;Here's the second one&lt;/li&gt;</line><line line-number="64">// &lt;/ul&gt;</line><line line-number="65">// Links also work, like &lt;a href="http://www.perdu.com" target="_new"&gt;this&lt;/a&gt;.</line><__lpend line-number="66"/><empty-line line-number="67"/><line line-number="68">    /** optionally preserve whitespace in input */</line><line line-number="69">    private boolean preserveSpace = false;</line><empty-line line-number="70"/><line line-number="71">    /** result of parsing a line */</line><line line-number="72">    static class ParsedLine {</line><line line-number="73">        final String name;</line><line line-number="74">        final String contents;</line><empty-line line-number="75"/><line line-number="76">        ParsedLine(String elementName, String elementContents) {</line><line line-number="77">            name = elementName;</line><line line-number="78">            contents = elementContents;</line><line line-number="79">        }</line><line line-number="80">    }</line><empty-line line-number="81"/><__lpstart line-number="82"/><line line-number="83">//    SetValidTagname() is used to define a list of valid character for XML element</line><line line-number="84">//    names.</line><__lpend line-number="85"/><empty-line line-number="86"/><line line-number="87">    /** set the list of valid chars for tag names (in addition to letters) */</line><line line-number="88">    public void setValidTagnameChars(String str) {</line><line line-number="89">        tagnameChars = str;</line><line line-number="90">    }</line><empty-line line-number="91"/><line line-number="92">}</line></parsed-text>