Browse Source

accepts description subelement within map entry as well (as per the XSD; SPR-8563)

3.0.x
Juergen Hoeller 15 years ago
parent
commit
c0257aba9b
  1. 9
      org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java
  2. 12
      org.springframework.beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1176,7 +1176,10 @@ public class BeanDefinitionParserDelegate { @@ -1176,7 +1176,10 @@ public class BeanDefinitionParserDelegate {
}
else {
// Child element is what we're looking for.
if (valueEle != null) {
if (nodeNameEquals(candidateEle, DESCRIPTION_ELEMENT)) {
// the element is a <description> -> ignore it
}
else if (valueEle != null) {
error("<entry> element must not contain more than one value sub-element", entryEle);
}
else {
@ -1422,7 +1425,7 @@ public class BeanDefinitionParserDelegate { @@ -1422,7 +1425,7 @@ public class BeanDefinitionParserDelegate {
/**
* Determine whether the name of the supplied node is equal to the supplied name.
* <p>The default implementation checks the supplied desired name against both
* {@link Node#getNodeName()) and {@link Node#getLocalName()}.
* {@link Node#getNodeName()} and {@link Node#getLocalName()}.
* <p>Subclasses may override the default implementation to provide a different
* mechanism for comparing node names.
* @param node the node to compare

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

@ -155,6 +155,18 @@ @@ -155,6 +155,18 @@
</property>
</bean>
<!-- The <description> element below caused parsing exception prior to resolution of SPR-8563 -->
<bean id="mapWithDescriptionInEntry" class="org.springframework.beans.factory.xml.HasMap">
<property name="map">
<map>
<entry key="e1">
<description>A map entry with a description</description>
<value>v1</value>
</entry>
</map>
</property>
</bean>
<bean id="fooKey" class="java.lang.String">
<constructor-arg value="foo"/>
</bean>

Loading…
Cancel
Save