Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] AbstractSimpleBeanDefinitionParser cannot handle namespace declarations (xmlns= or xmlns:prefix=") attributes on the same element [SPR-4599] #9276

Closed
spring-issuemaster opened this issue Mar 18, 2008 · 2 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Mar 18, 2008

James Strachan opened SPR-4599 and commented

Change the doParse to be this...

protected final void doParse(Element element, BeanDefinitionBuilder builder) {
     NamedNodeMap attributes = element.getAttributes();
     for (int x = 0; x < attributes.getLength(); x++) {
         Attr attribute = (Attr) attributes.item(x);
         String name = attribute.getLocalName();
         String fullName = attribute.getName();
         if (!fullName.startsWith("xmlns:") && !fullName.equals("xmlns") && isEligibleAttribute(name)) {
             String propertyName = extractPropertyName(name);
             Assert.state(StringUtils.hasText(propertyName),
                     "Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty.");
             builder.addPropertyValue(propertyName, attribute.getValue());
         }
     }
     postProcess(builder, element);
 }

Fixes the problem.

Or you could make the current Attr available to the isEligibleAttribute() method call so that folks can do the xmlns exclusion in their own code


Affects: 2.5.2

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Mar 18, 2008

Juergen Hoeller commented

Good point, those should be excluded by default. I've added an "isEligibleAttribute(Attr)" variant, excluding namespace declaration attributes as well as calling "isEligibleAttribute(String)".

This will be available in tonight's 2.5.3 snapshot.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Mar 19, 2008

James Strachan commented

Awesome thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.