xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] Serialize selected elements to a Writer.
- From: Tatu Saloranta <cowtowncoder AT yahoo.com>
- To: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] Serialize selected elements to a Writer.
- Date: Fri, 13 Oct 2006 17:41:44 -0700 (PDT)
--- Wolfgang Hoschek <wolfgang.hoschek AT mac.com> wrote:
>
> On Oct 13, 2006, at 2:22 PM, Wolfgang Hoschek wrote:
>
> > On Oct 13, 2006, at 8:27 AM, David Bullock wrote:
> >
...
> >> probably go with StAX instead, but I found
> Node.query(String xpath)
> >> compelling enough to stay with XOM for now (I
> guess that means that
> >> actually
> >> I would migrate to TrAX rather than StAX). I
Or maybe not, if you care about minimal memory usage?
XOM should be good, if full-tree model is acceptable;
and full power of XSLT and XPath tend to require full
in-memory model (there are some clever optimization
some impls do to alleviate situation, which may work
for subset of functionality though).
However, besides going to Stax full speed (ie. only
using streaming model for input and/or output),
like Wolfgang points out, Stax serializers may
have bit more features than XOM has. Usually
there's no big difference but wrt. using Writers
there is. Specifically:
...
> However, there's no standard way to detect the
> encoding used by a
> generic java.io.Writer or XMLStreamWriter. And StaX
This may not be applicable here, but there is
OutputStreamWriter.getEncoding()
which is sometimes useful. Woodstox Stax processor
does check that automatically (and make use of it),
but if the Writer you get doesn't extend it, it's not
of much use.
It is unfortunate that Stax 1.0 API does not have
method for passing encoding with Writer -- this
is probably an accidental omission, since on input
side, there is a way to pass encoding with Reader.
> has no standard
> factory method for java.io.Writer that takes an
> encoding, such as
> createXMLStreamWriter(java.io.Writer, String
> encoding).
>
> OutputStream remains a more reliable option than
> java.io.Writer. It
> also tends to be more efficient.
Definitely. The only other thing I would say is
that if David must use a Writer, there are
implementation-specific additional features
in Woodstox that would allow proper quoting
of content written using a Writer. So it is
possible to use XOM, and yet correctly and
reliably output it to xml, using Woodstox Stax
processor (if so, let me know, or ask on woodstox
mailing list -- this doesn't have much to do with
Xom so I don't want to talk too much about it).
This is not as optimal as using an OutputStream,
but is at least possible.
-+ Tatu +-
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-
Re: [XOM-interest] Serialize selected elements to a Writer.
, (continued)
-
Re: [XOM-interest] Serialize selected elements to a Writer.,
David Bullock, 10/13/2006
-
Re: [XOM-interest] Serialize selected elements to a Writer.,
Elliotte Harold, 10/13/2006
- Re: [XOM-interest] Serialize selected elements to a Writer., Michael Kay, 10/14/2006
-
Re: [XOM-interest] Serialize selected elements to a Writer.,
David Bullock, 10/16/2006
-
Re: [XOM-interest] Serialize selected elements to a Writer.,
Ed Davies, 10/16/2006
- Re: [XOM-interest] Serialize selected elements to a Writer., Michael Kay, 10/16/2006
- Re: [XOM-interest] Serialize selected elements to a Writer., Tatu Saloranta, 10/17/2006
-
Re: [XOM-interest] Serialize selected elements to a Writer.,
Ed Davies, 10/16/2006
-
Re: [XOM-interest] Serialize selected elements to a Writer.,
Elliotte Harold, 10/13/2006
- Re: [XOM-interest] Serialize selected elements to a Writer., Elliotte Harold, 10/13/2006
-
Re: [XOM-interest] Serialize selected elements to a Writer.,
Wolfgang Hoschek, 10/13/2006
-
Re: [XOM-interest] Serialize selected elements to a Writer.,
Wolfgang Hoschek, 10/13/2006
- Re: [XOM-interest] Serialize selected elements to a Writer., Tatu Saloranta, 10/13/2006
-
Re: [XOM-interest] Serialize selected elements to a Writer.,
Wolfgang Hoschek, 10/13/2006
-
Re: [XOM-interest] Serialize selected elements to a Writer.,
David Bullock, 10/13/2006
Archive powered by MHonArc 2.6.24.