castor

XML_NAMING configuration cannot be set programmatically

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.2
  • Fix Version/s: 1.3
  • Component/s: Core
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    1

Description

This code:

public static User unmarshalUser(final java.io.Reader reader)
throws MarshalException, ValidationException { XMLContext context = new XMLContext(); context.setProperty(XMLConfiguration.XML_NAMING, "mixed"); Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setClass(User.class); User user = (User) unmarshaller.unmarshal(reader); return user; }

doesn't work because the XML_NAMING property isn't taking effect at runtime. It can only be set from a properties file.

Issue Links

Activity

Hide
Larry Chu added a comment -

XML_NAMING is org.exolab.castor.xml.naming. Changing the property using the methods XMLContext.setProperty() or Marshaller.setProperty() does not change the XMLNaming strategy as I would have expected. I attached a JUnit test.

Show
Larry Chu added a comment - XML_NAMING is org.exolab.castor.xml.naming. Changing the property using the methods XMLContext.setProperty() or Marshaller.setProperty() does not change the XMLNaming strategy as I would have expected. I attached a JUnit test.
Hide
Joachim Grüneis added a comment -

I think I have a quick solution to solve this...
there are some values - e.g. XMLNaming - that are not instantiated from the property by each access but only the first time; afterwards the preinitialized value is used
the quick solution is to extend the setProperty method to set all those values to null

Show
Joachim Grüneis added a comment - I think I have a quick solution to solve this... there are some values - e.g. XMLNaming - that are not instantiated from the property by each access but only the first time; afterwards the preinitialized value is used the quick solution is to extend the setProperty method to set all those values to null
Hide
Joachim Grüneis added a comment -

The patch at issue 2630 also solves this problem.
Thx for the test I used it as base for my patch.

Show
Joachim Grüneis added a comment - The patch at issue 2630 also solves this problem. Thx for the test I used it as base for my patch.
Hide
Joachim Grüneis added a comment -

The patch which fixes the problem is committed together with the test case.

Show
Joachim Grüneis added a comment - The patch which fixes the problem is committed together with the test case.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: