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 lt...@apache.org on 2007/11/03 21:55:59 UTC

svn commit: r591685 - /maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java

Author: ltheussl
Date: Sat Nov  3 13:55:58 2007
New Revision: 591685

URL: http://svn.apache.org/viewvc?rev=591685&view=rev
Log:
Add a convenience method to parse a string

Modified:
    maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java

Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java?rev=591685&r1=591684&r2=591685&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java (original)
+++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java Sat Nov  3 13:55:58 2007
@@ -21,6 +21,7 @@
 
 import java.io.IOException;
 import java.io.Reader;
+import java.io.StringReader;
 
 import org.apache.maven.doxia.macro.MacroExecutionException;
 import org.apache.maven.doxia.markup.XmlMarkup;
@@ -60,6 +61,20 @@
         {
             throw new ParseException( "Macro execution failed: " + ex.getMessage(), ex );
         }
+    }
+
+    /**
+     * Convenience method to parse an arbitrary string and emit any xml events into the given sink.
+     *
+     * @param string A string that provides the source input. The string has to be completely
+     * enclosed inside one xml root element, otherwise a ParseException is thrown.
+     * @param sink A sink that consumes the Doxia events.
+     * @throws ParseException if the string does not represent a well-formed xml snippet.
+     */
+    public void parse( String string, Sink sink )
+        throws ParseException
+    {
+        parse( new StringReader( string ), sink );
     }
 
     /** {@inheritDoc} */