let hte XML parser detect th encoding

This commit is contained in:
Elliotte Rusty Harold 2023-03-04 18:42:08 -05:00
parent f41d533e71
commit 9e797f5e1b
1 changed files with 23 additions and 28 deletions

View File

@ -52,7 +52,6 @@ import org.apache.maven.internal.xml.XmlNodeBuilder;
#foreach ( $class in $model.allClasses ) #foreach ( $class in $model.allClasses )
import ${packageModelV4}.${class.name}; import ${packageModelV4}.${class.name};
#end #end
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.EntityReplacementMap; import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
import org.codehaus.plexus.util.xml.pull.MXParser; import org.codehaus.plexus.util.xml.pull.MXParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParser; import org.codehaus.plexus.util.xml.pull.XmlPullParser;
@ -565,13 +564,11 @@ public class ${className}
} //-- int nextTag( XmlPullParser ) } //-- int nextTag( XmlPullParser )
/** /**
* @see ReaderFactory#newXmlReader
* *
* @param reader a reader object. * @param reader a reader object
* @param strict a strict object. * @param strict a strict object
* @throws IOException IOException if any. * @throws IOException IOException if any
* @throws XmlPullParserException XmlPullParserException if * @throws XmlPullParserException XmlPullParserException if any
* any.
* @return ${root.name} * @return ${root.name}
*/ */
public ${root.name} read( Reader reader, boolean strict ) public ${root.name} read( Reader reader, boolean strict )
@ -581,17 +578,14 @@ public class ${className}
parser.setInput( reader ); parser.setInput( reader );
return read( parser, strict ); return read( parser, strict );
} //-- ${root.name} read( Reader, boolean ) } //-- ${root.name} read( Reader, boolean )
/** /**
* @see ReaderFactory#newXmlReader
* *
* @param reader a reader object. * @param reader a reader object
* @throws IOException IOException if any. * @throws IOException IOException if any.
* @throws XmlPullParserException XmlPullParserException if * @throws XmlPullParserException XmlPullParserException if any
* any.
* @return ${root.name} * @return ${root.name}
*/ */
public ${root.name} read( Reader reader ) public ${root.name} read( Reader reader )
@ -603,42 +597,43 @@ public class ${className}
/** /**
* Method read. * Method read.
* *
* @param in a in object. * @param in a in object
* @param strict a strict object. * @param strict a strict object
* @throws IOException IOException if any. * @throws IOException IOException if any
* @throws XmlPullParserException XmlPullParserException if * @throws XmlPullParserException XmlPullParserException if any
* any.
* @return ${root.name} * @return ${root.name}
*/ */
public ${root.name} read( InputStream in, boolean strict ) public ${root.name} read( InputStream in, boolean strict )
throws IOException, XmlPullParserException throws IOException, XmlPullParserException
{ {
return read( ReaderFactory.newXmlReader( in ), strict ); XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( );
parser.setInput( in, null );
return read( in, strict );
} //-- ${root.name} read( InputStream, boolean ) } //-- ${root.name} read( InputStream, boolean )
/** /**
* Method read. * Method read.
* *
* @param in a in object. * @param in a in object
* @throws IOException IOException if any. * @throws IOException IOException if any
* @throws XmlPullParserException XmlPullParserException if * @throws XmlPullParserException XmlPullParserException if any
* any.
* @return ${root.name} * @return ${root.name}
*/ */
public ${root.name} read( InputStream in ) public ${root.name} read( InputStream in )
throws IOException, XmlPullParserException throws IOException, XmlPullParserException
{ {
return read( ReaderFactory.newXmlReader( in ) ); return read( in, true );
} //-- ${root.name} read( InputStream ) } //-- ${root.name} read( InputStream )
/** /**
* Method read. * Method read.
* *
* @param parser a parser object. * @param parser a parser object
* @param strict a strict object. * @param strict a strict object
* @throws IOException IOException if any. * @throws IOException IOException if any
* @throws XmlPullParserException XmlPullParserException if * @throws XmlPullParserException XmlPullParserException if any
* any.
* @return ${root.name} * @return ${root.name}
*/ */
public ${root.name} read( XmlPullParser parser, boolean strict ) public ${root.name} read( XmlPullParser parser, boolean strict )