Skip to content

Commit c0257ab

Browse files
committed
accepts description subelement within map entry as well (as per the XSD; SPR-8563)
1 parent 79aa661 commit c0257ab

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2011 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -1176,7 +1176,10 @@ public Map parseMapElement(Element mapEle, BeanDefinition bd) {
11761176
}
11771177
else {
11781178
// Child element is what we're looking for.
1179-
if (valueEle != null) {
1179+
if (nodeNameEquals(candidateEle, DESCRIPTION_ELEMENT)) {
1180+
// the element is a <description> -> ignore it
1181+
}
1182+
else if (valueEle != null) {
11801183
error("<entry> element must not contain more than one value sub-element", entryEle);
11811184
}
11821185
else {
@@ -1422,7 +1425,7 @@ public String getLocalName(Node node) {
14221425
/**
14231426
* Determine whether the name of the supplied node is equal to the supplied name.
14241427
* <p>The default implementation checks the supplied desired name against both
1425-
* {@link Node#getNodeName()) and {@link Node#getLocalName()}.
1428+
* {@link Node#getNodeName()} and {@link Node#getLocalName()}.
14261429
* <p>Subclasses may override the default implementation to provide a different
14271430
* mechanism for comparing node names.
14281431
* @param node the node to compare

org.springframework.beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,18 @@
155155
</property>
156156
</bean>
157157

158+
<!-- The <description> element below caused parsing exception prior to resolution of SPR-8563 -->
159+
<bean id="mapWithDescriptionInEntry" class="org.springframework.beans.factory.xml.HasMap">
160+
<property name="map">
161+
<map>
162+
<entry key="e1">
163+
<description>A map entry with a description</description>
164+
<value>v1</value>
165+
</entry>
166+
</map>
167+
</property>
168+
</bean>
169+
158170
<bean id="fooKey" class="java.lang.String">
159171
<constructor-arg value="foo"/>
160172
</bean>

0 commit comments

Comments
 (0)