Re: [JIRA] Commented: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations

  • From: Martin Grebac <martin.grebac@...>
  • To: issues@...
  • Cc: "m_perdikeas (JIRA)" <jira-no-reply@...>, Iaroslav Savytskyi <Iaroslav.Savytskyi@...>
  • Subject: Re: [JIRA] Commented: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations
  • Date: Tue, 25 Jun 2013 13:36:51 +0200
  • Organization: Oracle

Hi,
thanks. FWIW, it's better to communicate directly in the issue than through the issues list. Yardo, would you please update the issue with all information from this thread so that it's useful for others, too? Thanks,
 MartiNG

On 6/24/13 10:28 PM, m_perdikeas (JIRA) wrote:
     [ 
https://java.net/jira/browse/JAXB-964?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=365723#action_365723
 ]

m_perdikeas commented on JAXB-964:
----------------------------------

OK, so I reported it to JAXP as: https://java.net/jira/browse/JAXP-78

JAXB unmarshalling failing when whitespace is present around token 
enumerations
-------------------------------------------------------------------------------

                 Key: JAXB-964
                 URL: https://java.net/jira/browse/JAXB-964
             Project: jaxb
          Issue Type: Bug
          Components: runtime, xjc
    Affects Versions: 2.2.7
         Environment: JDK 1.7.0_21, Ubuntu 12.04.2
            Reporter: m_perdikeas
            Assignee: Iaroslav Savytskyi

SO post on the subject: 
http://stackoverflow.com/questions/17114304/jaxb-unmarshalling-not-tolerating-whitespace-around-token-enumerations
Here's the code that demonstrates the issue, for completeness purposes:
h1.A.xsd
<xs:schema targetNamespace="foo://a"
            xmlns:xs="http://www.w3.org/2001/XMLSchema";
            xmlns="foo://a">
    <xs:element name="type" type="Type"/>
    <xs:simpleType name="Type">
      <xs:restriction base="xs:token">
          <xs:enumeration value="Archive"/>
          <xs:enumeration value="Organisation"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
h1.a.xml
<a:type xmlns:a="foo://a" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="foo://a A.xsd"
Organisation </a:type>
(notice the space after the 'Organisation')
h1.unmarshalling code that fails
import java.io.*;
import javax.xml.XMLConstants;
import javax.xml.bind.*;
import javax.xml.validation.Validator;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Schema;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import a.*;
public class FooMain {
     public static void main(String args[]) throws Exception {
         SchemaFactory schemaFactory = 
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
         JAXBContext payloadContext = JAXBContext.newInstance("a");
         Unmarshaller unmarshaller = payloadContext.createUnmarshaller();
         unmarshaller.setSchema(schemaFactory.newSchema(new Source[]{new 
StreamSource(new FileInputStream(new File("A.xsd")))}));
         unmarshaller.setAdapter(new StringTrimAdapter());
         JAXBElement<?> oUnmarshalled = (JAXBElement<?>) unmarshaller.unmarshal(new 
File("a.xml"));
         Object o = oUnmarshalled.getValue();
         System.out.println("o==null? "+(o==null?"YES":"NO"));
         System.out.println("the type of object is: 
"+o.getClass().getName()); // NPE here
     }
}

--
Martin Grebac, SW Engineering Manager (Metro/JAXWS/JAXB RI)
Oracle Czech, Prague
http://blogs.oracle.com/mgrebac



[JIRA] Created: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations

m_perdikeas (JIRA) 06/14/2013

[JIRA] Commented: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations

laune (JIRA) 06/15/2013

[JIRA] Commented: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations

m_perdikeas (JIRA) 06/15/2013

[JIRA] Commented: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations

Iaroslav Savytskyi (JIRA) 06/17/2013

[JIRA] Closed: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations

Iaroslav Savytskyi (JIRA) 06/17/2013

[JIRA] Commented: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations

m_perdikeas (JIRA) 06/17/2013

[JIRA] Commented: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations

m_perdikeas (JIRA) 06/24/2013

Re: [JIRA] Commented: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations

Martin Grebac 06/25/2013
Terms of Use; Privacy Policy; Copyright ©2013-2016 (revision 20160708.bf2ac18)
 
 
Close
loading
Please Confirm
Close