dev@fi.java.net

Re: JAXB and of base64 data and FI

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 02 Aug 2005 11:13:02 +0200

Kohsuke Kawaguchi wrote:
>
> Thanks for the changes. They were merged.
>

Great. Many thanks.


> Paul Sandoz wrote:
>
>> The implementations are currently very specific to the Base64Data
>> class and will not scale very well when supporting a number of
>> different data types. We will need a better way to supports types
>> (single instances and in certain cases arrays of) for both serializing
>> and parsing in the future
>
>
> Right.
>
>> The FastInfosetConnector class is currently FI StAX specific. In the
>> future it does not have to be. I can see how to optimize specifically
>> for JAXB e.g. to avoid buffering until the end of the element, and not
>> to decode stuff like comments and PI which can be just skipped.
>
>
> I'm not sure if I follow this. Are you saying that you can do those
> optimizations with any StAX parser?
>

No, not with the StAX API.

I can write a SAX like push parser to specifically push the required
events to the XMLVisitor. Using this approach may have a number of
advantages. Since this will essentially be an internally controlled loop
with most state based stuff on the stack the hotspot should optimize it
quite well.

The tricky bit with this approach is merging the pull of JAX-WS for
processing the SOAP message infoset and the pull of JAXB. I think it can
be done but it makes for a rather odd parser.

Such techniques may also be possible with a hybrid XML parser. FI
parsers tend to be quite light weight and there are certain tricks with
the encoding that help, which makes this sort of thing easier to do. For
an XML parser it might be more complex.


>> The serializing side of things should be quite stable as most code is
>> rused. The parsing side may be less so because it is new code. I am
>> not sure how best we can test both the parser and serializer. Can
>> existing JAXB tests be used with FI?
>
>
> If we have instance documents, I think we can. Is there any "FI encoder"
> tool?
>

Yes. There are two options:

1) Use the UNIX script, fi/FastInfoset/bin/xmltosaxtofi

xmltosaxtofi <input> <output>
-----------------------------
Parses an XML document and transforms it into an equivalent fast infoset
document using the FI SAX serializer.
         The 'input' shall be a XML document file.
         If the input is ommited then the standard input is used.
         The 'output' is the resulting fast infoset document file.
         If the output is ommited then the standard output is used.

2) Use the Java class, com.sun.xml.fastinfoset.tools.XML_SAX_FI:

https://fi.dev.java.net/source/browse/fi/FastInfoset/src/com/sun/xml/fastinfoset/tools/XML_SAX_FI.java?rev=1.2&view=auto&content-type=text/vnd.viewcvs-markup

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109