You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by jv...@apache.org on 2007/03/17 15:48:18 UTC

svn commit: r519332 - in /maven/doxia/trunk/doxia-modules/doxia-module-xdoc: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/doxia/ src/main/java/org/apache/ma...

Author: jvanzyl
Date: Sat Mar 17 07:48:17 2007
New Revision: 519332

URL: http://svn.apache.org/viewvc?view=rev&rev=519332
Log:
o separate xdoc module

Added:
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/pom.xml   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSiteModule.java   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java   (with props)
    maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java   (with props)

Added: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-modules/doxia-module-xdoc/pom.xml?view=auto&rev=519332
==============================================================================
--- maven/doxia/trunk/doxia-modules/doxia-module-xdoc/pom.xml (added)
+++ maven/doxia/trunk/doxia-modules/doxia-module-xdoc/pom.xml Sat Mar 17 07:48:17 2007
@@ -0,0 +1,21 @@
+<?xml version="1.0"?><project>
+  <parent>
+    <artifactId>doxia-modules</artifactId>
+    <groupId>org.apache.maven.doxia</groupId>
+    <version>1.0-alpha-9-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.doxia</groupId>
+  <artifactId>doxia-module-xdoc</artifactId>
+  <name>doxia-module-xdoc</name>
+  <version>1.0-SNAPSHOT</version>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java?view=auto&rev=519332
==============================================================================
--- maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java (added)
+++ maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java Sat Mar 17 07:48:17 2007
@@ -0,0 +1,366 @@
+package org.apache.maven.doxia.module.xdoc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.doxia.macro.MacroRequest;
+import org.apache.maven.doxia.parser.AbstractParser;
+import org.apache.maven.doxia.parser.ParseException;
+import org.apache.maven.doxia.sink.Sink;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.pull.MXParser;
+import org.codehaus.plexus.util.xml.pull.XmlPullParser;
+
+/**
+ * Parse an xdoc model and emit events into the specified doxia
+ * Sink.
+ *
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id:XdocParser.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005) brett $
+ * @plexus.component role="org.apache.maven.doxia.parser.Parser"
+ * role-hint="xdoc"
+ */
+public class XdocParser
+    extends AbstractParser
+{
+    private String sourceContent;
+
+    public void parse( Reader reader, Sink sink )
+        throws ParseException
+    {
+        try
+        {
+            StringWriter contentWriter = new StringWriter();
+            IOUtil.copy( reader, contentWriter );
+            sourceContent = contentWriter.toString();
+
+            XmlPullParser parser = new MXParser();
+
+            parser.setInput( new StringReader( sourceContent ) );
+
+            parseXdoc( parser, sink );
+        }
+        catch ( Exception ex )
+        {
+            throw new ParseException( "Error parsing the model.", ex );
+        }
+    }
+
+    public void parseXdoc( XmlPullParser parser, Sink sink )
+        throws Exception
+    {
+        int eventType = parser.getEventType();
+
+        while ( eventType != XmlPullParser.END_DOCUMENT )
+        {
+            if ( eventType == XmlPullParser.START_TAG )
+            {
+                if ( parser.getName().equals( "document" ) )
+                {
+                    //Do nothing
+                }
+                else if ( parser.getName().equals( "title" ) )
+                {
+                    sink.title();
+                }
+                else if ( parser.getName().equals( "author" ) )
+                {
+                    sink.author();
+                }
+                else if ( parser.getName().equals( "body" ) )
+                {
+                    sink.body();
+                }
+                else if ( parser.getName().equals( "section" ) )
+                {
+                    sink.anchor( parser.getAttributeValue( null, "name" ) );
+                    sink.anchor_();
+
+                    sink.section1();
+
+                    sink.sectionTitle1();
+
+                    sink.text( parser.getAttributeValue( null, "name" ) );
+
+                    sink.sectionTitle1_();
+                }
+                else if ( parser.getName().equals( "subsection" ) )
+                {
+                    sink.anchor( parser.getAttributeValue( null, "name" ) );
+                    sink.anchor_();
+
+                    sink.section2();
+
+                    sink.sectionTitle2();
+
+                    sink.text( parser.getAttributeValue( null, "name" ) );
+
+                    sink.sectionTitle2_();
+                }
+                else if ( parser.getName().equals( "p" ) )
+                {
+                    sink.paragraph();
+                }
+                else if ( parser.getName().equals( "source" ) )
+                {
+                    sink.verbatim( true );
+                }
+                else if ( parser.getName().equals( "ul" ) )
+                {
+                    sink.list();
+                }
+                else if ( parser.getName().equals( "ol" ) )
+                {
+                    sink.numberedList( Sink.NUMBERING_DECIMAL );
+                }
+                else if ( parser.getName().equals( "li" ) )
+                {
+                    sink.listItem();
+                }
+                else if ( parser.getName().equals( "properties" ) )
+                {
+                    sink.head();
+                }
+                else if ( parser.getName().equals( "b" ) )
+                {
+                    sink.bold();
+                }
+                else if ( parser.getName().equals( "i" ) )
+                {
+                    sink.italic();
+                }
+                else if ( parser.getName().equals( "a" ) )
+                {
+                    String href = parser.getAttributeValue( null, "href" );
+                    if ( href != null )
+                    {
+                        sink.link( href );
+                    }
+                    else
+                    {
+                        String name = parser.getAttributeValue( null, "name" );
+                        if ( name != null )
+                        {
+                            sink.anchor( name );
+                        }
+                        else
+                        {
+                            handleRawText( sink, parser );
+                        }
+                    }
+                }
+                else if ( parser.getName().equals( "macro" ) )
+                {
+                    if ( !secondParsing )
+                    {
+                        String macroName = parser.getAttributeValue( null, "name" );
+
+                        int count = parser.getAttributeCount();
+
+                        Map parameters = new HashMap();
+
+                        for ( int i = 1; i < count; i++ )
+                        {
+                            parameters.put( parser.getAttributeName( i ), parser.getAttributeValue( i ) );
+                        }
+
+                        parameters.put( "sourceContent", sourceContent );
+
+                        XdocParser xdocParser = new XdocParser();
+                        xdocParser.setSecondParsing( true );
+                        parameters.put( "parser", xdocParser );
+
+                        MacroRequest request = new MacroRequest( parameters, getBasedir() );
+
+                        executeMacro( macroName, request, sink );
+                    }
+                }
+
+                // ----------------------------------------------------------------------
+                // Tables
+                // ----------------------------------------------------------------------
+
+                else if ( parser.getName().equals( "table" ) )
+                {
+                    sink.table();
+                }
+                else if ( parser.getName().equals( "tr" ) )
+                {
+                    sink.tableRow();
+                }
+                else if ( parser.getName().equals( "th" ) )
+                {
+                    sink.tableHeaderCell();
+                }
+                else if ( parser.getName().equals( "td" ) )
+                {
+                    sink.tableCell();
+                }
+                else
+                {
+                    handleRawText( sink, parser );
+                }
+            }
+            else if ( eventType == XmlPullParser.END_TAG )
+            {
+                if ( parser.getName().equals( "document" ) )
+                {
+                    //Do nothing
+                }
+                else if ( parser.getName().equals( "title" ) )
+                {
+                    sink.title_();
+                }
+                else if ( parser.getName().equals( "author" ) )
+                {
+                    sink.author_();
+                }
+                else if ( parser.getName().equals( "body" ) )
+                {
+                    sink.body_();
+                }
+                else if ( parser.getName().equals( "p" ) )
+                {
+                    sink.paragraph_();
+                }
+                else if ( parser.getName().equals( "source" ) )
+                {
+                    sink.verbatim_();
+                }
+                else if ( parser.getName().equals( "ul" ) )
+                {
+                    sink.list_();
+                }
+                else if ( parser.getName().equals( "ol" ) )
+                {
+                    sink.numberedList_();
+                }
+                else if ( parser.getName().equals( "li" ) )
+                {
+                    sink.listItem_();
+                }
+                else if ( parser.getName().equals( "properties" ) )
+                {
+                    sink.head_();
+                }
+                else if ( parser.getName().equals( "b" ) )
+                {
+                    sink.bold_();
+                }
+                else if ( parser.getName().equals( "i" ) )
+                {
+                    sink.italic_();
+                }
+                else if ( parser.getName().equals( "a" ) )
+                {
+                    // TODO: Note there will be badness if link_ != anchor != </a>
+                    sink.link_();
+                }
+                else if ( parser.getName().equals( "macro" ) )
+                {
+                    //Do nothing
+                }
+
+                // ----------------------------------------------------------------------
+                // Tables
+                // ----------------------------------------------------------------------
+
+                else if ( parser.getName().equals( "table" ) )
+                {
+                    sink.table_();
+                }
+                else if ( parser.getName().equals( "tr" ) )
+                {
+                    sink.tableRow_();
+                }
+                else if ( parser.getName().equals( "th" ) )
+                {
+                    sink.tableHeaderCell_();
+                }
+                else if ( parser.getName().equals( "td" ) )
+                {
+                    sink.tableCell_();
+                }
+
+                // ----------------------------------------------------------------------
+                // Sections
+                // ----------------------------------------------------------------------
+
+                else if ( parser.getName().equals( "section" ) )
+                {
+                    sink.section1_();
+                }
+                else if ( parser.getName().equals( "subsection" ) )
+                {
+                    sink.section2_();
+                }
+                else
+                {
+                    sink.rawText( "</" );
+
+                    sink.rawText( parser.getName() );
+
+                    sink.rawText( ">" );
+                }
+
+                // ----------------------------------------------------------------------
+                // Sections
+                // ----------------------------------------------------------------------
+            }
+            else if ( eventType == XmlPullParser.TEXT )
+            {
+                sink.text( parser.getText() );
+            }
+
+            eventType = parser.next();
+        }
+    }
+
+    private void handleRawText( Sink sink, XmlPullParser parser )
+    {
+        sink.rawText( "<" );
+
+        sink.rawText( parser.getName() );
+
+        int count = parser.getAttributeCount();
+
+        for ( int i = 0; i < count; i++ )
+        {
+            sink.rawText( " " );
+
+            sink.rawText( parser.getAttributeName( i ) );
+
+            sink.rawText( "=" );
+
+            sink.rawText( "\"" );
+
+            sink.rawText( parser.getAttributeValue( i ) );
+
+            sink.rawText( "\"" );
+        }
+
+        sink.rawText( ">" );
+    }
+}

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java?view=auto&rev=519332
==============================================================================
--- maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java (added)
+++ maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java Sat Mar 17 07:48:17 2007
@@ -0,0 +1,707 @@
+package org.apache.maven.doxia.module.xdoc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Writer;
+
+import org.apache.maven.doxia.module.HtmlTools;
+import org.apache.maven.doxia.module.apt.AptParser;
+import org.apache.maven.doxia.sink.SinkAdapter;
+import org.apache.maven.doxia.util.LineBreaker;
+
+/**
+ * A doxia Sink which produces an xdoc model.
+ *
+ * @author <a href="mailto:james@jamestaylor.org">James Taylor</a>
+ * @version $Id:XdocSink.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005) brett $
+ */
+public class XdocSink
+    extends SinkAdapter
+{
+    protected static final String EOL = System.getProperty( "line.separator" );
+
+    protected LineBreaker out;
+
+    protected StringBuffer buffer = new StringBuffer();
+
+    protected boolean headFlag;
+
+    /**
+     * An indication on if we're inside a title.
+     *
+     * This will prevent the styling of titles.
+     */
+    protected boolean titleFlag;
+
+    private boolean itemFlag;
+
+    private boolean boxedFlag;
+
+    private boolean verbatimFlag;
+
+    private int[] cellJustif;
+
+    private int cellCount;
+
+    private String section;
+
+    public XdocSink( Writer out )
+    {
+        this.out = new LineBreaker( out );
+    }
+
+    protected void resetState()
+    {
+        headFlag = false;
+        buffer = new StringBuffer();
+        itemFlag = false;
+        boxedFlag = false;
+        verbatimFlag = false;
+        cellJustif = null;
+        cellCount = 0;
+    }
+
+    public void head()
+    {
+        resetState();
+
+        headFlag = true;
+
+        markup( "<?xml version=\"1.0\" ?>" + EOL );
+
+        markup( "<document>" + EOL );
+
+        markup( "<properties>" + EOL );
+    }
+
+    public void head_()
+    {
+        headFlag = false;
+
+        markup( "</properties>" + EOL );
+    }
+
+    public void title_()
+    {
+        if ( buffer.length() > 0 )
+        {
+            markup( "<title>" );
+            content( buffer.toString() );
+            markup( "</title>" + EOL );
+            buffer = new StringBuffer();
+        }
+    }
+
+    public void author_()
+    {
+        if ( buffer.length() > 0 )
+        {
+            markup( "<author>" );
+            content( buffer.toString() );
+            markup( "</author>" + EOL );
+            buffer = new StringBuffer();
+        }
+    }
+
+    public void date_()
+    {
+        if ( buffer.length() > 0 )
+        {
+            markup( "<date>" );
+            content( buffer.toString() );
+            markup( "</date>" );
+            buffer = new StringBuffer();
+        }
+    }
+
+    public void body()
+    {
+        markup( "<body>" + EOL );
+    }
+
+    public void body_()
+    {
+        markup( "</body>" + EOL );
+
+        markup( "</document>" + EOL );
+
+        out.flush();
+
+        resetState();
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // -----------------------------------------------------------------------
+
+    public void section1()
+    {
+        onSection( 1 );
+    }
+
+    public void sectionTitle1()
+    {
+        onSectionTitle( 1 );
+    }
+
+    public void sectionTitle1_()
+    {
+        onSectionTitle_( 1 );
+    }
+
+    public void section1_()
+    {
+        onSection_( 1 );
+    }
+
+    public void section2()
+    {
+        onSection( 2 );
+    }
+
+    public void sectionTitle2()
+    {
+        onSectionTitle( 2 );
+    }
+
+    public void sectionTitle2_()
+    {
+        onSectionTitle_( 2 );
+    }
+
+    public void section2_()
+    {
+        onSection_( 2 );
+    }
+
+    public void section3()
+    {
+        onSection( 3 );
+    }
+
+    public void sectionTitle3()
+    {
+        onSectionTitle( 3 );
+    }
+
+    public void sectionTitle3_()
+    {
+        onSectionTitle_( 3 );
+    }
+
+    public void section3_()
+    {
+        onSection_( 3 );
+    }
+
+    public void section4()
+    {
+        onSection( 4 );
+    }
+
+    public void sectionTitle4()
+    {
+        onSectionTitle( 4 );
+    }
+
+    public void sectionTitle4_()
+    {
+        onSectionTitle_( 4 );
+    }
+
+    public void section4_()
+    {
+        onSection_( 4 );
+    }
+
+    public void section5()
+    {
+        onSection( 5 );
+    }
+
+    public void sectionTitle5()
+    {
+        onSectionTitle( 5 );
+    }
+
+    public void sectionTitle5_()
+    {
+        onSectionTitle_( 5 );
+    }
+
+    public void section5_()
+    {
+        onSection_( 5 );
+    }
+
+    private void onSection( int depth )
+    {
+        if ( depth == 1 )
+        {
+            markup( "<section name=\"" );
+        }
+        else
+        {
+            markup( "<subsection name=\"" );
+        }
+    }
+
+    private void onSectionTitle( int depth )
+    {
+        titleFlag = true;
+    }
+
+    private void onSectionTitle_( int depth )
+    {
+        markup( "\">" );
+
+        titleFlag = false;
+    }
+
+    private void onSection_( int depth )
+    {
+        if ( depth == 1 )
+        {
+            markup( "</section>" );
+        }
+        else
+        {
+            markup( "</subsection>" );
+        }
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // -----------------------------------------------------------------------
+
+    public void list()
+    {
+        markup( "<ul>" + EOL );
+    }
+
+    public void list_()
+    {
+        markup( "</ul>" );
+        itemFlag = false;
+    }
+
+    public void listItem()
+    {
+        markup( "<li>" );
+        itemFlag = true;
+        // What follows is at least a paragraph.
+    }
+
+    public void listItem_()
+    {
+        markup( "</li>" + EOL );
+    }
+
+    public void numberedList( int numbering )
+    {
+        String style;
+        switch ( numbering )
+        {
+            case NUMBERING_UPPER_ALPHA:
+                style = "upper-alpha";
+                break;
+            case NUMBERING_LOWER_ALPHA:
+                style = "lower-alpha";
+                break;
+            case NUMBERING_UPPER_ROMAN:
+                style = "upper-roman";
+                break;
+            case NUMBERING_LOWER_ROMAN:
+                style = "lower-roman";
+                break;
+            case NUMBERING_DECIMAL:
+            default:
+                style = "decimal";
+        }
+        markup( "<ol style=\"list-style-type: " + style + "\">" + EOL );
+    }
+
+    public void numberedList_()
+    {
+        markup( "</ol>" );
+        itemFlag = false;
+    }
+
+    public void numberedListItem()
+    {
+        markup( "<li>" );
+        itemFlag = true;
+        // What follows is at least a paragraph.
+    }
+
+    public void numberedListItem_()
+    {
+        markup( "</li>" + EOL );
+    }
+
+    public void definitionList()
+    {
+        markup( "<dl compact=\"compact\">" + EOL );
+    }
+
+    public void definitionList_()
+    {
+        markup( "</dl>" );
+        itemFlag = false;
+    }
+
+    public void definedTerm()
+    {
+        markup( "<dt><b>" );
+    }
+
+    public void definedTerm_()
+    {
+        markup( "</b></dt>" + EOL );
+    }
+
+    public void definition()
+    {
+        markup( "<dd>" );
+        itemFlag = true;
+        // What follows is at least a paragraph.
+    }
+
+    public void definition_()
+    {
+        markup( "</dd>" + EOL );
+    }
+
+    public void paragraph()
+    {
+        if ( !itemFlag )
+        {
+            markup( "<p>" );
+        }
+    }
+
+    public void paragraph_()
+    {
+        if ( itemFlag )
+        {
+            itemFlag = false;
+        }
+        else
+        {
+            markup( "</p>" );
+        }
+    }
+
+    public void verbatim( boolean boxed )
+    {
+        verbatimFlag = true;
+        boxedFlag = boxed;
+        if ( boxed )
+        {
+            markup( "<source>" );
+        }
+        else
+        {
+            markup( "<pre>" );
+        }
+    }
+
+    public void verbatim_()
+    {
+        if ( boxedFlag )
+        {
+            markup( "</source>" );
+        }
+        else
+        {
+            markup( "</pre>" );
+        }
+
+        verbatimFlag = false;
+
+        boxedFlag = false;
+    }
+
+    public void horizontalRule()
+    {
+        markup( "<hr />" );
+    }
+
+    public void table()
+    {
+        markup( "<table align=\"center\">" + EOL );
+    }
+
+    public void table_()
+    {
+        markup( "</table>" );
+    }
+
+    public void tableRows( int[] justification, boolean grid )
+
+    {
+        markup( "<table align=\"center\" border=\"" + ( grid ? 1 : 0 ) + "\">" + EOL );
+        this.cellJustif = justification;
+    }
+
+    public void tableRows_()
+    {
+        markup( "</table>" );
+    }
+
+    public void tableRow()
+    {
+        markup( "<tr valign=\"top\">" + EOL );
+        cellCount = 0;
+    }
+
+    public void tableRow_()
+    {
+        markup( "</tr>" + EOL );
+        cellCount = 0;
+    }
+
+    public void tableCell()
+    {
+        tableCell( false );
+    }
+
+    public void tableHeaderCell()
+    {
+        tableCell( true );
+    }
+
+    public void tableCell( boolean headerRow )
+    {
+        String justif = null;
+
+        if ( cellJustif != null )
+        {
+            switch ( cellJustif[cellCount] )
+            {
+                case AptParser.JUSTIFY_LEFT:
+                    justif = "left";
+                    break;
+                case AptParser.JUSTIFY_RIGHT:
+                    justif = "right";
+                    break;
+                case AptParser.JUSTIFY_CENTER:
+                default:
+                    justif = "center";
+                    break;
+            }
+        }
+
+        if ( justif != null )
+        {
+            markup( "<t" + ( headerRow ? 'h' : 'd' ) + " align=\"" + justif + "\">" );
+        }
+        else
+        {
+            markup( "<t" + ( headerRow ? 'h' : 'd' ) + ">" );
+        }
+    }
+
+    public void tableCell_()
+    {
+        tableCell_( false );
+    }
+
+    public void tableHeaderCell_()
+    {
+        tableCell_( true );
+    }
+
+    public void tableCell_( boolean headerRow )
+    {
+        markup( "</t" + ( headerRow ? 'h' : 'd' ) + ">" + EOL );
+        ++cellCount;
+    }
+
+    public void tableCaption()
+    {
+        markup( "<p><i>" );
+    }
+
+    public void tableCaption_()
+    {
+        markup( "</i></p>" );
+    }
+
+    public void anchor( String name )
+    {
+        if ( !headFlag && !titleFlag )
+        {
+            String id = HtmlTools.encodeId( name );
+            markup( "<a id=\"" + id + "\" name=\"" + id + "\">" );
+        }
+    }
+
+    public void anchor_()
+    {
+        if ( !headFlag && !titleFlag )
+        {
+            markup( "</a>" );
+        }
+    }
+
+    public void link( String name )
+    {
+        if ( !headFlag && !titleFlag )
+        {
+            markup( "<a href=\"" + name + "\">" );
+        }
+    }
+
+    public void link_()
+    {
+        if ( !headFlag && !titleFlag )
+        {
+            markup( "</a>" );
+        }
+    }
+
+    public void italic()
+    {
+        if ( !headFlag && !titleFlag )
+        {
+            markup( "<i>" );
+        }
+    }
+
+    public void italic_()
+    {
+        if ( !headFlag && !titleFlag )
+        {
+            markup( "</i>" );
+        }
+    }
+
+    public void bold()
+    {
+        if ( !headFlag && !titleFlag )
+        {
+            markup( "<b>" );
+        }
+    }
+
+    public void bold_()
+    {
+        if ( !headFlag && !titleFlag )
+        {
+            markup( "</b>" );
+        }
+    }
+
+    public void monospaced()
+    {
+        if ( !headFlag && !titleFlag )
+        {
+            markup( "<tt>" );
+        }
+    }
+
+    public void monospaced_()
+    {
+        if ( !headFlag && !titleFlag )
+        {
+            markup( "</tt>" );
+        }
+    }
+
+    public void lineBreak()
+    {
+        if ( headFlag || titleFlag )
+        {
+            buffer.append( EOL );
+        }
+        else
+        {
+            markup( "<br />" );
+        }
+    }
+
+    public void nonBreakingSpace()
+    {
+        if ( headFlag || titleFlag )
+        {
+            buffer.append( ' ' );
+        }
+        else
+        {
+            markup( "&#160;" );
+        }
+    }
+
+    public void text( String text )
+    {
+        if ( headFlag )
+        {
+            buffer.append( text );
+        }
+        else if ( verbatimFlag )
+        {
+            verbatimContent( text );
+        }
+        else
+        {
+            content( text );
+        }
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    protected void markup( String text )
+    {
+        out.write( text, true );
+    }
+
+    protected void content( String text )
+    {
+        out.write( escapeHTML( text ), false );
+    }
+
+    protected void verbatimContent( String text )
+    {
+        out.write( escapeHTML( text ), true );
+    }
+
+    public static String escapeHTML( String text )
+    {
+        return HtmlTools.escapeHTML( text );
+    }
+
+    public static String encodeURL( String text )
+    {
+        return HtmlTools.encodeURL( text );
+    }
+
+    public void flush()
+    {
+        out.flush();
+    }
+
+    public void close()
+    {
+        out.close();
+    }
+}

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSiteModule.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSiteModule.java?view=auto&rev=519332
==============================================================================
--- maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSiteModule.java (added)
+++ maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSiteModule.java Sat Mar 17 07:48:17 2007
@@ -0,0 +1,47 @@
+package org.apache.maven.doxia.module.xdoc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.doxia.site.module.AbstractSiteModule;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id:XdocSiteModule.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005) brett $
+ * @plexus.component role="org.apache.maven.doxia.site.module.SiteModule"
+ * role-hint="xdoc"
+ */
+public class XdocSiteModule
+    extends AbstractSiteModule
+{
+    public String getSourceDirectory()
+    {
+        return "xdoc";
+    }
+
+    public String getExtension()
+    {
+        return "xml";
+    }
+
+    public String getParserId()
+    {
+        return "xdoc";
+    }
+}

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSiteModule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSiteModule.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java?view=auto&rev=519332
==============================================================================
--- maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java (added)
+++ maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java Sat Mar 17 07:48:17 2007
@@ -0,0 +1,120 @@
+package org.apache.maven.doxia.module.xdoc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.FileReader;
+import java.io.Reader;
+import java.io.StringWriter;
+
+import org.apache.maven.doxia.parser.AbstractParserTestCase;
+import org.apache.maven.doxia.parser.Parser;
+import org.apache.maven.doxia.sink.Sink;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
+ * @version $Id:XdocParserTest.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005) brett $
+ */
+public class XdocParserTest
+    extends AbstractParserTestCase
+{
+    private XdocParser parser;
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        parser = (XdocParser) lookup( Parser.ROLE, "xdoc" );
+    }
+
+    /**
+     * @see org.apache.maven.doxia.parser.AbstractParserTestCase#getParser()
+     */
+    protected Parser getParser()
+    {
+        return parser;
+    }
+
+    /**
+     * @see org.apache.maven.doxia.parser.AbstractParserTestCase#getDocument()
+     */
+    protected String getDocument()
+    {
+        return "src/test/site/xdoc/report.xml";
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testSnippetMacro()
+        throws Exception
+    {
+        StringWriter output = null;
+        Reader reader = null;
+
+        try
+        {
+            output = new StringWriter();
+            reader = new FileReader( getTestFile( getBasedir(), "src/test/site/xdoc/macro.xml" ) );
+
+            Sink sink = new XdocSink( output );
+            getParser().parse( reader, sink );
+
+            assertTrue( output.toString().indexOf( "&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;" ) != -1 );
+        }
+        finally
+        {
+            output.close();
+            reader.close();
+        }
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testTocMacro()
+        throws Exception
+    {
+        StringWriter output = null;
+        Reader reader = null;
+
+        try
+        {
+            output = new StringWriter();
+            reader = new FileReader( getTestFile( getBasedir(), "src/test/site/xdoc/toc.xml" ) );
+
+            Sink sink = new XdocSink( output );
+            getParser().parse( reader, sink );
+
+            // No section, only subsection 1 and 2
+            assertTrue( output.toString().indexOf( "<li><a href=\"#section_11\">Section 11</a></li>" ) != -1 );
+            assertTrue( output.toString().indexOf( "<li><a href=\"#section_1211\">Section 1211</a></li>" ) == -1 );
+        }
+        finally
+        {
+            output.close();
+            reader.close();
+        }
+    }
+}

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java?view=auto&rev=519332
==============================================================================
--- maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java (added)
+++ maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java Sat Mar 17 07:48:17 2007
@@ -0,0 +1,43 @@
+package org.apache.maven.doxia.module.xdoc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.doxia.module.xdoc.XdocSink;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.AbstractSinkTestCase;
+
+/**
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * @version $Id:XdocSinkTest.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005) brett $
+ */
+public class XdocSinkTest
+    extends AbstractSinkTestCase
+{
+    protected String outputExtension()
+    {
+        return "xml";
+    }
+
+    protected Sink createSink()
+        throws Exception
+    {
+        return new XdocSink( getTestWriter() );
+    }
+}

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"