XStream
  1. XStream
  2. XSTR-643

Can't read Attribute with jaxp (spring batch integration)

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: 1.3.1
    • Fix Version/s: None
    • Component/s: IO
    • Labels:
      None
    • JDK version and platform:
      sun jdk 1.6_21

      Description

      Context:
      I was trying to map an attribute in an xml file (with no namespace) to a field in an object using spring batch integration with Xtream
      I use the @XStreamAsAttribute annotation

      It works if I launch xstream directly (it use the xpp parser)
      It doesn't work if I launch xstream throught spring batch integration because it use stax parser.

      Why:
      The spring batch integration is done using spring XstreamMarshaller that use xstream StaxReader

      The stax parser validate that attribute match namespace, see org.springframework.xml.stream.AbstractXmlStreamReader ligne 152

      When trying to fetch an attribute StaxReader.getAttribute(String name) is called with a null namespace
      return in.getAttributeValue(null, name);

      => always return null when used with the stax parser.

      Solution:
      In the StaxReader class replace
      return in.getAttributeValue(null, name);
      with
      return in.getAttributeValue("", name);

      Note:
      I was able to override the StaxReader and the XStreamMarshaller class and configure and overrided XStreamMarshaller in spring to make it work

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Aurélien Pelletier
        • Votes:
          0 Vote for this issue
          Watchers:
          2 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: