JAXB doesn't parse valid(?) XML

12 Views Asked by At

I am writing a SOAP client. The server is minidlna/readymedia and implements uPnP/DLNA. I would like to use JAX-WS – it seems an obvious choice for this type of SOAP application.

A typical server response is:

<?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <s:Body>
            <u:SearchResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
                <Result>
                    <DIDLLite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDLLite/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/">
                        <container id="2$8" parentID="2" restricted="1" searchable="1" childCount="12">
                             <dc:title>All Video</dc:title>
                             <upnp:class>object.container.storageFolder</upnp:class>
                             <upnp:storageUsed>-1</upnp:storageUsed>
                        </container>
                    </DIDLLite>
                </Result>
            <NumberReturned>3</NumberReturned>
            <TotalMatches>3</TotalMatches>
            <UpdateID>6</UpdateID>
        </u:SearchResponse>
    </s:Body>
</s:Envelope>

Unfortunately JAXB parser fails to parse the line:

<DIDLLite .... xmlns="urn:schemas-upnp-org:metadata-1-0/DIDLLite/" .... >

Instead it interprets all of the <DIDLLite .... /DIDLLite> as a single, text, value for the Result tag.

If I edit the problem tag to:

<DIDLLite .... xmlns:z="urn:schemas-upnp-org:metadata-1-0/DIDLLite/" .... >

The problem does not occur.

The problem does not exist with the SAX or DOM parsers which parse the whole of the XML as expected.

Is there a way to get JAXB to accept this XML?

0

There are 0 best solutions below