Jaxb unmarshalling: how to ignore unknown elements?

Hi,
I use jaxb 1.1 for communication with an external partner. (Took schema, compiled it, used generated classes for unmarshalling like this:
Document doc = /* some document building */
JAXBContext jaxbContext = JAXBContext.newInstance(MyConstants.JAXB_PACKAGE);
Unmarshaller unMarshaller = jaxbContext.createUnmarshaller();
myObject = (MyObject) unMarshaller.unmarshal(doc);) Everything worked fine until they decided to add new elements to their xml-Document without notifiing me (nothing very unusual I think...). Now I get a javax.xml.bind.UnmarshallingException with Message "Unexpected Element". Is there any way to ignore such elements and just take the known Elements from the xml-stream?
Thanks in advance
Thomas

Update your schema with the following after you known elements.
<xs:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>An extension point for arbitrary xml value fragments</xs:documentation>
</xs:annotation>
</xs:any>
Hunter

Similar Messages

  • JAXB unmarshalling error for " " token as part of xsd:string type element

    JAXB unmarshalling error for "<" token as part of xsd:string type element
    We are getting a JAXB unmarshalling error:
    while processing the following <condition> tag which is of type xsd:string
    <condition> x < 100 </condition>
    The error is probably happening due to "<" token as a part of string type.
    xml.bind.JAXBException: Unexpected error in Unmarshalling
    at oracle.xml.jaxb.JaxbUnmarshaller.unmarshal(JaxbUnmarshaller.java:224)
    Any ideas how to resolve this issue?
    Note
    <condition> x > 100 </condition> is getting unmarshalled successfully by JAXB unmarshaller.
    Thanks

    Hi,
    Did you tried to put & lt; (without space) instead of < ?
    Best Regards,
    Paweł

  • JAXB unmarshalling elements with xs:type explicitly set

    I am working with XML content where the XSD defines an element as being of a complexType (say "ParentType") but the content explicitly sets the element's xs:type attribute to an extension of that complexType (say "ChildType").
    As far as I can tell the XML is valid, but JAXB issues the following when unmarshalling:
    DefaultValidationEventHandler: [ERROR]: Unexpected element {}:child1
    javax.xml.bind.UnmarshalException: Unexpected element {}:child1
    Where <child1> is added via the extension.
    Is this a problem with JAXB or my XSD?
    (XSD and XML enclosed below)
    XSD ------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:complexType name="ParentType">
    <xs:sequence>
    <xs:element name="parent1" type="xs:string"/>
    <xs:element name="parent2" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ChildType">
    <xs:complexContent>
    <xs:extension base="ParentType">
    <xs:sequence>
    <xs:element name="child1" type="xs:string"/>
    </xs:sequence>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>
    <xs:element name="root">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="child" type="ParentType"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    XML -----------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="problem.xsd">
    <child xsi:type="ChildType">
    <parent1/>
    <parent2/>
    <child1/>
    </child>
    </root>

    JAXB doesn't handle OO schema design. I tried to do something similar where I defined a type called base and then defined that my document contained 1 or more base elements. Then I tried to unmarshall a document that contained elements that were of types extending from base. I ended up with the same issue.
    It seems that when the xjc compiler defines the classes it isn't smart enough to realize the element defined as parent could also contain a child element since child extends parent. Your XSD and XML are valid.
    I would think that JAXB should identify that because there is a type the extends the defined type, that an element of the sub-type might be subsituted i.e. check the actual type of the element in the XML before attempting to unmarshall it as the default type. It doesn't do that. I am not sure if this is as desinged, or a flaw in the implementation.

  • JAXB Unmarshall Validation Error Handling

    Hello,
    During unmarshalling, if say a required element is missing, a ValidationEvent is created and passed to the handleEvent(ValidationEvent e) method of a custom class implementing the ValidationEventHandler interface.
    From the ValidationEvent, one can get the ValidationEventLocator, which allows you to find out the column and row numbers of where the validation failed in the XML file.
    The problem is, this XML file that is being unmarshalled/marshalled is hidden from the user and not allowed to be accessed directly. I would like to tell the user where the validation failed by referencing nodes instead of column/line numbers.
    For example, if an element called 'foo' requires one child 'bar', and if 'bar' is discovered as missing during unmarshalling, the message that comes with the ValidationEvent will say:
    uncompleted content model. expecting: <bar>
    I don't see a way to find out exactly where in the entire XML file that 'bar' is supposed to occure. How do I find out that the 'bar' element is expected to be under 'foo' element?
    Using the Eclipse debugger, I can see that the parent 'foo' is referenced somewhere deep within the JAXB impl classes, but I don't see any public methods that will allow me to get it.
    Any ideas?
    Thanks,
    AJ

    Try 'ValidationEventLocation.getObject()', and see if you can narrow it down from there.
    I'm also looking for a better solution, since I have a case where a child element is violating it's pattern restrictions, but all I get is a reference to the parent, with no apparent indication as to which child is at fault.

  • JAXB unmarshall problem - beginner

    Hi Im having real pain trying to get unmarshall to work with JAXB with a very simple set up..
    My DTD looks like
    <!ELEMENT CXMLRESULT (MESSAGE)>
    <!ELEMENT MESSAGE (#PCDATA)>
    and xjs like
    <xml-java-binding-schema version="1.0ea">
    <element name="CXMLRESULT" type="class" root="true">
    </xml-java-binding-schema>
    I create an object marshall it and output to a file.. All looks good. This results in the following in the file..
    <CXMLRESULT>
    <MESSAGE>hello</MESSAGE></CXMLRESULT>
    However when I try to read in that file and unmarshall it I run into problems.. Although I receive NO error during the unmarshall, when I do a toString() afterwards then it does not display the MESSAGE element, and similarly trying to validate the object says that MESSAGE hasn't been detected.. I cannot figure out why this is.. The file was written out by JAXB so how come it cant read it back in.. For my unmarshall I do ...
    CXMLRESULT cxmlresult=new CXMLRESULT();
    try{
    try{
    input=new File("/in.xml");
    fileInputStream=new FileInputStream(input);
    } catch (IOException e)
    { System.out.println("error with file"); }
    cxmlresult.unmarshal(fileInputStream);
    } catch(UnmarshalException e) {
    e.printStackTrace();
    System.out.println(cxmlresult.toString());
    Doing this just shows a CXMLRESULT and not the MESSAGE element..
    Any ideas ?
    Mark

    Try this:
    CXMLRESULT cxmlresult = CXMLRESULT.unmarshal(fileInputStream);Dave

  • How to ignore programmatically some items during a query ?

    Hi all,
    The process of my application is like this : first of all the end-user enters some criteria , then he/she presses a button to search for the possible results matching the criteria entered (execute_query). The possible results are displayed through a multirecord based datablock.
    The criteria screen has two parts , say part_a and part_b. When the end-user does not enter any criteria in part_b then the datasource of the results block should be a table , say data_source_1 ; and if some criteria are entered in part_b then the datasource of the results block should be a view , say data_source_2.
    The datasource data_source_1 has less number of columns than the datasource data_source_2 , but all of data_source_1's columns are included into data_source_2.
    So my problem is when the datasource of the results block is set to data_source_1 then there are unknown columns when executing the query (alert error). All of the columns of data_source_2 are included in the results block , and all of the columns of data_source_1 are automatically there because mathematically speaking data_source_1 is included into data_source_2.
    I have tried to use in the pre-query trigger of the results block this statement : set_item_property('results_possibles.column_a',queryable,property_false); but the same error still occurs.
    So how to ignore these items ?
    Thank you very much indeed.

    After looking at what you did to try to solve the problem, I'm not sure what the actual problem is.
    You can make both datasources have the same number of columns by selecting nulls:
    data_source_1: select a, b, c, null as d, null as e from <table>
    data_source_2: select a, b, c, d, e from <view>
    If you have a field which is used to query a column which is included in data_source_2 but not in data_source_1, and that field is populated when you run the query, then just set the block's default_where to ignore that field.
    eg
    data_source_1: where...and c like nvl(:control.c,'%')
    data_source_2: where...and c like nvl(:control.c,'%') and d like nvl(:control.d,'%')...

  • JAXB unmarshalling error

    We are getting a JAXB unmarshalling error:
    while processing the following <condition> tag which is of type xsd:string
    <condition> x < 100 </condition>
    The error is probably happening due to "<" token as a part of string type.
    xml.bind.JAXBException: Unexpected error in Unmarshalling
    at oracle.xml.jaxb.JaxbUnmarshaller.unmarshal(JaxbUnmarshaller.java:224)
    Any ideas how to resolve this issue?
    Note
    <condition> x >100 </condition> is getting unmarshalled successfully by JAXB unmarshaller.
    Thanks

    Hi,
    Did you tried to put & lt; (without space) instead of < ?
    Best Regards,
    Paweł

  • How to ignore blank/null key figure value in BI Queries

    Reports on Multiprovider - we see some cells of a Key figure as blanks. These blanks are interpreted as zeros by the system and calculated accordingly resulting in incorrect values. As per our requirement, we need a count of all hard/real zeros only, not the blanks. For example, if there are 10 rows of which 6 are real zeros and 4 are blanks - our count should be 6 and not 10.
    How to ignore the blanks in BEx queries please?
    Thanks for your help.
    Upender

    Rakesh,
    It is not possible to find a pattern because the report is on a MultiProvider with 2 InfoProviders- Purchasing documents DSO and Material Movements InfoCube.
    Every Purchasing Document has several materials associated with it. These materials are compared with materials in Materials Movement. Not all materials in Purchasing Document are found in Materials Movement. For those Materials found in Materials Movement, the Quantity is obtained. For these found rows, the correct value is showing up - if the quantity is zero, it is showing in reports as zero. If the material is not found in Material Movements then Quantity shows up as blank values.
    My requirement is ignore such blank quantities and not count them. Only Quantities with 0 values should be counted. Currently both blanks and zero values are counted showing inflated count.
    Thanks,
    Upender

  • How can I use Elements as Edit in using a Lightroom?

    How can I use Elements as Edit in in Lightroom using a Lightroom picture. I followed instructions: Photo/Add in/ and received in Elements a blanco screen instead of the picture selected in Lightroom. Please further instructions before ordering Elements 11.

    Dear Andaleeb,
    I have followed instructions as follows: In Lightroom I have installed Elements under extra plug inns. (on top of the screen reference is made  to Photoshop and not Photoshop 11). Under photo, cmd-e does not work since Photoshop is colored gray. As I have Elements installed under extra plug-inns this is highlighted. BUT………..Clicking that, the picture selected does NOT appear in Elements. The screen remains being empty! How can I solve this?
    Mr. F.K.A. de Haan
    Op 4 mrt. 2013, om 14:50 heeft andaleebfatima1 <[email protected]> het volgende geschreven:
    Re: How do I use Elements as a plug in for Lightroom? After plugging no picture appears in Elements!
    created by andaleebfatima1 in Photoshop Elements - View the full discussion
    Please ensure that you have added PSE Editor as external editor for Lightroom. See : http://www.photoshopelementsuser.com/html/integrate-lightroom-with-ele ments/
    Thanks
    Andaleeb
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5119785#5119785
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5119785#5119785
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5119785#5119785. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Photoshop Elements by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How do I move Elements 8 projects (slide shows) from a Windows XP computer to new Windows 7 computer that also has Elements 8 on it so that the slides shows will work (Elements 8 works well on the Windows 7 computer & I have done several new slide show pr

    How do I move Elements 8 projects (slide shows) from a Windows XP computer to new Windows 7 computer that also has Elements 8 on it so that the slides shows will work (Elements 8 works well on the Windows 7 computer & I have done several new slide show projects on it)?    I tried backup & restore without success.  I have also found the .psess files and copied them to the catalog in the new computer but when the sides shows are opened none of the images or music is there.  Only the text that I entered shows.  I have even tried to replicate the file paths from the XP computer to the new computer to see if that will help.

    UPDATE:  By a stroke of luck I happened to find a catalog link (a PSE8D file) in the 'My Catalog' file where the imported data was stored.  When I clicked on it to investigate what is was 'magically' all of my transferred projects appeared in Organizer.  Upon further investigation I found that the projects transferred from my XP computer were stored in a hidden catalog that had to be accessed through the Custom Location option in Catalog Manager (accessed by clicking File then Catalog then Custom Location).  No Windows or Elements search revealed this fact.  I am appreciative that I just got lucky.  The Adode/Photoshop company was absolutely of no help.  If fact to me their structure is designed to avoid contact with their customers unless you're buying a new product.  Their products have many good features (even though user unfriendly) and it's a shame they don't value their customers more once the sale is completed. 
    Bottom line:  All of the projects (sideshows) have been recovered and work in my new Windows 7 computer.  I hope my experience helps others. 

  • How to define default element in SAP-Script?

    Hi Guys,
    How to define default element in SAP-Script?
    Can you tell me to do this...is it possible in all the windows or only in main window?
    Regards,
    GURU

    Hi,
    Welcome to SDN
    You can't post ur questions in other's threads .Open a new thread.
    click on post new thread and open new thread.
    Regards

  • How to translate text elements in forms from type : pdf

    does anybody know how to translate text elements
    in  pdf  from english to other languages.
    i tried the tran. se63 and filled in the desired language,
    but there was no effect on the output ,
    thanks,
    ami

    call this funcation. crate_text.
    CALL FUNCTION 'CREATE_TEXT'
             EXPORTING
               FID               =
               FLANGUAGE         =
               FNAME             =
               FOBJECT           =
             SAVE_DIRECT       = 'X'
             FFORMAT           = '*'
             TABLES
               FLINES            =
           EXCEPTIONS
             NO_INIT           = 1
             NO_SAVE           = 2
             OTHERS            = 3
           IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
           ENDIF.

  • How do I get Elements to occupy full screen on my macbook pro? - the docking station remains visible and I don't want to have the dock in hide mode?

    How do I get Elements to occupy full screen on my macbook pro? - the docking station remains visible and I don't want to have the dock in hide mode?

    Unfortunately, there is no answer to this problem via this link. It may be that this is simply how the software actually works. It is a design fault in Adobe Photoshop Elements. It is possible to temporarily hide the dock within 'system preferences'. Oh well. Someone may know better.... I hope!

  • How to activate WBS Element in Sales Order

    Dear All,
    How to activate WBS element in sales order?
    Thanks & Regards,
    PM

    Basically in case of Repair and overhaul material is taking inside for repair purpose..for that we create service order in which we r creating component, operation(time. labor, machine) besides we create notification to allow overhead activity for this special activity..
    once this service order r created and notification is set.. we r estimating cost for this process and updating sales price(DP82) which further send to customer for approval.. once v receive approval v issue a goods along with parental serviceable material to Plant for Plant maintenance estimation..
    so all this procedure obey just like project , in this case we have to assign WBS element into sales order level..
    WBS elemet is nothing simply its hierarchy which shows what r the steps followed in project(CJ20N)..
    Correct me if i m wrong..
    thanks
    Mk

  • Had Photoshop Elements 12 on my other Mac that recently got smashed, new one has no CD drive. How do I install Elements with my product key? Purchasing an external CD drive is not an option at this time after forking over the 2500 for the new Mac...

    Had Photoshop Elements 12 on my other Mac that recently got smashed, new one has no CD drive. How do I install Elements with my product key? Purchasing an external CD drive is not an option at this time after forking over the 2500 for the new Mac...

    Downloads available:
    Suites and Programs:  CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4 | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  12 | 11, 10 | 9, 8, 7
    Photoshop Elements:  12 | 11, 10 | 9,8,7
    Lightroom:  5.6| 5 | 4 | 3
    Captivate:  8 | 7 | 6 | 5
    Contribute:  CS5 | CS4, CS3
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.

Maybe you are looking for

  • The version number of export file in Java Card 2.2 is not correct

    Hi all, I used jdk1.3.1 and java card 2.2's exp2text tool to see the content of an export file. The value of minor_version is 1. But the JCVM 2.2 spec. says it should be 2. So which one is correct? Joey

  • Disc Drive won't take DVD+RW

    I want to free up some of the space on my macbook, so I'm trying to put some of my photos on a DVD+RW. The Brand is Memorex. At the top it says "rewritable-4X-4.7GB-120min". When I put the disc in the drive, it makes all the usual noises, and sounds

  • When I compress my folder I lose my css styles

    When I compress my folder I lose my css styles Let me give a little bit more information,when and upload from dreamweaver it uploads in the browser with the css styles, but once I compress my folder it loses its styles, any help anybody.

  • Copy within content area

    I am trying to copy a folder which contains sub-folders and files to the root level of a content area. I am doing so from within the navagator. I navigate to the folder I want to copy and click its copy link. I select the root level of the content ar

  • Can't open old logic files

    I recently upgraded to SNow leopard. I have logic pro 9 I tried opening older tracks and they won't open due to the version I made those on logic express 7. Some of those tracks used intakt and battery 2 which now don't work on 10.6 but did on 10.5 L