users@jaxb.java.net

Re: raw xml in wildcard content

From: StopSpam <swajixa02_at_sneakemail.com>
Date: Mon, 14 Feb 2005 17:05:11 +0100

Kohsuke Kawaguchi wrote:

>StopSpam wrote:

>> Is it possible to read the xml content (or input stream) as presented to
>> the parser between the <XMLData> tags?
>
>Hmm, not really. If XJC doesn't append proper namespaces on DOM
>elements, in general by the time you marshal it out, the meaning of
>those elements may change in an unexpected way.

Right, but in the case of an XML Protocol which envelops other XML data,
it might not be desirable to inherit name spaces and other context into
designated elements. This is also true in my case, where the xml wild card
content inside the XMLData element should be independent.

For a more detailed explanation of the problem please refer to
http://www.w3.org/TR/xml-exc-c14n/#sec-ExclusiveNeed

Btw. how is this solved for SOAP? I'm not too much into SOAP, but my problem
seems similar to SOAP envelopes and I think jaxrpc also uses jaxb.

>If you need to keep the original infoset intact, you can first unmarshal
>the whole document to DOM, then unmarshal it into JAXB. That way, you
>can perform the signature verification against DOM.

Thanks a lot for the fast reply and I think this might be possible,
but the problem to extract a node without it's context remains.
However Document.adoptNode() might do the trick.

>We are thinking about adding a feature in the 2.0 RI so that when you do
>this, you can jump between JAXB object <-> DOM nodes more easily.

>Is this something that would help your case? Or not really?

Not sure if this would help, as the name space and context problem would remain.

What really would help is a raw (or plain text) binding like:

<xs:element name="XMLData" type="AnyXMLType"/>

<xs:complexType name="AnyXMLType">
   <xs:sequence>
      <xs:any processContents="lax" maxOccurs="unbounded">
      
         <xs:annotation>
            <xs:appinfo>
               <xjc:raw/>
            </xs:appinfo>
         </xs:annotation>
      
      </xs:any>
   </xs:sequence>
</xs:complexType>

That allows to access the plain data between the XMLData Tags.

Also a method like
"marshaller.marshalExclusive(XMLDataElement,System.out);"
or
"marshaller.marshalExclusive(XMLDataElement.getAny(),System.out);"
that marshalls a subset of an xml document as if it where
independent of the rest of the document would enhance flexibility.

many thanks

Konrad Lanz
Konrad(dot)Lanz[AT]iaik{dot}at

P.S.: Is it possible to do the dom binding from a customization
file as well, and how is the Syntax?