maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r660885 - in /maven/doxia/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/markup/ doxia-core/src/main/java/org/apache/maven/doxia/parser/ doxia-core/src/main/java/org/apache/maven/doxia/sink/ doxia-core/src/main/java/org/apache...
Date Wed, 28 May 2008 09:50:11 GMT
Author: ltheussl
Date: Wed May 28 02:50:10 2008
New Revision: 660885

URL: http://svn.apache.org/viewvc?rev=660885&view=rev
Log:
[DOXIA-243,DOXIA-183] Add an 'unknown' element to Sink API, removing xhtml-specific events from xdoc parser.

Added:
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java   (with props)
Modified:
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkEventTestingSink.java
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlMarkup.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocMarkup.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlMarkup.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
    maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java

Added: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java?rev=660885&view=auto
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java (added)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java Wed May 28 02:50:10 2008
@@ -0,0 +1,451 @@
+package org.apache.maven.doxia.markup;
+
+/*
+ * 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 javax.swing.text.html.HTML.Tag;
+
+
+/**
+ * List of <code>Html</code> tags.
+ * <p>
+ *   This should contain all valid XHTML 1.0 tags, comprising the tags in
+ *   {@link javax.swing.text.html.HTML.Tag} plus several others.
+ * </p>
+ *
+ * @author ltheussl
+ * @version $Id:$
+ * @since 1.0
+ */
+public interface HtmlMarkup
+    extends XmlMarkup
+{
+
+    /** A simple HTML tag. Eg <code>&lt;br/&gt;</code>. */
+    int TAG_TYPE_SIMPLE = 1;
+
+    /** A start HTML tag. Eg <code>&lt;p&gt;</code>. */
+    int TAG_TYPE_START = 2;
+
+    /** An end HTML tag. Eg <code>&lt;/p&gt;</code>. */
+    int TAG_TYPE_END = 3;
+
+    // ----------------------------------------------------------------------
+    // All XHTML 1.0 tags
+    // ----------------------------------------------------------------------
+
+    /** Xhtml tag for <code>a</code>. */
+    Tag A = Tag.A;
+
+    /** Xhtml tag for <code>abbr</code>. */
+    Tag ABBR = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "abbr";
+        }
+    };
+
+    /** Xhtml tag for <code>acronym</code>. */
+    Tag ACRONYM = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "acronym";
+        }
+    };
+
+    /** Xhtml tag for <code>address</code>. */
+    Tag ADDRESS = Tag.ADDRESS;
+
+    /** Xhtml tag for <code>applet</code>. */
+    Tag APPLET = Tag.APPLET;
+
+    /** Xhtml tag for <code>area</code>. */
+    Tag AREA = Tag.AREA;
+
+    /** Xhtml tag for <code>b</code>. */
+    Tag B = Tag.B;
+
+    /** Xhtml tag for <code>base</code>. */
+    Tag BASE = Tag.BASE;
+
+    /** Xhtml tag for <code>basefont</code>. */
+    Tag BASEFONT = Tag.BASEFONT;
+
+    /** Xhtml tag for <code>bdo</code>. */
+    Tag BDO = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "bdo";
+        }
+    };
+
+    /** Xhtml tag for <code>big</code>. */
+    Tag BIG = Tag.BIG;
+
+    /** Xhtml tag for <code>blockquote</code>. */
+    Tag BLOCKQUOTE = Tag.BLOCKQUOTE;
+
+    /** Xhtml tag for <code>body</code>. */
+    Tag BODY = Tag.BODY;
+
+    /** Xhtml tag for <code>br</code>. */
+    Tag BR = Tag.BR;
+
+    /** Xhtml tag for <code>button</code>. */
+    Tag BUTTON = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "button";
+        }
+    };
+
+    /** Xhtml tag for <code>caption</code>. */
+    Tag CAPTION = Tag.CAPTION;
+
+    /** Xhtml tag for <code>center</code>. */
+    Tag CENTER = Tag.CENTER;
+
+    /** Xhtml tag for <code>cite</code>. */
+    Tag CITE = Tag.CITE;
+
+    /** Xhtml tag for <code>code</code>. */
+    Tag CODE = Tag.CODE;
+
+    /** Xhtml tag for <code>col</code>. */
+    Tag COL = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "col";
+        }
+    };
+
+    /** Xhtml tag for <code>colgroup</code>. */
+    Tag COLGROUP = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "colgroup";
+        }
+    };
+
+    /** Xhtml tag for <code>dd</code>. */
+    Tag DD = Tag.DD;
+
+    /** Xhtml tag for <code>del</code>. */
+    Tag DEL = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "del";
+        }
+    };
+
+    /** Xhtml tag for <code>dfn</code>. */
+    Tag DFN = Tag.DFN;
+
+    /** Xhtml tag for <code>dir</code>. */
+    Tag DIR = Tag.DIR;
+
+    /** Xhtml tag for <code>div</code>. */
+    Tag DIV = Tag.DIV;
+
+    /** Xhtml tag for <code>dl</code>. */
+    Tag DL = Tag.DL;
+
+    /** Xhtml tag for <code>dt</code>. */
+    Tag DT = Tag.DT;
+
+    /** Xhtml tag for <code>em</code>. */
+    Tag EM = Tag.EM;
+
+    /** Xhtml tag for <code>fieldset</code>. */
+    Tag FIELDSET = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "fieldset";
+        }
+    };
+
+    /** Xhtml tag for <code>font</code>. */
+    Tag FONT = Tag.FONT;
+
+    /** Xhtml tag for <code>form</code>. */
+    Tag FORM = Tag.FORM;
+
+    /** Xhtml tag for <code>frame</code>. */
+    Tag FRAME = Tag.FRAME;
+
+    /** Xhtml tag for <code>frameset</code>. */
+    Tag FRAMESET = Tag.FRAMESET;
+
+    /** Xhtml tag for <code>h1</code>. */
+    Tag H1 = Tag.H1;
+
+    /** Xhtml tag for <code>h2</code>. */
+    Tag H2 = Tag.H2 ;
+
+    /** Xhtml tag for <code>h3</code>. */
+    Tag H3 = Tag.H3;
+
+    /** Xhtml tag for <code>h4</code>. */
+    Tag H4 = Tag.H4;
+
+    /** Xhtml tag for <code>h5</code>. */
+    Tag H5 = Tag.H5;
+
+    /** Xhtml tag for <code>h6</code>. */
+    Tag H6 = Tag.H6;
+
+    /** Xhtml tag for <code>head</code>. */
+    Tag HEAD = Tag.HEAD;
+
+    /** Xhtml tag for <code>hr</code>. */
+    Tag HR = Tag.HR;
+
+    /** Xhtml tag for <code>html</code>. */
+    Tag HTML = Tag.HTML;
+
+    /** Xhtml tag for <code>i</code>. */
+    Tag I = Tag.I;
+
+    /** Xhtml tag for <code>iframe</code>. */
+    Tag IFRAME = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "iframe";
+        }
+    };
+
+    /** Xhtml tag for <code>img</code>. */
+    Tag IMG = Tag.IMG;
+
+    /** Xhtml tag for <code>input</code>. */
+    Tag INPUT = Tag.INPUT;
+
+    /** Xhtml tag for <code>ins</code>. */
+    Tag INS = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "ins";
+        }
+    };
+
+    /** Xhtml tag for <code>isindex</code>. */
+    Tag ISINDEX = Tag.ISINDEX;
+
+    /** Xhtml tag for <code>kbd</code>. */
+    Tag KBD = Tag.KBD;
+
+    /** Xhtml tag for <code>label</code>. */
+    Tag LABEL = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "label";
+        }
+    };
+
+    /** Xhtml tag for <code>legend</code>. */
+    Tag LEGEND = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "legend";
+        }
+    };
+
+    /** Xhtml tag for <code>li</code>. */
+    Tag LI = Tag.LI;
+
+    /** Xhtml tag for <code>link</code>. */
+    Tag LINK = Tag.LINK;
+
+    /** Xhtml tag for <code>map</code>. */
+    Tag MAP = Tag.MAP;
+
+    /** Xhtml tag for <code>menu</code>. */
+    Tag MENU = Tag.MENU;
+
+    /** Xhtml tag for <code>meta</code>. */
+    Tag META = Tag.META;
+
+    /** Xhtml tag for <code>noframes</code>. */
+    Tag NOFRAMES = Tag.NOFRAMES;
+
+    /** Xhtml tag for <code>noscript</code>. */
+    Tag NOSCRIPT = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "noscript";
+        }
+    };
+
+    /** Xhtml tag for <code>object</code>. */
+    Tag OBJECT = Tag.OBJECT;
+
+    /** Xhtml tag for <code>ol</code>. */
+    Tag OL = Tag.OL;
+
+    /** Xhtml tag for <code>optgroup</code>. */
+    Tag OPTGROUP = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "optgroup";
+        }
+    };
+
+    /** Xhtml tag for <code>option</code>. */
+    Tag OPTION = Tag.OPTION;
+
+    /** Xhtml tag for <code>p</code>. */
+    Tag P = Tag.P;
+
+    /** Xhtml tag for <code>param</code>. */
+    Tag PARAM = Tag.PARAM;
+
+    /** Xhtml tag for <code>pre</code>. */
+    Tag PRE = Tag.PRE;
+
+    /** Xhtml tag for <code>q</code>. */
+    Tag Q = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "q";
+        }
+    };
+
+    /** Xhtml tag for <code>s</code>. */
+    Tag S = Tag.S;
+
+    /** Xhtml tag for <code>samp</code>. */
+    Tag SAMP = Tag.SAMP;
+
+    /** Xhtml tag for <code>script</code>. */
+    Tag SCRIPT = Tag.SCRIPT;
+
+    /** Xhtml tag for <code>select</code>. */
+    Tag SELECT = Tag.SELECT;
+
+    /** Xhtml tag for <code>small</code>. */
+    Tag SMALL = Tag.SMALL;
+
+    /** Xhtml tag for <code>span</code>. */
+    Tag SPAN = Tag.SPAN;
+
+    /** Xhtml tag for <code>strike</code>. */
+    Tag STRIKE = Tag.STRIKE;
+
+    /** Xhtml tag for <code>strong</code>. */
+    Tag STRONG = Tag.STRONG;
+
+    /** Xhtml tag for <code>style</code>. */
+    Tag STYLE = Tag.STYLE;
+
+    /** Xhtml tag for <code>sub</code>. */
+    Tag SUB = Tag.SUB;
+
+    /** Xhtml tag for <code>sup</code>. */
+    Tag SUP = Tag.SUP;
+
+    /** Xhtml tag for <code>table</code>. */
+    Tag TABLE = Tag.TABLE;
+
+    /** Xhtml tag for <code>tbody</code>. */
+    Tag TBODY = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "tbody";
+        }
+    };
+
+    /** Xhtml tag for <code>td</code>. */
+    Tag TD = Tag.TD;
+
+    /** Xhtml tag for <code>textarea</code>. */
+    Tag TEXTAREA = Tag.TEXTAREA;
+
+    /** Xhtml tag for <code>tfoot</code>. */
+    Tag TFOOT = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "tfoot";
+        }
+    };
+
+    /** Xhtml tag for <code>th</code>. */
+    Tag TH = Tag.TH;
+
+    /** Xhtml tag for <code>thead</code>. */
+    Tag THEAD = new Tag()
+    {
+        /** {@inheritDoc} */
+        public String toString()
+        {
+            return "thead";
+        }
+    };
+
+    /** Xhtml tag for <code>title</code>. */
+    Tag TITLE = Tag.TITLE;
+
+    /** Xhtml tag for <code>tr</code>. */
+    Tag TR = Tag.TR;
+
+    /** Xhtml tag for <code>tt</code>. */
+    Tag TT = Tag.TT;
+
+    /** Xhtml tag for <code>u</code>. */
+    Tag U = Tag.U;
+
+    /** Xhtml tag for <code>ul</code>. */
+    Tag UL = Tag.UL;
+
+    /** Xhtml tag for <code>var</code>. */
+    Tag VAR = Tag.VAR ;
+}

Propchange: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java Wed May 28 02:50:10 2008
@@ -697,6 +697,26 @@
     }
 
     /**
+     * Handles an unkown event.
+     *
+     * @param parser the parser to get the event from.
+     * @param sink the sink to receive the event.
+     * @param type the tag event type. This should be one of HtmlMarkup.TAG_TYPE_SIMPLE,
+     * HtmlMarkup.TAG_TYPE_START or HtmlMarkup.TAG_TYPE_END. It will be passed as the first
+     * argument of the required parameters to the Sink
+     * {@link org.apache.maven.doxia.sink.Sink#unkown(String,Object[],SinkEventAttributes) unkown}
+     * method.
+     */
+    protected void handleUnknown( XmlPullParser parser, Sink sink, int type )
+    {
+        Object[] required = new Object[] { new Integer( type ) };
+
+        SinkEventAttributeSet attribs = getAttributesFromParser( parser );
+
+        sink.unknown( parser.getName(), required, attribs );
+    }
+
+    /**
      * Close open sections. The current level is set to newLevel afterwards.
      *
      * @param newLevel the new section level, all upper levels have to be closed.

Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/SinkAdapter.java Wed May 28 02:50:10 2008
@@ -844,4 +844,10 @@
     {
         text( text );
     }
+
+    /** {@inheritDoc} */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        // nop
+    }
 }

Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/sink/XhtmlBaseSink.java Wed May 28 02:50:10 2008
@@ -26,6 +26,7 @@
 import javax.swing.text.html.HTML.Attribute;
 import javax.swing.text.html.HTML.Tag;
 
+import org.apache.maven.doxia.markup.HtmlMarkup;
 import org.apache.maven.doxia.parser.Parser;
 import org.apache.maven.doxia.util.DoxiaUtils;
 import org.apache.maven.doxia.util.HtmlTools;
@@ -40,6 +41,7 @@
  */
 public class XhtmlBaseSink
     extends AbstractXmlSink
+    implements HtmlMarkup
 {
     // ----------------------------------------------------------------------
     // Instance fields
@@ -1595,6 +1597,54 @@
         rawText( buf.toString() );
     }
 
+    /**
+     * Adding an unkown event, <i>ie</i> an event that was not recognized by a parser.
+     * If {@link org.apache.maven.doxia.util.HtmlTools#getHtmlTag(String) HtmlTools.getHtmlTag( name )}
+     * does not return null, the corresponding tag will be written.
+     *
+     * @param name The name of the event.
+     * @param requiredParams If <code>name</code> is a defined HTML tag, the first element of
+     * this array has to be an Integer wrapping one of the TAG_TYPE constants in
+     * {@link org.apache.maven.doxia.markup.HtmlMarkup HtmlMarkup}, otherwise an
+     * IllegalArgumentException is thrown.
+     * @param attributes A set of optional {@link SinkEventAttributes}, may be <code>null</code>.
+     */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        Tag tag = HtmlTools.getHtmlTag( name );
+
+        if ( tag == null )
+        {
+            getLog().warn( "No HTML tag found for unknown Sink event: " + name + ", ignoring!" );
+        }
+        else
+        {
+            if ( requiredParams == null || !( requiredParams[0] instanceof Integer ) )
+            {
+                throw new IllegalArgumentException( "Missing required parameter: TAG_TYPE" );
+            }
+
+            int tagType = ( (Integer) requiredParams[0] ).intValue();
+
+            if ( tagType == TAG_TYPE_SIMPLE )
+            {
+                writeSimpleTag( tag, attributes );
+            }
+            else if ( tagType == TAG_TYPE_START )
+            {
+                writeStartTag( tag, attributes );
+            }
+            else if ( tagType == TAG_TYPE_END )
+            {
+                writeEndTag( tag );
+            }
+            else
+            {
+                throw new IllegalArgumentException( "Not a valid TAG_TYPE: " + tagType );
+            }
+        }
+    }
+
     /** {@inheritDoc} */
     public void flush()
     {

Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java Wed May 28 02:50:10 2008
@@ -21,6 +21,12 @@
 
 import java.io.UnsupportedEncodingException;
 
+import java.util.Hashtable;
+
+import javax.swing.text.html.HTML.Tag;
+
+import org.apache.maven.doxia.markup.HtmlMarkup;
+
 
 /**
  * The <code>HtmlTools</code> class defines methods to HTML handling.
@@ -31,6 +37,55 @@
  */
 public class HtmlTools
 {
+    private static final Tag[] allTags  =
+    {
+        HtmlMarkup.A, HtmlMarkup.ABBR, HtmlMarkup.ACRONYM, HtmlMarkup.ADDRESS, HtmlMarkup.APPLET,
+        HtmlMarkup.AREA, HtmlMarkup.B, HtmlMarkup.BASE, HtmlMarkup.BASEFONT, HtmlMarkup.BDO,
+        HtmlMarkup.BIG, HtmlMarkup.BLOCKQUOTE, HtmlMarkup.BODY, HtmlMarkup.BR, HtmlMarkup.BUTTON,
+        HtmlMarkup.CAPTION, HtmlMarkup.CENTER, HtmlMarkup.CITE, HtmlMarkup.CODE, HtmlMarkup.COL,
+        HtmlMarkup.COLGROUP, HtmlMarkup.DD, HtmlMarkup.DEL, HtmlMarkup.DFN, HtmlMarkup.DIR,
+        HtmlMarkup.DIV, HtmlMarkup.DL, HtmlMarkup.DT, HtmlMarkup.EM, HtmlMarkup.FIELDSET,
+        HtmlMarkup.FONT, HtmlMarkup.FORM, HtmlMarkup.FRAME, HtmlMarkup.FRAMESET, HtmlMarkup.H1,
+        HtmlMarkup.H2, HtmlMarkup.H3, HtmlMarkup.H4, HtmlMarkup.H5, HtmlMarkup.H6, HtmlMarkup.HEAD,
+        HtmlMarkup.HR, HtmlMarkup.HTML, HtmlMarkup.I, HtmlMarkup.IFRAME, HtmlMarkup.IMG,
+        HtmlMarkup.INPUT, HtmlMarkup.INS, HtmlMarkup.ISINDEX, HtmlMarkup.KBD, HtmlMarkup.LABEL,
+        HtmlMarkup.LEGEND, HtmlMarkup.LI, HtmlMarkup.LINK, HtmlMarkup.MAP, HtmlMarkup.MENU,
+        HtmlMarkup.META, HtmlMarkup.NOFRAMES, HtmlMarkup.NOSCRIPT, HtmlMarkup.OBJECT, HtmlMarkup.OL,
+        HtmlMarkup.OPTGROUP, HtmlMarkup.OPTION, HtmlMarkup.P, HtmlMarkup.PARAM, HtmlMarkup.PRE,
+        HtmlMarkup.Q, HtmlMarkup.S, HtmlMarkup.SAMP, HtmlMarkup.SCRIPT, HtmlMarkup.SELECT,
+        HtmlMarkup.SMALL, HtmlMarkup.SPAN, HtmlMarkup.STRIKE, HtmlMarkup.STRONG, HtmlMarkup.STYLE,
+        HtmlMarkup.SUB, HtmlMarkup.SUP, HtmlMarkup.TABLE, HtmlMarkup.TBODY, HtmlMarkup.TD,
+        HtmlMarkup.TEXTAREA, HtmlMarkup.TFOOT, HtmlMarkup.TH, HtmlMarkup.THEAD, HtmlMarkup.TITLE,
+        HtmlMarkup.TR, HtmlMarkup.TT, HtmlMarkup.U, HtmlMarkup.UL, HtmlMarkup.VAR
+    };
+
+    private static final Hashtable tagHashtable = new Hashtable( allTags.length );
+
+    static
+    {
+        for ( int i = 0; i < allTags.length; i++ )
+        {
+            tagHashtable.put( allTags[i].toString(), allTags[i] );
+        }
+    }
+
+    /**
+     * Returns a tag for a defined HTML tag name (i.e. one of
+     * the tags defined in {@link org.apache.maven.doxia.markup.HtmlMarkup}.
+     * If the given name does not represent one of the defined tags, then
+     * <code>null</code> will be returned.
+     *
+     * @param tagName the <code>String</code> name requested.
+     * @return a tag constant corresponding to the <code>tagName</code>,
+     *    or <code>null</code> if not found.
+     */
+    public static Tag getHtmlTag( String tagName )
+    {
+        Object t =  tagHashtable.get( tagName );
+
+        return ( t == null ? null : (Tag) t );
+    }
+
     /**
      * Escape special HTML characters in a String in <code>xml</code> mode.
      *

Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkEventTestingSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkEventTestingSink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkEventTestingSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/SinkEventTestingSink.java Wed May 28 02:50:10 2008
@@ -807,6 +807,12 @@
         text( text );
     }
 
+    /** {@inheritDoc} */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        addEvent( name, requiredParams );
+    }
+
       //
      // private
     //

Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/TextSink.java Wed May 28 02:50:10 2008
@@ -814,6 +814,12 @@
         text( text );
     }
 
+    /** {@inheritDoc} */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        write( "unknown: " + name );
+    }
+
     /**
      * Writes the given string + EOL.
      *

Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/sink/WellformednessCheckingSink.java Wed May 28 02:50:10 2008
@@ -752,4 +752,10 @@
     {
         text( text );
     }
+
+    /** {@inheritDoc} */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        // ignore
+    }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-apt/src/main/java/org/apache/maven/doxia/module/apt/AptSink.java Wed May 28 02:50:10 2008
@@ -24,6 +24,7 @@
 import java.util.Stack;
 
 import org.apache.maven.doxia.sink.AbstractTextSink;
+import org.apache.maven.doxia.sink.SinkEventAttributes;
 
 import org.codehaus.plexus.util.StringUtils;
 
@@ -874,6 +875,18 @@
         rawText( EOL + COMMENT + COMMENT + SPACE + comment.trim() );
     }
 
+    /**
+     * Unkown events just log a warning message but are ignored otherwise.
+     *
+     * @param name The name of the event.
+     * @param requiredParams not used.
+     * @param attributes not used.
+     * @see org.apache.maven.doxia.sink.Sink#unknown(String,Object[],SinkEventAttributes)
+     */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        getLog().warn( "Unknown Sink event in AptSink: " + name + ", ignoring!" );
+    }
 
     /**
      * Write text to output.

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-docbook-simple/src/main/java/org/apache/maven/doxia/module/docbook/DocBookSink.java Wed May 28 02:50:10 2008
@@ -31,6 +31,7 @@
 
 import org.apache.maven.doxia.parser.Parser;
 import org.apache.maven.doxia.sink.AbstractXmlSink;
+import org.apache.maven.doxia.sink.SinkEventAttributes;
 import org.apache.maven.doxia.util.DoxiaUtils;
 import org.apache.maven.doxia.util.HtmlTools;
 import org.apache.maven.doxia.util.LineBreaker;
@@ -1670,6 +1671,19 @@
         markup( buffer.toString() );
     }
 
+    /**
+     * Unkown events just log a warning message but are ignored otherwise.
+     *
+     * @param name The name of the event.
+     * @param requiredParams not used.
+     * @param attributes not used.
+     * @see org.apache.maven.doxia.sink.Sink#unknown(String,Object[],SinkEventAttributes)
+     */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        getLog().warn( "Unknown Sink event in DocBookSink: " + name + ", ignoring!" );
+    }
+
     // -----------------------------------------------------------------------
 
     /**

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlContentParser.java Wed May 28 02:50:10 2008
@@ -37,14 +37,20 @@
     extends XhtmlBaseParser
     implements FmlMarkup
 {
+    /** Empty elements don't write a closing tag. */
+    private boolean isEmptyElement;
+
     /** {@inheritDoc} */
     protected void handleStartTag( XmlPullParser parser, Sink sink )
         throws XmlPullParserException, MacroExecutionException
     {
+        isEmptyElement = parser.isEmptyElementTag();
+
         if ( parser.getName().equals( QUESTION_TAG.toString() )
             || parser.getName().equals( ANSWER_TAG.toString() ) )
         {
             // ignore
+            return;
         }
         else if ( parser.getName().equals( SOURCE_TAG.toString() ) )
         {
@@ -54,13 +60,22 @@
         }
         else if ( !baseStartTag( parser, sink ) )
         {
-            if ( !isVerbatim() && getLog().isWarnEnabled() )
+            if ( isEmptyElement )
+            {
+                handleUnknown( parser, sink, TAG_TYPE_SIMPLE );
+            }
+            else
+            {
+                handleUnknown( parser, sink, TAG_TYPE_START );
+            }
+
+            if ( !isVerbatim() && getLog().isDebugEnabled() )
             {
                 String position = "[" + parser.getLineNumber() + ":"
                     + parser.getColumnNumber() + "]";
                 String tag = "<" + parser.getName() + ">";
 
-                getLog().warn( "Unrecognized fml tag: " + tag + " at " + position );
+                getLog().debug( "Unrecognized fml tag: " + tag + " at " + position );
             }
         }
     }
@@ -69,7 +84,13 @@
     protected void handleEndTag( XmlPullParser parser, Sink sink )
         throws XmlPullParserException, MacroExecutionException
     {
-        if ( parser.getName().equals( SOURCE_TAG.toString() ) )
+        if ( parser.getName().equals( QUESTION_TAG.toString() )
+            || parser.getName().equals( ANSWER_TAG.toString() ) )
+        {
+            // ignore
+            return;
+        }
+        else if ( parser.getName().equals( SOURCE_TAG.toString() ) )
         {
             verbatim_();
 
@@ -77,7 +98,12 @@
         }
         else if ( !baseEndTag( parser, sink ) )
         {
-            // unrecognized tag is already logged in StartTag
+            if ( !isEmptyElement )
+            {
+                handleUnknown( parser, sink, TAG_TYPE_END );
+            }
         }
+
+        isEmptyElement = false;
     }
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlMarkup.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlMarkup.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlMarkup.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlMarkup.java Wed May 28 02:50:10 2008
@@ -21,7 +21,7 @@
 
 import javax.swing.text.html.HTML.Tag;
 
-import org.apache.maven.doxia.markup.XmlMarkup;
+import org.apache.maven.doxia.markup.HtmlMarkup;
 
 /**
  * List of <code>FML</code> markups.
@@ -34,7 +34,7 @@
  * @since 1.0
  */
 public interface FmlMarkup
-    extends XmlMarkup
+    extends HtmlMarkup
 {
     // ----------------------------------------------------------------------
     // Specific Fml tags

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoSink.java Wed May 28 02:50:10 2008
@@ -29,6 +29,7 @@
 
 import org.apache.maven.doxia.sink.AbstractXmlSink;
 import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkEventAttributes;
 import org.apache.maven.doxia.parser.Parser;
 import org.apache.maven.doxia.util.DoxiaUtils;
 import org.apache.maven.doxia.util.HtmlTools;
@@ -955,6 +956,19 @@
     }
 
     /**
+     * Unkown events just log a warning message but are ignored otherwise.
+     *
+     * @param name The name of the event.
+     * @param requiredParams not used.
+     * @param attributes not used.
+     * @see org.apache.maven.doxia.sink.Sink#unknown(String,Object[],SinkEventAttributes)
+     */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        getLog().warn( "Unknown Sink event in FoSink: " + name + ", ignoring!" );
+    }
+
+    /**
      * Writes the beginning of a FO document.
      */
     public void beginDocument()

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-itext/src/main/java/org/apache/maven/doxia/module/itext/ITextSink.java Wed May 28 02:50:10 2008
@@ -19,6 +19,10 @@
  * under the License.
  */
 
+import com.lowagie.text.BadElementException;
+import com.lowagie.text.ElementTags;
+import com.lowagie.text.Image;
+
 import java.awt.Color;
 import java.io.IOException;
 import java.io.LineNumberReader;
@@ -30,16 +34,15 @@
 
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.SinkAdapter;
+import org.apache.maven.doxia.sink.SinkEventAttributes;
+import org.apache.maven.doxia.util.DoxiaUtils;
 import org.apache.maven.doxia.util.HtmlTools;
+
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
 import org.codehaus.plexus.util.xml.XMLWriter;
 
-import com.lowagie.text.BadElementException;
-import com.lowagie.text.ElementTags;
-import com.lowagie.text.Image;
-import org.apache.maven.doxia.util.DoxiaUtils;
 
 /**
  * <p>A doxia Sink which produces an XML Front End document for <code>iText</code> framework.</p>
@@ -1649,6 +1652,19 @@
     }
 
     /**
+     * Unkown events just log a warning message but are ignored otherwise.
+     *
+     * @param name The name of the event.
+     * @param requiredParams not used.
+     * @param attributes not used.
+     * @see org.apache.maven.doxia.sink.Sink#unknown(String,Object[],SinkEventAttributes)
+     */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        getLog().warn( "Unknown Sink event in ITextSink: " + name + ", ignoring!" );
+    }
+
+    /**
      * Convenience method to write a starting element.
      *
      * @param tag the name of the tag

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java Wed May 28 02:50:10 2008
@@ -21,6 +21,7 @@
 
 import org.apache.maven.doxia.parser.Parser;
 import org.apache.maven.doxia.sink.AbstractTextSink;
+import org.apache.maven.doxia.sink.SinkEventAttributes;
 import org.apache.maven.doxia.util.DoxiaUtils;
 import org.apache.maven.doxia.util.LineBreaker;
 
@@ -1004,6 +1005,19 @@
         }
     }
 
+    /**
+     * Unkown events just log a warning message but are ignored otherwise.
+     *
+     * @param name The name of the event.
+     * @param requiredParams not used.
+     * @param attributes not used.
+     * @see org.apache.maven.doxia.sink.Sink#unknown(String,Object[],SinkEventAttributes)
+     */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        getLog().warn( "Unknown Sink event in LatexSink: " + name + ", ignoring!" );
+    }
+
     // -----------------------------------------------------------------------
 
     /**

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-rtf/src/main/java/org/apache/maven/doxia/module/rtf/RtfSink.java Wed May 28 02:50:10 2008
@@ -20,6 +20,7 @@
  */
 
 import java.awt.Color;
+
 import java.io.BufferedOutputStream;
 import java.io.BufferedWriter;
 import java.io.IOException;
@@ -27,6 +28,7 @@
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.Writer;
+
 import java.util.Hashtable;
 import java.util.StringTokenizer;
 import java.util.Vector;
@@ -34,6 +36,7 @@
 import org.apache.maven.doxia.parser.Parser;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.SinkAdapter;
+import org.apache.maven.doxia.sink.SinkEventAttributes;
 
 /**
  * @version $Id$
@@ -1385,6 +1388,19 @@
         }
     }
 
+    /**
+     * Unkown events just log a warning message but are ignored otherwise.
+     *
+     * @param name The name of the event.
+     * @param requiredParams not used.
+     * @param attributes not used.
+     * @see org.apache.maven.doxia.sink.Sink#unknown(String,Object[],SinkEventAttributes)
+     */
+    public void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes )
+    {
+        getLog().warn( "Unknown Sink event in RtfSink: " + name + ", ignoring!" );
+    }
+
     private static String normalize( String s )
     {
         int length = s.length();

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocMarkup.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocMarkup.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocMarkup.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocMarkup.java Wed May 28 02:50:10 2008
@@ -21,7 +21,7 @@
 
 import javax.swing.text.html.HTML.Tag;
 
-import org.apache.maven.doxia.markup.XmlMarkup;
+import org.apache.maven.doxia.markup.HtmlMarkup;
 
 /**
  * List of <code>Xdoc</code> markups.
@@ -34,7 +34,7 @@
  * @since 1.0
  */
 public interface XdocMarkup
-    extends XmlMarkup
+    extends HtmlMarkup
 {
     // ----------------------------------------------------------------------
     // Specific Xdoc tags

Modified: maven/doxia/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/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java Wed May 28 02:50:10 2008
@@ -207,28 +207,33 @@
                 else
                 {
                     // param tag from non-macro object, see MSITE-288
-                    // TODO: remove
-                    handleRawText( sink, parser );
+                    handleUnknown( parser, sink, TAG_TYPE_START );
                 }
             }
         }
         else if ( parser.getName().equals( Tag.SCRIPT.toString() ) )
         {
-            handleRawText( sink, parser );
+            handleUnknown( parser, sink, TAG_TYPE_START );
             scriptBlock = true;
         }
         else if ( !baseStartTag( parser, sink ) )
         {
-            // TODO: remove
-            handleRawText( sink, parser );
+            if ( isEmptyElement )
+            {
+                handleUnknown( parser, sink, TAG_TYPE_SIMPLE );
+            }
+            else
+            {
+                handleUnknown( parser, sink, TAG_TYPE_START );
+            }
 
-            if ( !isVerbatim() && getLog().isWarnEnabled() )
+            if ( !isVerbatim() && getLog().isDebugEnabled() )
             {
                 String position = "[" + parser.getLineNumber() + ":"
                     + parser.getColumnNumber() + "]";
                 String tag = "<" + parser.getName() + ">";
 
-                getLog().warn( "Unrecognized xdoc tag: " + tag + " at " + position );
+                getLog().debug( "Unrecognized xdoc tag: " + tag + " at " + position );
             }
         }
     }
@@ -313,9 +318,7 @@
         {
             if ( !StringUtils.isNotEmpty( macroName ) )
             {
-                // TODO: remove
-                sink.rawText( String.valueOf( LESS_THAN ) + String.valueOf( SLASH )
-                    + Tag.PARAM.toString() + String.valueOf( GREATER_THAN ));
+                handleUnknown( parser, sink, TAG_TYPE_END );
             }
         }
         else if ( parser.getName().equals( SECTION_TAG.toString() ) )
@@ -332,13 +335,7 @@
         }
         else if ( parser.getName().equals( Tag.SCRIPT.toString() ) )
         {
-            // TODO: this is HTML specific, factor out into a specialized parser
-
-            sink.rawText( String.valueOf( LESS_THAN ) + String.valueOf( SLASH ) );
-
-            sink.rawText( parser.getName() );
-
-            sink.rawText( String.valueOf( GREATER_THAN ) );
+            handleUnknown( parser, sink, TAG_TYPE_END );
 
             scriptBlock = false;
         }
@@ -346,13 +343,7 @@
         {
             if ( !isEmptyElement )
             {
-                // TODO: this is HTML specific, factor out into a specialized parser
-
-                sink.rawText( String.valueOf( LESS_THAN ) + String.valueOf( SLASH ) );
-
-                sink.rawText( parser.getName() );
-
-                sink.rawText( String.valueOf( GREATER_THAN ) );
+                handleUnknown( parser, sink, TAG_TYPE_END );
             }
         }
 
@@ -404,41 +395,4 @@
         setSectionLevel( newLevel );
     }
 
-    // ----------------------------------------------------------------------
-    // Private methods
-    // ----------------------------------------------------------------------
-
-    /**
-     * Handles raw text events.
-     *
-     * @param sink the sink to receive the events.
-     * @param parser A parser.
-     * @todo this is HTML specific, factor out into a specialized parser
-     */
-    private void handleRawText( Sink sink, XmlPullParser parser )
-    {
-        sink.rawText( String.valueOf( LESS_THAN ) );
-
-        sink.rawText( parser.getName() );
-
-        int count = parser.getAttributeCount();
-
-        for ( int i = 0; i < count; i++ )
-        {
-            sink.rawText( String.valueOf( SPACE ) );
-
-            sink.rawText( parser.getAttributeName( i ) );
-
-            sink.rawText( String.valueOf( EQUAL ) );
-
-            sink.rawText( String.valueOf( QUOTE ) );
-
-            sink.rawText( parser.getAttributeValue( i ) );
-
-            sink.rawText( String.valueOf( QUOTE ) );
-        }
-
-        sink.rawText( String.valueOf( GREATER_THAN ) );
-    }
-
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlMarkup.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlMarkup.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlMarkup.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlMarkup.java Wed May 28 02:50:10 2008
@@ -19,9 +19,7 @@
  * under the License.
  */
 
-import javax.swing.text.html.HTML.Tag;
-
-import org.apache.maven.doxia.markup.XmlMarkup;
+import org.apache.maven.doxia.markup.HtmlMarkup;
 
 /**
  * List of <code>Xhtml</code> markups.
@@ -34,19 +32,6 @@
  * @since 1.0
  */
 public interface XhtmlMarkup
-    extends XmlMarkup
+    extends HtmlMarkup
 {
-    // ----------------------------------------------------------------------
-    // Specific XHTML tags
-    // ----------------------------------------------------------------------
-
-    /** Xhtml tag for <code>tbody</code> */
-    Tag TBODY_TAG = new Tag()
-    {
-        /** {@inheritDoc} */
-        public String toString()
-        {
-            return "tbody";
-        }
-    };
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java Wed May 28 02:50:10 2008
@@ -45,10 +45,15 @@
     /** For boxed verbatim. */
     private boolean boxed;
 
+    /** Empty elements don't write a closing tag. */
+    private boolean isEmptyElement;
+
     /** {@inheritDoc} */
     protected void handleStartTag( XmlPullParser parser, Sink sink )
         throws XmlPullParserException, MacroExecutionException
     {
+        isEmptyElement = parser.isEmptyElementTag();
+
         SinkEventAttributeSet attribs = getAttributesFromParser( parser );
 
         if ( parser.getName().equals( Tag.HTML.toString() ) )
@@ -111,6 +116,7 @@
             {
                 this.boxed = true;
             }
+
             super.baseStartTag( parser, sink ); // pick up other divs
         }
         /*
@@ -134,13 +140,22 @@
         }
         else if ( !baseStartTag( parser, sink ) )
         {
-            if ( getLog().isWarnEnabled() )
+            if ( isEmptyElement )
+            {
+                handleUnknown( parser, sink, TAG_TYPE_SIMPLE );
+            }
+            else
+            {
+                handleUnknown( parser, sink, TAG_TYPE_START );
+            }
+
+            if ( getLog().isDebugEnabled() )
             {
                 String position = "[" + parser.getLineNumber() + ":"
                     + parser.getColumnNumber() + "]";
                 String tag = "<" + parser.getName() + ">";
 
-                getLog().warn( "Unrecognized xhtml tag: " + tag + " at " + position );
+                getLog().debug( "Unrecognized xhtml tag: " + tag + " at " + position );
             }
         }
     }
@@ -179,9 +194,13 @@
         }
         else if ( !baseEndTag( parser, sink ) )
         {
-            // unrecognized tag is already logged in StartTag
+            if ( !isEmptyElement )
+            {
+                handleUnknown( parser, sink, TAG_TYPE_END );
+            }
         }
-    }
 
+        isEmptyElement = false;
+    }
 
 }

Modified: maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java?rev=660885&r1=660884&r2=660885&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java (original)
+++ maven/doxia/doxia/trunk/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java Wed May 28 02:50:10 2008
@@ -1266,6 +1266,19 @@
     void comment( String comment );
 
     /**
+     * Add an unkown event. This may be used by parsers to notify a general Sink about
+     * an event that doesn't fit into any event defined by the Sink API.
+     * Depending on the parameters, a Sink may decide whether or not to process the event,
+     * emit it as raw text, as a comment, log it, etc.
+     *
+     * @param name The name of the event.
+     * @param requiredParams An optional array of required parameters to the event.
+     * May be <code>null</code>.
+     * @param attributes A set of {@link SinkEventAttributes}, may be <code>null</code>.
+     */
+    void unknown( String name, Object[] requiredParams, SinkEventAttributes attributes );
+
+    /**
      * Flush the writer or the stream, if needed.
      * Flushing a previously-flushed Sink has no effect.
      */



Mime
View raw message