3 Replies Latest reply on Jul 12, 2007 11:09 AM by Scott Stark

    jaxb whitepsace handling

    Scott Stark Master

      Is there a way to get jaxb to trim string data? I'm seeing a problem with the parsing of the jmx or the connection-factories/tx-connection-factory/connection-definition is failing to be mapped correctly because it contains the newlines from the xml:


      Also, the fields for the associated TxConnectionFactoryDeploymentMetaData are set directly rather than going through the javabean accessors, so I can't intercept and trim there. Is there a way to change the whitespace handling for a field?

        • 1. Re: jaxb whitepsace handling
          Alexey Loubyansky Master

          Is this really JAXB or JBossXB?

          JBossXB used to trim whitespaces by default. But then we had this thread http://www.jboss.com/index.html?module=bb&op=viewtopic&t=110310

          • 2. Re: jaxb whitepsace handling
            Adrian Brock Master

            The example you post is NOT valid, you're missing the
            managed-connection-factory-class element.

            Have you enabled validation on the parser?

            You'll need it if you want whitespace collpasing by the parser
            because its gots to read the schema to find out the datatype.

            e.g. in your case it should be


            managed-connection-factory-class is a j2ee:fully-qualified-classType
            which is a j2ee:string which is a token.

            See javaee.xsd
             <xsd:complexType name="string">
             This is a special string datatype that is defined by Java EE as
             a base type for defining collapsed strings. When schemas
             require trailing/leading space elimination as well as
             collapsing the existing whitespace, this base type may be
             <xsd:extension base="xsd:token">
             <xsd:attribute name="id" type="xsd:ID"/>

            • 3. Re: jaxb whitepsace handling
              Scott Stark Master

              Its the tx-connection-factories-ds.xml that is being parsed, not the ra.xml so there is no schema associated with the file. I was able to resolve the issue by using the existing javax.xml.bind.annotation.adapters.CollapsedStringAdapter type adapter:

               /** The connectionDefinition */
               protected String connectionDefinition;