Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » eclipselink moxy xml-path binding file not skipping element(xml-path binding failing with unexpected element)
eclipselink moxy xml-path binding file not skipping element [message #1116914] Thu, 26 September 2013 00:18 Go to next message
Swarup Eda is currently offline Swarup Eda
Messages: 1
Registered: September 2013
Junior Member
I was expecting by using xml-path that it skips elements when required to be ignored, but it doesn't seem to be doing that. Am I missing something?



It should be ignoring the nested element "responseHeader"
Please see below error, binding file, model samples

Error:

Caused by: org.xml.sax.SAXParseException: unexpected element (uri:"", local:"responseHeader"). Expected elements are <{}response>
    at org.eclipse.persistence.internal.oxm.record.UnmarshalRecordImpl.startUnmappedElement(UnmarshalRecordImpl.java:957)
    at org.eclipse.persistence.internal.oxm.record.UnmarshalRecordImpl.startElement(UnmarshalRecordImpl.java:814)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)


Here's the xml input

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href=""?>
<response xmlns:xsi=""
 xsi:noNamespaceSchemaLocation="">
<responseHeader>
<status>0</status>
<sql>select * from csource_WEEKBOX LIMIT 0,20</sql>
<numFields>15</numFields>
<numRecords>10</numRecords>
<QTime>0</QTime>
</responseHeader>
<responseBody>
<record>
<field type="integer">
<name>rank</name>
<value>1</value>
</field>
<field type="integer">
<name>movieid</name>
<value>143966</value>
</field>
<field type="integer">
<name>mf_mid</name>
<value>58759</value>
</field>
<field type="string">
<name>movietitle</name>
<value>Prisoners</value>
</field>
<field type="integer">
<name>previous</name>
<value>0</value>
</field>
<field type="integer">
<name>gross</name>
<value>21430000</value>
</field>
<field type="integer">
<name>grosschange</name>
<value>0</value>
</field>
<field type="integer">
<name>number</name>
<value>3260</value>
</field>
<field type="integer">
<name>numberchange</name>
<value>0</value>
</field>
<field type="integer">
<name>average</name>
<value>6574</value>
</field>
<field type="integer">
<name>cume</name>
<value>21430000</value>
</field>
<field type="integer">
<name>weeks</name>
<value>1</value>
</field>
<field type="integer">
<name>batchNumber</name>
<value>104323</value>
</field>
<field type="string">
<name>rowStatus</name>
<value>I</value>
</field>
<field type="date">
<name>updateDateTime</name>
<value>2013-09-24 11:08:34</value>
</field>
</record>
<record>
...


binding file:

<?xml version="1.0"?>
<xml-bindings 
        xmlns=""
        version="2.1" package-name="com.dao">
    <java-types>
        <java-type name="DaoResult">
            <xml-root-element name="response"/>
            <xml-type prop-order="results"/>
            <java-attributes>
                <xml-element java-attribute="results" xml-path="responseBody/record" type="com.aol.pxy.movies.model.WeekBox" container-type="java.util.List"/>
                <xml-transient java-attribute="totalCount"/>
                <xml-transient java-attribute="cachedTime"/>
                <xml-transient java-attribute="firstResult"/>
                <xml-transient java-attribute="inputQuery"/>
                <xml-transient java-attribute="paginationHandle"/>
            </java-attributes>
        </java-type>
    </java-types>
</xml-bindings>


Model class:

public class DaoResult<T>  extends AbstractModel implements Serializable {

    private static final long serialVersionUID = -6369563906973225250L;

    @XmlTransient
    private String inputQuery;

    @Deprecated
    private Integer count = -1;

    private Integer totalCount;

    private List<T> results;

    private String paginationHandle;

    private Date cachedTime = new Date();
Re: eclipselink moxy xml-path binding file not skipping element [message #1118605 is a reply to message #1116914] Fri, 27 September 2013 15:25 Go to previous message
Denise Smith is currently offline Denise Smith
Messages: 11
Registered: July 2009
Junior Member
Hi

Do you possibly have your own ValidationEventHandler specified on the JAXB Unmarshaller? The unmarshal will report errors for unexpected elements but our default event handler ignores those. The only way I could recreate this issue was to specify a custom event handler that fails on these errors (so behaves differently from our default event handler).

Denise
Previous Topic:Is it possible to define everything for Composite Persistent Units in one persistence.xml ?
Next Topic:How to use Moxy
Goto Forum:
  


Current Time: Wed Sep 24 00:42:17 GMT 2014

Powered by FUDForum. Page generated in 0.04664 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software