mirror of https://github.com/apache/maven.git
[MNG-3839] XML parsing of POM does not reliably coalesce text data
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@714059 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2881df1046
commit
1f6060121d
|
@ -28,7 +28,7 @@ under the License.
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>maven-shared-model</artifactId>
|
<artifactId>maven-shared-model</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>maven-shared-model</name>
|
<name>Maven Shared Model</name>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.woodstox</groupId>
|
<groupId>org.codehaus.woodstox</groupId>
|
||||||
|
|
|
@ -82,9 +82,10 @@ public final class ModelMarshaller
|
||||||
|
|
||||||
Uri uri = new Uri( baseUri );
|
Uri uri = new Uri( baseUri );
|
||||||
String tagName = baseUri;
|
String tagName = baseUri;
|
||||||
String tagValue = null;
|
StringBuilder tagValue = new StringBuilder( 256 );
|
||||||
|
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
|
int depthOfTagValue = depth;
|
||||||
XMLStreamReader xmlStreamReader = null;
|
XMLStreamReader xmlStreamReader = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -97,22 +98,27 @@ public final class ModelMarshaller
|
||||||
switch ( type )
|
switch ( type )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
case XMLStreamConstants.CDATA:
|
||||||
case XMLStreamConstants.CHARACTERS:
|
case XMLStreamConstants.CHARACTERS:
|
||||||
{
|
{
|
||||||
String tmp = xmlStreamReader.getText();
|
if ( depth == depthOfTagValue )
|
||||||
if ( tmp != null && tmp.trim().length() != 0 )
|
|
||||||
{
|
{
|
||||||
tagValue = tmp;
|
tagValue.append( xmlStreamReader.getTextCharacters(), xmlStreamReader.getTextStart(),
|
||||||
|
xmlStreamReader.getTextLength() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XMLStreamConstants.START_ELEMENT:
|
case XMLStreamConstants.START_ELEMENT:
|
||||||
{
|
{
|
||||||
depth++;
|
|
||||||
if ( !tagName.equals( baseUri ) )
|
if ( !tagName.equals( baseUri ) )
|
||||||
{
|
{
|
||||||
modelProperties.add( new ModelProperty( tagName, tagValue ) );
|
String value = null;
|
||||||
|
if ( depth < depthOfTagValue )
|
||||||
|
{
|
||||||
|
value = tagValue.toString();
|
||||||
|
}
|
||||||
|
modelProperties.add( new ModelProperty( tagName, value ) );
|
||||||
if ( !attributes.isEmpty() )
|
if ( !attributes.isEmpty() )
|
||||||
{
|
{
|
||||||
for ( Map.Entry<String, String> e : attributes.entrySet() )
|
for ( Map.Entry<String, String> e : attributes.entrySet() )
|
||||||
|
@ -123,6 +129,7 @@ public final class ModelMarshaller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
depth++;
|
||||||
tagName = uri.getUriFor( xmlStreamReader.getName().getLocalPart(), depth );
|
tagName = uri.getUriFor( xmlStreamReader.getName().getLocalPart(), depth );
|
||||||
if ( collections.contains( tagName + "#collection" ) )
|
if ( collections.contains( tagName + "#collection" ) )
|
||||||
{
|
{
|
||||||
|
@ -138,8 +145,8 @@ public final class ModelMarshaller
|
||||||
{
|
{
|
||||||
uri.addTag( xmlStreamReader.getName().getLocalPart() );
|
uri.addTag( xmlStreamReader.getName().getLocalPart() );
|
||||||
}
|
}
|
||||||
tagValue = null;
|
tagValue.setLength( 0 );
|
||||||
|
depthOfTagValue = depth;
|
||||||
}
|
}
|
||||||
case XMLStreamConstants.ATTRIBUTE:
|
case XMLStreamConstants.ATTRIBUTE:
|
||||||
{
|
{
|
||||||
|
@ -155,15 +162,11 @@ public final class ModelMarshaller
|
||||||
case XMLStreamConstants.END_ELEMENT:
|
case XMLStreamConstants.END_ELEMENT:
|
||||||
{
|
{
|
||||||
depth--;
|
depth--;
|
||||||
if ( tagValue == null )
|
|
||||||
{
|
|
||||||
tagValue = "";
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XMLStreamConstants.END_DOCUMENT:
|
case XMLStreamConstants.END_DOCUMENT:
|
||||||
{
|
{
|
||||||
modelProperties.add( new ModelProperty( tagName, tagValue ) );
|
modelProperties.add( new ModelProperty( tagName, tagValue.toString() ) );
|
||||||
if ( !attributes.isEmpty() )
|
if ( !attributes.isEmpty() )
|
||||||
{
|
{
|
||||||
for ( Map.Entry<String, String> e : attributes.entrySet() )
|
for ( Map.Entry<String, String> e : attributes.entrySet() )
|
||||||
|
|
Loading…
Reference in New Issue