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

  • From: "m_perdikeas (JIRA)" <jira-no-reply@...>
  • To: issues@...
  • Subject: [JIRA] Created: (JAXB-964) JAXB unmarshalling failing when whitespace is present around token enumerations
  • Date: Fri, 14 Jun 2013 21:41:09 +0000 (UTC)
  • Auto-submitted: auto-generated

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
    }
}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[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 20151030.c1dd42a)
 
 
Close
loading
Please Confirm
Close