Skip to content

Commit e1304dd

Browse files
committed
#26 Support combine.keys (in sync with xml-combiner implementation)
1 parent b93d9fa commit e1304dd

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/main/java/org/codehaus/plexus/util/xml/Xpp3DomUtils.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,12 @@ private static void mergeIntoXpp3Dom( Xpp3Dom dominant, Xpp3Dom recessive, Boole
171171
}
172172
}
173173

174+
final String keysValue = recessive.getAttribute( KEYS_COMBINATION_MODE_ATTRIBUTE );
175+
174176
Xpp3Dom[] children = recessive.getChildren();
175177
for ( Xpp3Dom recessiveChild : children )
176178
{
177179
String idValue = recessiveChild.getAttribute( ID_COMBINATION_MODE_ATTRIBUTE );
178-
String keysValue = recessiveChild.getAttribute( KEYS_COMBINATION_MODE_ATTRIBUTE );
179180

180181
Xpp3Dom childDom = null;
181182
if ( isNotEmpty( idValue ) )
@@ -196,15 +197,15 @@ else if ( isNotEmpty( keysValue ) )
196197
Map<String, String> recessiveKeyValues = new HashMap<String, String>( keys.length );
197198
for ( String key : keys )
198199
{
199-
recessiveKeyValues.put( key, recessiveChild.getChild( key ).getValue() );
200+
recessiveKeyValues.put( key, recessiveChild.getAttribute( key ) );
200201
}
201202

202203
for ( Xpp3Dom dominantChild : dominant.getChildren() )
203204
{
204205
Map<String, String> dominantKeyValues = new HashMap<String, String>( keys.length );
205206
for ( String key : keys )
206207
{
207-
dominantKeyValues.put( key, dominantChild.getChild( key ).getValue() );
208+
dominantKeyValues.put( key, dominantChild.getAttribute( key ) );
208209
}
209210

210211
if ( recessiveKeyValues.equals( dominantKeyValues ) )

src/test/java/org/codehaus/plexus/util/xml/Xpp3DomUtilsTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ public void testCombineId()
6464
public void testCombineKeys()
6565
throws Exception
6666
{
67-
String lhs = "<props>" + "<property combine.keys='name'><name>LHS-ONLY</name><value>LHS</value></property>"
67+
String lhs = "<props combine.keys='key'>" + "<property key=\"LHS-ONLY\"><name>LHS-ONLY</name><value>LHS</value></property>"
6868
+ "<property combine.keys='name'><name>TOOVERWRITE</name><value>LHS</value></property>" + "</props>";
6969

70-
String rhs = "<props>" + "<property combine.keys='name'><name>RHS-ONLY</name><value>RHS</value></property>"
70+
String rhs = "<props combine.keys='key'>" + "<property key=\"RHS-ONLY\"><name>RHS-ONLY</name><value>RHS</value></property>"
7171
+ "<property combine.keys='name'><name>TOOVERWRITE</name><value>RHS</value></property>" + "</props>";
7272

7373
Xpp3Dom leftDom = Xpp3DomBuilder.build( new StringReader( lhs ), new FixedInputLocationBuilder( "left" ) );

0 commit comments

Comments
 (0)