You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Dick Deneer <di...@donkeydevelopment.com> on 2009/11/20 23:36:36 UTC

Loosing significant space in LSSerializer

I am still using the deprecated LSSerializer  because the xalan  
serializer has issues with the pretty print.
But when I have simple elements with only space, the serializer  
produces empty elements. Is there a tweak to keep the spaces in this  
elements?

Sample xml:
<root><child1>text</child1><child2>   </child2></root>
I attached a simple test program, that you can just run to see the  
results:

Program started
Xerces serializer will be used
<?xml version="1.0" encoding="UTF-16"?>
<root>
     <child1>text</child1>
     <child2/>
</root>

Xalan serializer will be used
<?xml version="1.0" encoding="UTF-16"?><root>
    <child1>text</child1>
    <child2>   </child2>
</root>

Regards
Dick Deneer

Re: Loosing significant space in LSSerializer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Right, that's exactly how it works:

    public LSSerializer createLSSerializer() {
        try {
            Class serializerClass = ObjectFactory.findProviderClass(
                "org.apache.xml.serializer.dom3.LSSerializerImpl",
                ObjectFactory.findClassLoader(), true);
            return (LSSerializer) serializerClass.newInstance();
        }
        catch (Exception e) {}
        // Fall back to Xerces' deprecated serializer if
        // the Xalan based serializer is unavailable.
        return new DOMSerializerImpl();
    }

Was hoping to put a warning in there if it takes the fallback path but
there's no DOMErrorHandler to report it to at this point.

FYI: If you don't have Xerces on the classpath but instead try to access
the JDK version [1] you may not get very far.

Thanks.

[1] http://markmail.org/message/e6rlhwymr43p4u4v

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Dick Deneer <di...@donkeydevelopment.com> wrote on 11/22/2009
04:06:06 PM:

> Hi Benson,
>
> As Michael notes, Xerces is now shipped with the serializer.jar
> (which contains the xalan serializer). If you have this on your
> classpath it will be used.
> If you leave it out, then xerces will fall back to it's own (deprecated)
one.
>
> regards
> Dick Deneer
> Op 22-nov-2009, om 21:54 heeft Benson Margulies het volgende geschreven:
>
> Hi Michael,
>
> So, if I put Xerces and not Xalan into classpath, and ask a document
> for it's implementation, and ask that for the DOMImplementationLS,
> what do I get? Whatever Sun tossed into the pot? And if I then add
> Xalan, do I get the right one?
>
> --benson
>

> On Sat, Nov 21, 2009 at 10:24 PM, Michael Glavassevich
<mrglavas@ca.ibm.com
> > wrote:
> Hi Benson,
>
> We're talking about two different implementations of the DOM Level 3
> LSSerializer, the more recently developed one in Xalan
> (serializer.jar which Xerces now ships and shares with Xalan) and
> the much older deprecated one in Xerces. If you're curious about the
> history on that, there's an FAQ [1] on the website.
>
> Some users have decided to keep using Xerces' deprecated serializer
> due to some quirks and issues with the currently available one from
> Xalan. Folks really should be opening JIRA issues [2] against Xalan,
> so those problems get addressed there. There's no intention to do
> any further development or fixes to the one in Xerces.
>
> Thanks.
>
> [1] http://xerces.apache.org/xerces2-j/faq-general.html#faq-6
> [2] https://issues.apache.org/jira/browse/XALANJ
>
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org

> Benson Margulies <bi...@gmail.com> wrote on 11/21/2009 02:17:49 PM:
>
>
> > Could I please ask for a bit of clarification? The only LSSerializer
> > I'm aware of is the DOM level 3 stuff, which, I thought, was the
> > opposite of obsolete. As someone pointed out here, unlike TraX, it
> > will serialize doctypes and do other handy things. In general, I'm
> > beginning to prefer the DOMImplementationLS to JAXP and TraX.
>
> > On Sat, Nov 21, 2009 at 2:07 PM, Michael Glavassevich
<mrglavas@ca.ibm.com
> > > wrote:
> > You should also be able to control whether spaces are preserved by
> > registering an LSSerializerFilter.
> >
> > When I added one to your test program:
> >
> >         if (useXerces)
> >         {
> >             domWriter = new DOMSerializerImpl();
> >             domWriter.setFilter(new LSSerializerFilter() {
> >                 public int getWhatToShow() {
> >                     return LSSerializerFilter.SHOW_ALL;
> >                 }
> >                 public short acceptNode(Node n) {
> >                     return LSSerializerFilter.FILTER_ACCEPT;
> >                 }});
> >         }
> >
> > the output I get is:
> >
> >
> > Program started
> > Xerces serializer will be used
> > <?xml version="1.0" encoding="UTF-16"?>
> > <root>
> > <child1>text</child1>
> > <child2> </child2>
> >
> > </root>
> >
> > Xalan serializer will be used
> > <?xml version="1.0" encoding="UTF-16"?><root>
> > <child1>text</child1>
> > <child2> </child2>
> > </root>
>
> > which I believe is what you were expecting.
> >
> > Thanks.
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> >
> > Dick Deneer <di...@donkeydevelopment.com> wrote on 11/21/2009
> > 01:19:27 PM:
> >
> >
> > > Hi Jake,
> > >
> > >
> > > I just tried your suggestion and the spaces are indeed preserved.
> > > But still, I woud prefer another solution. I do not have any clue
> > > about the xml (I use xerces in a xml editor) and I do not want to
> > > change the xml.
> > > And also I would like to stay with the LSSerializer (it also
> > > serilalizes doctype nodes).
> > > If there is another way please let me know.
> > >
> > > Thanks
> > > Dick Deneer
> > >
> > >
> > >
> > > Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:
> > >
> > > > Have you tried xml:space="preserve"?
> > > >
> > > > Jake
> > > >
> > > > On 11/20/2009 4:36 PM, Dick Deneer wrote:
> > > >> I am still using the deprecated LSSerializer because the xalan
> > > >> serializer has issues with the pretty print.
> > > >> But when I have simple elements with only space, the serializer
> > > >> produces
> > > >> empty elements. Is there a tweak to keep the spaces in this
elements?
> > > >>
> > > >> Sample xml:
> > > >> <root><child1>text</child1><child2> </child2></root>
> > > >> I attached a simple test program, that you can just run to see the

> > > >> results:
> > > >>
> > > >> Program started
> > > >> Xerces serializer will be used
> > > >> <?xml version="1.0" encoding="UTF-16"?>
> > > >> <root>
> > > >> <child1>text</child1>
> > > >> <child2/>
> > > >> </root>
> > > >>
> > > >> Xalan serializer will be used
> > > >> <?xml version="1.0" encoding="UTF-16"?><root>
> > > >> <child1>text</child1>
> > > >> <child2> </child2>
> > > >> </root>
> > > >>
> > > >> Regards
> > > >> Dick Deneer
> > > >>
> > > >>
---------------------------------------------------------------------
> > > >> ---
> > > >>
> > > >
> > > >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org

Re: Loosing significant space in LSSerializer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Right, that's exactly how it works:

    public LSSerializer createLSSerializer() {
        try {
            Class serializerClass = ObjectFactory.findProviderClass(
                "org.apache.xml.serializer.dom3.LSSerializerImpl",
                ObjectFactory.findClassLoader(), true);
            return (LSSerializer) serializerClass.newInstance();
        }
        catch (Exception e) {}
        // Fall back to Xerces' deprecated serializer if
        // the Xalan based serializer is unavailable.
        return new DOMSerializerImpl();
    }

Was hoping to put a warning in there if it takes the fallback path but
there's no DOMErrorHandler to report it to at this point.

FYI: If you don't have Xerces on the classpath but instead try to access
the JDK version [1] you may not get very far.

Thanks.

[1] http://markmail.org/message/e6rlhwymr43p4u4v

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Dick Deneer <di...@donkeydevelopment.com> wrote on 11/22/2009
04:06:06 PM:

> Hi Benson,
>
> As Michael notes, Xerces is now shipped with the serializer.jar
> (which contains the xalan serializer). If you have this on your
> classpath it will be used.
> If you leave it out, then xerces will fall back to it's own (deprecated)
one.
>
> regards
> Dick Deneer
> Op 22-nov-2009, om 21:54 heeft Benson Margulies het volgende geschreven:
>
> Hi Michael,
>
> So, if I put Xerces and not Xalan into classpath, and ask a document
> for it's implementation, and ask that for the DOMImplementationLS,
> what do I get? Whatever Sun tossed into the pot? And if I then add
> Xalan, do I get the right one?
>
> --benson
>

> On Sat, Nov 21, 2009 at 10:24 PM, Michael Glavassevich
<mrglavas@ca.ibm.com
> > wrote:
> Hi Benson,
>
> We're talking about two different implementations of the DOM Level 3
> LSSerializer, the more recently developed one in Xalan
> (serializer.jar which Xerces now ships and shares with Xalan) and
> the much older deprecated one in Xerces. If you're curious about the
> history on that, there's an FAQ [1] on the website.
>
> Some users have decided to keep using Xerces' deprecated serializer
> due to some quirks and issues with the currently available one from
> Xalan. Folks really should be opening JIRA issues [2] against Xalan,
> so those problems get addressed there. There's no intention to do
> any further development or fixes to the one in Xerces.
>
> Thanks.
>
> [1] http://xerces.apache.org/xerces2-j/faq-general.html#faq-6
> [2] https://issues.apache.org/jira/browse/XALANJ
>
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org

> Benson Margulies <bi...@gmail.com> wrote on 11/21/2009 02:17:49 PM:
>
>
> > Could I please ask for a bit of clarification? The only LSSerializer
> > I'm aware of is the DOM level 3 stuff, which, I thought, was the
> > opposite of obsolete. As someone pointed out here, unlike TraX, it
> > will serialize doctypes and do other handy things. In general, I'm
> > beginning to prefer the DOMImplementationLS to JAXP and TraX.
>
> > On Sat, Nov 21, 2009 at 2:07 PM, Michael Glavassevich
<mrglavas@ca.ibm.com
> > > wrote:
> > You should also be able to control whether spaces are preserved by
> > registering an LSSerializerFilter.
> >
> > When I added one to your test program:
> >
> >         if (useXerces)
> >         {
> >             domWriter = new DOMSerializerImpl();
> >             domWriter.setFilter(new LSSerializerFilter() {
> >                 public int getWhatToShow() {
> >                     return LSSerializerFilter.SHOW_ALL;
> >                 }
> >                 public short acceptNode(Node n) {
> >                     return LSSerializerFilter.FILTER_ACCEPT;
> >                 }});
> >         }
> >
> > the output I get is:
> >
> >
> > Program started
> > Xerces serializer will be used
> > <?xml version="1.0" encoding="UTF-16"?>
> > <root>
> > <child1>text</child1>
> > <child2> </child2>
> >
> > </root>
> >
> > Xalan serializer will be used
> > <?xml version="1.0" encoding="UTF-16"?><root>
> > <child1>text</child1>
> > <child2> </child2>
> > </root>
>
> > which I believe is what you were expecting.
> >
> > Thanks.
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> >
> > Dick Deneer <di...@donkeydevelopment.com> wrote on 11/21/2009
> > 01:19:27 PM:
> >
> >
> > > Hi Jake,
> > >
> > >
> > > I just tried your suggestion and the spaces are indeed preserved.
> > > But still, I woud prefer another solution. I do not have any clue
> > > about the xml (I use xerces in a xml editor) and I do not want to
> > > change the xml.
> > > And also I would like to stay with the LSSerializer (it also
> > > serilalizes doctype nodes).
> > > If there is another way please let me know.
> > >
> > > Thanks
> > > Dick Deneer
> > >
> > >
> > >
> > > Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:
> > >
> > > > Have you tried xml:space="preserve"?
> > > >
> > > > Jake
> > > >
> > > > On 11/20/2009 4:36 PM, Dick Deneer wrote:
> > > >> I am still using the deprecated LSSerializer because the xalan
> > > >> serializer has issues with the pretty print.
> > > >> But when I have simple elements with only space, the serializer
> > > >> produces
> > > >> empty elements. Is there a tweak to keep the spaces in this
elements?
> > > >>
> > > >> Sample xml:
> > > >> <root><child1>text</child1><child2> </child2></root>
> > > >> I attached a simple test program, that you can just run to see the

> > > >> results:
> > > >>
> > > >> Program started
> > > >> Xerces serializer will be used
> > > >> <?xml version="1.0" encoding="UTF-16"?>
> > > >> <root>
> > > >> <child1>text</child1>
> > > >> <child2/>
> > > >> </root>
> > > >>
> > > >> Xalan serializer will be used
> > > >> <?xml version="1.0" encoding="UTF-16"?><root>
> > > >> <child1>text</child1>
> > > >> <child2> </child2>
> > > >> </root>
> > > >>
> > > >> Regards
> > > >> Dick Deneer
> > > >>
> > > >>
---------------------------------------------------------------------
> > > >> ---
> > > >>
> > > >
> > > >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org

Re: Loosing significant space in LSSerializer

Posted by Dick Deneer <di...@donkeydevelopment.com>.
Hi Benson,

As Michael notes, Xerces is now shipped with the serializer.jar  
(which contains the xalan serializer). If you have this on your  
classpath it will be used.
If you leave it out, then xerces will fall back to it's own  
(deprecated) one.

regards
Dick Deneer
Op 22-nov-2009, om 21:54 heeft Benson Margulies het volgende geschreven:

> Hi Michael,
>
> So, if I put Xerces and not Xalan into classpath, and ask a  
> document for it's implementation, and ask that for the  
> DOMImplementationLS, what do I get? Whatever Sun tossed into the  
> pot? And if I then add Xalan, do I get the right one?
>
> --benson
>
>
> On Sat, Nov 21, 2009 at 10:24 PM, Michael Glavassevich  
> <mr...@ca.ibm.com> wrote:
> Hi Benson,
>
> We're talking about two different implementations of the DOM Level  
> 3 LSSerializer, the more recently developed one in Xalan  
> (serializer.jar which Xerces now ships and shares with Xalan) and  
> the much older deprecated one in Xerces. If you're curious about  
> the history on that, there's an FAQ [1] on the website.
>
> Some users have decided to keep using Xerces' deprecated serializer  
> due to some quirks and issues with the currently available one from  
> Xalan. Folks really should be opening JIRA issues [2] against  
> Xalan, so those problems get addressed there. There's no intention  
> to do any further development or fixes to the one in Xerces.
>
> Thanks.
>
> [1] http://xerces.apache.org/xerces2-j/faq-general.html#faq-6
> [2] https://issues.apache.org/jira/browse/XALANJ
>
>
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Benson Margulies <bi...@gmail.com> wrote on 11/21/2009  
> 02:17:49 PM:
>
>
> > Could I please ask for a bit of clarification? The only LSSerializer
> > I'm aware of is the DOM level 3 stuff, which, I thought, was the
> > opposite of obsolete. As someone pointed out here, unlike TraX, it
> > will serialize doctypes and do other handy things. In general, I'm
> > beginning to prefer the DOMImplementationLS to JAXP and TraX.
>
> > On Sat, Nov 21, 2009 at 2:07 PM, Michael Glavassevich  
> <mrglavas@ca.ibm.com
> > > wrote:
> > You should also be able to control whether spaces are preserved by
> > registering an LSSerializerFilter.
> >
> > When I added one to your test program:
> >
> >         if (useXerces)
> >         {
> >             domWriter = new DOMSerializerImpl();
> >             domWriter.setFilter(new LSSerializerFilter() {
> >                 public int getWhatToShow() {
> >                     return LSSerializerFilter.SHOW_ALL;
> >                 }
> >                 public short acceptNode(Node n) {
> >                     return LSSerializerFilter.FILTER_ACCEPT;
> >                 }});
> >         }
> >
> > the output I get is:
> >
> >
> > Program started
> > Xerces serializer will be used
> > <?xml version="1.0" encoding="UTF-16"?>
> > <root>
> > <child1>text</child1>
> > <child2> </child2>
> >
> > </root>
> >
> > Xalan serializer will be used
> > <?xml version="1.0" encoding="UTF-16"?><root>
> > <child1>text</child1>
> > <child2> </child2>
> > </root>
>
> > which I believe is what you were expecting.
> >
> > Thanks.
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> >
> > Dick Deneer <di...@donkeydevelopment.com> wrote on 11/21/2009
> > 01:19:27 PM:
> >
> >
> > > Hi Jake,
> > >
> > >
> > > I just tried your suggestion and the spaces are indeed preserved.
> > > But still, I woud prefer another solution. I do not have any clue
> > > about the xml (I use xerces in a xml editor) and I do not want to
> > > change the xml.
> > > And also I would like to stay with the LSSerializer (it also
> > > serilalizes doctype nodes).
> > > If there is another way please let me know.
> > >
> > > Thanks
> > > Dick Deneer
> > >
> > >
> > >
> > > Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende  
> geschreven:
> > >
> > > > Have you tried xml:space="preserve"?
> > > >
> > > > Jake
> > > >
> > > > On 11/20/2009 4:36 PM, Dick Deneer wrote:
> > > >> I am still using the deprecated LSSerializer because the xalan
> > > >> serializer has issues with the pretty print.
> > > >> But when I have simple elements with only space, the serializer
> > > >> produces
> > > >> empty elements. Is there a tweak to keep the spaces in this  
> elements?
> > > >>
> > > >> Sample xml:
> > > >> <root><child1>text</child1><child2> </child2></root>
> > > >> I attached a simple test program, that you can just run to  
> see the
> > > >> results:
> > > >>
> > > >> Program started
> > > >> Xerces serializer will be used
> > > >> <?xml version="1.0" encoding="UTF-16"?>
> > > >> <root>
> > > >> <child1>text</child1>
> > > >> <child2/>
> > > >> </root>
> > > >>
> > > >> Xalan serializer will be used
> > > >> <?xml version="1.0" encoding="UTF-16"?><root>
> > > >> <child1>text</child1>
> > > >> <child2> </child2>
> > > >> </root>
> > > >>
> > > >> Regards
> > > >> Dick Deneer
> > > >>
> > > >>  
> ---------------------------------------------------------------------
> > > >> ---
> > > >>
> > > >
> > > >  
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > > >
> > >
> > >
> > >  
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org
>


Re: Loosing significant space in LSSerializer

Posted by Benson Margulies <bi...@gmail.com>.
Hi Michael,

So, if I put Xerces and not Xalan into classpath, and ask a document for
it's implementation, and ask that for the DOMImplementationLS, what do I
get? Whatever Sun tossed into the pot? And if I then add Xalan, do I get the
right one?

--benson


On Sat, Nov 21, 2009 at 10:24 PM, Michael Glavassevich
<mr...@ca.ibm.com>wrote:

> Hi Benson,
>
> We're talking about two different implementations of the DOM Level 3
> LSSerializer, the more recently developed one in Xalan (serializer.jar which
> Xerces now ships and shares with Xalan) and the much older deprecated one in
> Xerces. If you're curious about the history on that, there's an FAQ [1] on
> the website.
>
> Some users have decided to keep using Xerces' deprecated serializer due to
> some quirks and issues with the currently available one from Xalan. Folks
> really should be opening JIRA issues [2] against Xalan, so those problems
> get addressed there. There's no intention to do any further development or
> fixes to the one in Xerces.
>
> Thanks.
>
> [1] http://xerces.apache.org/xerces2-j/faq-general.html#faq-6
> [2] https://issues.apache.org/jira/browse/XALANJ
>
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Benson Margulies <bi...@gmail.com> wrote on 11/21/2009 02:17:49 PM:
>
>
> > Could I please ask for a bit of clarification? The only LSSerializer
> > I'm aware of is the DOM level 3 stuff, which, I thought, was the
> > opposite of obsolete. As someone pointed out here, unlike TraX, it
> > will serialize doctypes and do other handy things. In general, I'm
> > beginning to prefer the DOMImplementationLS to JAXP and TraX.
>
> > On Sat, Nov 21, 2009 at 2:07 PM, Michael Glavassevich <
> mrglavas@ca.ibm.com
> > > wrote:
> > You should also be able to control whether spaces are preserved by
> > registering an LSSerializerFilter.
> >
> > When I added one to your test program:
> >
> >         if (useXerces)
> >         {
> >             domWriter = new DOMSerializerImpl();
> >             domWriter.setFilter(new LSSerializerFilter() {
> >                 public int getWhatToShow() {
> >                     return LSSerializerFilter.SHOW_ALL;
> >                 }
> >                 public short acceptNode(Node n) {
> >                     return LSSerializerFilter.FILTER_ACCEPT;
> >                 }});
> >         }
> >
> > the output I get is:
> >
> >
> > Program started
> > Xerces serializer will be used
> > <?xml version="1.0" encoding="UTF-16"?>
> > <root>
> > <child1>text</child1>
> > <child2> </child2>
> >
> > </root>
> >
> > Xalan serializer will be used
> > <?xml version="1.0" encoding="UTF-16"?><root>
> > <child1>text</child1>
> > <child2> </child2>
> > </root>
>
> > which I believe is what you were expecting.
> >
> > Thanks.
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> >
> > Dick Deneer <di...@donkeydevelopment.com> wrote on 11/21/2009
> > 01:19:27 PM:
> >
> >
> > > Hi Jake,
> > >
> > >
> > > I just tried your suggestion and the spaces are indeed preserved.
> > > But still, I woud prefer another solution. I do not have any clue
> > > about the xml (I use xerces in a xml editor) and I do not want to
> > > change the xml.
> > > And also I would like to stay with the LSSerializer (it also
> > > serilalizes doctype nodes).
> > > If there is another way please let me know.
> > >
> > > Thanks
> > > Dick Deneer
> > >
> > >
> > >
> > > Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:
> > >
> > > > Have you tried xml:space="preserve"?
> > > >
> > > > Jake
> > > >
> > > > On 11/20/2009 4:36 PM, Dick Deneer wrote:
> > > >> I am still using the deprecated LSSerializer because the xalan
> > > >> serializer has issues with the pretty print.
> > > >> But when I have simple elements with only space, the serializer
> > > >> produces
> > > >> empty elements. Is there a tweak to keep the spaces in this
> elements?
> > > >>
> > > >> Sample xml:
> > > >> <root><child1>text</child1><child2> </child2></root>
> > > >> I attached a simple test program, that you can just run to see the
> > > >> results:
> > > >>
> > > >> Program started
> > > >> Xerces serializer will be used
> > > >> <?xml version="1.0" encoding="UTF-16"?>
> > > >> <root>
> > > >> <child1>text</child1>
> > > >> <child2/>
> > > >> </root>
> > > >>
> > > >> Xalan serializer will be used
> > > >> <?xml version="1.0" encoding="UTF-16"?><root>
> > > >> <child1>text</child1>
> > > >> <child2> </child2>
> > > >> </root>
> > > >>
> > > >> Regards
> > > >> Dick Deneer
> > > >>
> > > >>
> ---------------------------------------------------------------------
> > > >> ---
> > > >>
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org
>

Re: Loosing significant space in LSSerializer

Posted by Benson Margulies <bi...@gmail.com>.
Hi Michael,

So, if I put Xerces and not Xalan into classpath, and ask a document for
it's implementation, and ask that for the DOMImplementationLS, what do I
get? Whatever Sun tossed into the pot? And if I then add Xalan, do I get the
right one?

--benson


On Sat, Nov 21, 2009 at 10:24 PM, Michael Glavassevich
<mr...@ca.ibm.com>wrote:

> Hi Benson,
>
> We're talking about two different implementations of the DOM Level 3
> LSSerializer, the more recently developed one in Xalan (serializer.jar which
> Xerces now ships and shares with Xalan) and the much older deprecated one in
> Xerces. If you're curious about the history on that, there's an FAQ [1] on
> the website.
>
> Some users have decided to keep using Xerces' deprecated serializer due to
> some quirks and issues with the currently available one from Xalan. Folks
> really should be opening JIRA issues [2] against Xalan, so those problems
> get addressed there. There's no intention to do any further development or
> fixes to the one in Xerces.
>
> Thanks.
>
> [1] http://xerces.apache.org/xerces2-j/faq-general.html#faq-6
> [2] https://issues.apache.org/jira/browse/XALANJ
>
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Benson Margulies <bi...@gmail.com> wrote on 11/21/2009 02:17:49 PM:
>
>
> > Could I please ask for a bit of clarification? The only LSSerializer
> > I'm aware of is the DOM level 3 stuff, which, I thought, was the
> > opposite of obsolete. As someone pointed out here, unlike TraX, it
> > will serialize doctypes and do other handy things. In general, I'm
> > beginning to prefer the DOMImplementationLS to JAXP and TraX.
>
> > On Sat, Nov 21, 2009 at 2:07 PM, Michael Glavassevich <
> mrglavas@ca.ibm.com
> > > wrote:
> > You should also be able to control whether spaces are preserved by
> > registering an LSSerializerFilter.
> >
> > When I added one to your test program:
> >
> >         if (useXerces)
> >         {
> >             domWriter = new DOMSerializerImpl();
> >             domWriter.setFilter(new LSSerializerFilter() {
> >                 public int getWhatToShow() {
> >                     return LSSerializerFilter.SHOW_ALL;
> >                 }
> >                 public short acceptNode(Node n) {
> >                     return LSSerializerFilter.FILTER_ACCEPT;
> >                 }});
> >         }
> >
> > the output I get is:
> >
> >
> > Program started
> > Xerces serializer will be used
> > <?xml version="1.0" encoding="UTF-16"?>
> > <root>
> > <child1>text</child1>
> > <child2> </child2>
> >
> > </root>
> >
> > Xalan serializer will be used
> > <?xml version="1.0" encoding="UTF-16"?><root>
> > <child1>text</child1>
> > <child2> </child2>
> > </root>
>
> > which I believe is what you were expecting.
> >
> > Thanks.
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: mrglavas@ca.ibm.com
> > E-mail: mrglavas@apache.org
> >
> > Dick Deneer <di...@donkeydevelopment.com> wrote on 11/21/2009
> > 01:19:27 PM:
> >
> >
> > > Hi Jake,
> > >
> > >
> > > I just tried your suggestion and the spaces are indeed preserved.
> > > But still, I woud prefer another solution. I do not have any clue
> > > about the xml (I use xerces in a xml editor) and I do not want to
> > > change the xml.
> > > And also I would like to stay with the LSSerializer (it also
> > > serilalizes doctype nodes).
> > > If there is another way please let me know.
> > >
> > > Thanks
> > > Dick Deneer
> > >
> > >
> > >
> > > Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:
> > >
> > > > Have you tried xml:space="preserve"?
> > > >
> > > > Jake
> > > >
> > > > On 11/20/2009 4:36 PM, Dick Deneer wrote:
> > > >> I am still using the deprecated LSSerializer because the xalan
> > > >> serializer has issues with the pretty print.
> > > >> But when I have simple elements with only space, the serializer
> > > >> produces
> > > >> empty elements. Is there a tweak to keep the spaces in this
> elements?
> > > >>
> > > >> Sample xml:
> > > >> <root><child1>text</child1><child2> </child2></root>
> > > >> I attached a simple test program, that you can just run to see the
> > > >> results:
> > > >>
> > > >> Program started
> > > >> Xerces serializer will be used
> > > >> <?xml version="1.0" encoding="UTF-16"?>
> > > >> <root>
> > > >> <child1>text</child1>
> > > >> <child2/>
> > > >> </root>
> > > >>
> > > >> Xalan serializer will be used
> > > >> <?xml version="1.0" encoding="UTF-16"?><root>
> > > >> <child1>text</child1>
> > > >> <child2> </child2>
> > > >> </root>
> > > >>
> > > >> Regards
> > > >> Dick Deneer
> > > >>
> > > >>
> ---------------------------------------------------------------------
> > > >> ---
> > > >>
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org
>

Re: Loosing significant space in LSSerializer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Benson,

We're talking about two different implementations of the DOM Level 3
LSSerializer, the more recently developed one in Xalan (serializer.jar
which Xerces now ships and shares with Xalan) and the much older deprecated
one in Xerces. If you're curious about the history on that, there's an FAQ
[1] on the website.

Some users have decided to keep using Xerces' deprecated serializer due to
some quirks and issues with the currently available one from Xalan. Folks
really should be opening JIRA issues [2] against Xalan, so those problems
get addressed there. There's no intention to do any further development or
fixes to the one in Xerces.

Thanks.

[1] http://xerces.apache.org/xerces2-j/faq-general.html#faq-6
[2] https://issues.apache.org/jira/browse/XALANJ

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Benson Margulies <bi...@gmail.com> wrote on 11/21/2009 02:17:49 PM:

> Could I please ask for a bit of clarification? The only LSSerializer
> I'm aware of is the DOM level 3 stuff, which, I thought, was the
> opposite of obsolete. As someone pointed out here, unlike TraX, it
> will serialize doctypes and do other handy things. In general, I'm
> beginning to prefer the DOMImplementationLS to JAXP and TraX.

> On Sat, Nov 21, 2009 at 2:07 PM, Michael Glavassevich
<mrglavas@ca.ibm.com
> > wrote:
> You should also be able to control whether spaces are preserved by
> registering an LSSerializerFilter.
>
> When I added one to your test program:
>
>         if (useXerces)
>         {
>             domWriter = new DOMSerializerImpl();
>             domWriter.setFilter(new LSSerializerFilter() {
>                 public int getWhatToShow() {
>                     return LSSerializerFilter.SHOW_ALL;
>                 }
>                 public short acceptNode(Node n) {
>                     return LSSerializerFilter.FILTER_ACCEPT;
>                 }});
>         }
>
> the output I get is:
>
>
> Program started
> Xerces serializer will be used
> <?xml version="1.0" encoding="UTF-16"?>
> <root>
> <child1>text</child1>
> <child2> </child2>
>
> </root>
>
> Xalan serializer will be used
> <?xml version="1.0" encoding="UTF-16"?><root>
> <child1>text</child1>
> <child2> </child2>
> </root>

> which I believe is what you were expecting.
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Dick Deneer <di...@donkeydevelopment.com> wrote on 11/21/2009
> 01:19:27 PM:
>
>
> > Hi Jake,
> >
> >
> > I just tried your suggestion and the spaces are indeed preserved.
> > But still, I woud prefer another solution. I do not have any clue
> > about the xml (I use xerces in a xml editor) and I do not want to
> > change the xml.
> > And also I would like to stay with the LSSerializer (it also
> > serilalizes doctype nodes).
> > If there is another way please let me know.
> >
> > Thanks
> > Dick Deneer
> >
> >
> >
> > Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:
> >
> > > Have you tried xml:space="preserve"?
> > >
> > > Jake
> > >
> > > On 11/20/2009 4:36 PM, Dick Deneer wrote:
> > >> I am still using the deprecated LSSerializer because the xalan
> > >> serializer has issues with the pretty print.
> > >> But when I have simple elements with only space, the serializer
> > >> produces
> > >> empty elements. Is there a tweak to keep the spaces in this
elements?
> > >>
> > >> Sample xml:
> > >> <root><child1>text</child1><child2> </child2></root>
> > >> I attached a simple test program, that you can just run to see the
> > >> results:
> > >>
> > >> Program started
> > >> Xerces serializer will be used
> > >> <?xml version="1.0" encoding="UTF-16"?>
> > >> <root>
> > >> <child1>text</child1>
> > >> <child2/>
> > >> </root>
> > >>
> > >> Xalan serializer will be used
> > >> <?xml version="1.0" encoding="UTF-16"?><root>
> > >> <child1>text</child1>
> > >> <child2> </child2>
> > >> </root>
> > >>
> > >> Regards
> > >> Dick Deneer
> > >>
> > >>
---------------------------------------------------------------------
> > >> ---
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org

Re: Loosing significant space in LSSerializer

Posted by Benson Margulies <bi...@gmail.com>.
Could I please ask for a bit of clarification? The only LSSerializer I'm
aware of is the DOM level 3 stuff, which, I thought, was the opposite of
obsolete. As someone pointed out here, unlike TraX, it will serialize
doctypes and do other handy things. In general, I'm beginning to prefer the
DOMImplementationLS to JAXP and TraX.

On Sat, Nov 21, 2009 at 2:07 PM, Michael Glavassevich
<mr...@ca.ibm.com>wrote:

> You should also be able to control whether spaces are preserved by
> registering an LSSerializerFilter.
>
> When I added one to your test program:
>
>         if (useXerces)
>         {
>             domWriter = new DOMSerializerImpl();
>             domWriter.setFilter(new LSSerializerFilter() {
>                 public int getWhatToShow() {
>                     return LSSerializerFilter.SHOW_ALL;
>                 }
>                 public short acceptNode(Node n) {
>                     return LSSerializerFilter.FILTER_ACCEPT;
>                 }});
>         }
>
> the output I get is:
>
>
> Program started
> Xerces serializer will be used
> <?xml version="1.0" encoding="UTF-16"?>
> <root>
>  <child1>text</child1>
>  <child2> </child2>
>
> </root>
>
> Xalan serializer will be used
> <?xml version="1.0" encoding="UTF-16"?><root>
>  <child1>text</child1>
>  <child2> </child2>
> </root>
>
> which I believe is what you were expecting.
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Dick Deneer <di...@donkeydevelopment.com> wrote on 11/21/2009
> 01:19:27 PM:
>
>
> > Hi Jake,
> >
> >
> > I just tried your suggestion and the spaces are indeed preserved.
> > But still, I woud prefer another solution. I do not have any clue
> > about the xml (I use xerces in a xml editor) and I do not want to
> > change the xml.
> > And also I would like to stay with the LSSerializer (it also
> > serilalizes doctype nodes).
> > If there is another way please let me know.
> >
> > Thanks
> > Dick Deneer
> >
> >
> >
> > Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:
> >
> > > Have you tried xml:space="preserve"?
> > >
> > > Jake
> > >
> > > On 11/20/2009 4:36 PM, Dick Deneer wrote:
> > >> I am still using the deprecated LSSerializer because the xalan
> > >> serializer has issues with the pretty print.
> > >> But when I have simple elements with only space, the serializer
> > >> produces
> > >> empty elements. Is there a tweak to keep the spaces in this elements?
> > >>
> > >> Sample xml:
> > >> <root><child1>text</child1><child2> </child2></root>
> > >> I attached a simple test program, that you can just run to see the
> > >> results:
> > >>
> > >> Program started
> > >> Xerces serializer will be used
> > >> <?xml version="1.0" encoding="UTF-16"?>
> > >> <root>
> > >> <child1>text</child1>
> > >> <child2/>
> > >> </root>
> > >>
> > >> Xalan serializer will be used
> > >> <?xml version="1.0" encoding="UTF-16"?><root>
> > >> <child1>text</child1>
> > >> <child2> </child2>
> > >> </root>
> > >>
> > >> Regards
> > >> Dick Deneer
> > >>
> > >> ---------------------------------------------------------------------
> > >> ---
> > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
>

Re: Loosing significant space in LSSerializer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
(Copying xalan-j-users to this thread.)

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Michael Glavassevich <mr...@ca.ibm.com> wrote on 11/22/2009 10:30:49 AM:

> Dick Deneer <di...@donkeydevelopment.com> wrote on 11/22/2009
> 06:33:28 AM:
>
> > Michael,
> >
> > Thank you for this suggestion.
> > I can use this. Before I call the serializer I will strip off all
> > whitespace in "whitespace-only" complex nodes because otherwise I do
> > not get a pretty-print:
> > For example:
> > String xml = "<root>" +
> > "                                  <child1>text</child1><child2>
> > </child2></root>";
> > results in :
> > <?xml version="1.0" encoding="UTF-16"?>
> > <root>                                  <child1>text</child1>
> >     <child2>   </child2>
> > </root>
> >
> > But stripping of this whitespace before will not be too difficult.
> >
> > I feel it is a pitty that the LSSerializer will not be maintained
> > anymore, because we do not have alternatives that supply the same
> > functionality.
>
> It is in Xalan. Their serializer started as a copy of the Xerces one
> (even has similar package names: org.apache.xml.serialize vs.
> org.apache.xml.serializer). We didn't want to duplicate the effort
> anymore and decided to combine forces and the Xalan one was chosen
> as the common codebase because it was better maintained and was
> making significant improvements to performance. Its LSSerializer
> implementation was written by a Xerces committer and I have made
> improvements and fixes to it too where I've found issues, so it's
> being jointly maintained, though in a different project. This is the
> alternative. It *is* an LSSerializer and there is no reason that it
> can't be updated / fixed to have similar behaviour, but that's only
> likely to happen if users report the problems they're having
> (patches are welcome), preferably in JIRA.
>
> > I am afraid that maybe in the future there may be new xml (or DOM)
> > feautures that have effects on the serialization. Then we are
> > totally dependent on other libraries to implement that functionality.
> >
> > But I understand you have to make choices where to spent the effort.
> >
> > Thanks
> > Dick Deneer
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org

Re: Loosing significant space in LSSerializer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Chris Simmons <cp...@corefiling.com> wrote on 11/23/2009 06:20:23 AM:

> > It is in Xalan. Their serializer started as a copy of the Xerces one
> > (even has similar package names: org.apache.xml.serialize vs.
> > org.apache.xml.serializer). We didn't want to duplicate the effort
> > anymore and decided to combine forces and the Xalan one was chosen as
> > the common codebase because it was better maintained and was making
> > significant improvements to performance. Its LSSerializer
> > implementation was written by a Xerces committer and I have made
> > improvements and fixes to it too where I've found issues, so it's
> > being jointly maintained, though in a different project. This is the
> > alternative. It *is* an LSSerializer and there is no reason that it
> > can't be updated / fixed to have similar behaviour, but that's only
> > likely to happen if users report the problems they're having (patches
> > are welcome), preferably in JIRA.
> >
> If only that were true.  I raised a bug (which included a patch) over
> two years ago due to different behaviour between the Xerces/Xalan
> LSSerializer but it has seemingly been ignored.
>
> https://issues.apache.org/jira/browse/XALANJ-2409
>
> I wonder if LSSerializer bugs are falling between the cracks?

Xalan has been relatively dormant the last couple years (developers busy at
their day jobs and elsewhere), so yes it's been awhile since things have
moved but there's recently been interest in revitalizing the project and
potentially two new committers who seem eager to get things rolling again.
b
> Chris Simmons.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Re: Loosing significant space in LSSerializer

Posted by Chris Simmons <cp...@corefiling.com>.
Stanimir Stamenkov wrote:
> Mon, 23 Nov 2009 11:20:23 +0000, /Chris Simmons/:
>
>> I raised a bug (which included a patch) over two
>> years ago due to different behaviour between the Xerces/Xalan
>> LSSerializer but it has seemingly been ignored.
>>
>> https://issues.apache.org/jira/browse/XALANJ-2409
>>
>> I wonder if LSSerializer bugs are falling between the cracks?
>
> Have you tried whether registering an LSSerializerFilter and filtering 
> out xmlns:xml attributes works around the problem?
>
We just built a patched version of the serializer jar as it seemed the 
most robust fix.  I can't recall whether we tried a filter.  I suppose 
it should work as long as the filter is after the namespace fix-up in 
the serializer's pipeline.

Chris.

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Loosing significant space in LSSerializer

Posted by Stanimir Stamenkov <s7...@netscape.net>.
Mon, 23 Nov 2009 11:20:23 +0000, /Chris Simmons/:

> I raised a bug (which included a patch) over two
> years ago due to different behaviour between the Xerces/Xalan
> LSSerializer but it has seemingly been ignored.
>
> https://issues.apache.org/jira/browse/XALANJ-2409
>
> I wonder if LSSerializer bugs are falling between the cracks?

Have you tried whether registering an LSSerializerFilter and 
filtering out xmlns:xml attributes works around the problem?

-- 
Stanimir

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Loosing significant space in LSSerializer

Posted by Chris Simmons <cp...@corefiling.com>.
> It is in Xalan. Their serializer started as a copy of the Xerces one 
> (even has similar package names: org.apache.xml.serialize vs. 
> org.apache.xml.serializer). We didn't want to duplicate the effort 
> anymore and decided to combine forces and the Xalan one was chosen as 
> the common codebase because it was better maintained and was making 
> significant improvements to performance. Its LSSerializer 
> implementation was written by a Xerces committer and I have made 
> improvements and fixes to it too where I've found issues, so it's 
> being jointly maintained, though in a different project. This is the 
> alternative. It *is* an LSSerializer and there is no reason that it 
> can't be updated / fixed to have similar behaviour, but that's only 
> likely to happen if users report the problems they're having (patches 
> are welcome), preferably in JIRA.
>
If only that were true.  I raised a bug (which included a patch) over 
two years ago due to different behaviour between the Xerces/Xalan 
LSSerializer but it has seemingly been ignored.

https://issues.apache.org/jira/browse/XALANJ-2409

I wonder if LSSerializer bugs are falling between the cracks?

Chris Simmons.

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Loosing significant space in LSSerializer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
(Copying xalan-j-users to this thread.)

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Michael Glavassevich <mr...@ca.ibm.com> wrote on 11/22/2009 10:30:49 AM:

> Dick Deneer <di...@donkeydevelopment.com> wrote on 11/22/2009
> 06:33:28 AM:
>
> > Michael,
> >
> > Thank you for this suggestion.
> > I can use this. Before I call the serializer I will strip off all
> > whitespace in "whitespace-only" complex nodes because otherwise I do
> > not get a pretty-print:
> > For example:
> > String xml = "<root>" +
> > "                                  <child1>text</child1><child2>
> > </child2></root>";
> > results in :
> > <?xml version="1.0" encoding="UTF-16"?>
> > <root>                                  <child1>text</child1>
> >     <child2>   </child2>
> > </root>
> >
> > But stripping of this whitespace before will not be too difficult.
> >
> > I feel it is a pitty that the LSSerializer will not be maintained
> > anymore, because we do not have alternatives that supply the same
> > functionality.
>
> It is in Xalan. Their serializer started as a copy of the Xerces one
> (even has similar package names: org.apache.xml.serialize vs.
> org.apache.xml.serializer). We didn't want to duplicate the effort
> anymore and decided to combine forces and the Xalan one was chosen
> as the common codebase because it was better maintained and was
> making significant improvements to performance. Its LSSerializer
> implementation was written by a Xerces committer and I have made
> improvements and fixes to it too where I've found issues, so it's
> being jointly maintained, though in a different project. This is the
> alternative. It *is* an LSSerializer and there is no reason that it
> can't be updated / fixed to have similar behaviour, but that's only
> likely to happen if users report the problems they're having
> (patches are welcome), preferably in JIRA.
>
> > I am afraid that maybe in the future there may be new xml (or DOM)
> > feautures that have effects on the serialization. Then we are
> > totally dependent on other libraries to implement that functionality.
> >
> > But I understand you have to make choices where to spent the effort.
> >
> > Thanks
> > Dick Deneer
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org

Re: Loosing significant space in LSSerializer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Dick Deneer <di...@donkeydevelopment.com> wrote on 11/22/2009
06:33:28 AM:

> Michael,
>
> Thank you for this suggestion.
> I can use this. Before I call the serializer I will strip off all
> whitespace in "whitespace-only" complex nodes because otherwise I do
> not get a pretty-print:
> For example:
> String xml = "<root>" +
> "                                  <child1>text</child1><child2>
> </child2></root>";
> results in :
> <?xml version="1.0" encoding="UTF-16"?>
> <root>                                  <child1>text</child1>
>     <child2>   </child2>
> </root>
>
> But stripping of this whitespace before will not be too difficult.
>
> I feel it is a pitty that the LSSerializer will not be maintained
> anymore, because we do not have alternatives that supply the same
> functionality.

It is in Xalan. Their serializer started as a copy of the Xerces one (even
has similar package names: org.apache.xml.serialize vs.
org.apache.xml.serializer). We didn't want to duplicate the effort anymore
and decided to combine forces and the Xalan one was chosen as the common
codebase because it was better maintained and was making significant
improvements to performance. Its LSSerializer implementation was written by
a Xerces committer and I have made improvements and fixes to it too where
I've found issues, so it's being jointly maintained, though in a different
project. This is the alternative. It *is* an LSSerializer and there is no
reason that it can't be updated / fixed to have similar behaviour, but
that's only likely to happen if users report the problems they're having
(patches are welcome), preferably in JIRA.

> I am afraid that maybe in the future there may be new xml (or DOM)
> feautures that have effects on the serialization. Then we are
> totally dependent on other libraries to implement that functionality.
>
> But I understand you have to make choices where to spent the effort.
>
> Thanks
> Dick Deneer

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Re: Loosing significant space in LSSerializer

Posted by Dick Deneer <di...@donkeydevelopment.com>.
Michael,

Thank you for this suggestion.
I can use this. Before I call the serializer I will strip off all  
whitespace in "whitespace-only" complex nodes because otherwise I do  
not get a pretty-print:
For example:
String xml = "<root>" +
				"                                  <child1>text</ 
child1><child2>   </child2></root>";
results in :
<?xml version="1.0" encoding="UTF-16"?>
<root>                                  <child1>text</child1>
     <child2>   </child2>
</root>

But stripping of this whitespace before will not be too difficult.

I feel it is a pitty that the LSSerializer will not be maintained  
anymore, because we do not have alternatives that supply the same  
functionality.
I am afraid that maybe in the future there may be new xml (or DOM)  
feautures that have effects on the serialization. Then we are totally  
dependent on other libraries to implement that functionality.


But I understand you have to make choices where to spent the effort.

Thanks
Dick Deneer


Op 21-nov-2009, om 20:07 heeft Michael Glavassevich het volgende  
geschreven:

> You should also be able to control whether spaces are preserved by  
> registering an LSSerializerFilter.
>
> When I added one to your test program:
>
>         if (useXerces)
>         {
>             domWriter = new DOMSerializerImpl();
>             domWriter.setFilter(new LSSerializerFilter() {
>                 public int getWhatToShow() {
>                     return LSSerializerFilter.SHOW_ALL;
>                 }
>                 public short acceptNode(Node n) {
>                     return LSSerializerFilter.FILTER_ACCEPT;
>                 }});
>         }
>
> the output I get is:
>
> Program started
> Xerces serializer will be used
> <?xml version="1.0" encoding="UTF-16"?>
> <root>
> <child1>text</child1>
> <child2> </child2>
> </root>
>
> Xalan serializer will be used
> <?xml version="1.0" encoding="UTF-16"?><root>
> <child1>text</child1>
> <child2> </child2>
> </root>
>
> which I believe is what you were expecting.
>
> Thanks.
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Dick Deneer <di...@donkeydevelopment.com> wrote on 11/21/2009  
> 01:19:27 PM:
>
> > Hi Jake,
> >
> >
> > I just tried your suggestion and the spaces are indeed preserved.
> > But still, I woud prefer another solution. I do not have any clue
> > about the xml (I use xerces in a xml editor) and I do not want to
> > change the xml.
> > And also I would like to stay with the LSSerializer (it also
> > serilalizes doctype nodes).
> > If there is another way please let me know.
> >
> > Thanks
> > Dick Deneer
> >
> >
> >
> > Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:
> >
> > > Have you tried xml:space="preserve"?
> > >
> > > Jake
> > >
> > > On 11/20/2009 4:36 PM, Dick Deneer wrote:
> > >> I am still using the deprecated LSSerializer because the xalan
> > >> serializer has issues with the pretty print.
> > >> But when I have simple elements with only space, the serializer
> > >> produces
> > >> empty elements. Is there a tweak to keep the spaces in this  
> elements?
> > >>
> > >> Sample xml:
> > >> <root><child1>text</child1><child2> </child2></root>
> > >> I attached a simple test program, that you can just run to see  
> the
> > >> results:
> > >>
> > >> Program started
> > >> Xerces serializer will be used
> > >> <?xml version="1.0" encoding="UTF-16"?>
> > >> <root>
> > >> <child1>text</child1>
> > >> <child2/>
> > >> </root>
> > >>
> > >> Xalan serializer will be used
> > >> <?xml version="1.0" encoding="UTF-16"?><root>
> > >> <child1>text</child1>
> > >> <child2> </child2>
> > >> </root>
> > >>
> > >> Regards
> > >> Dick Deneer
> > >>
> > >>  
> ---------------------------------------------------------------------
> > >> ---
> > >>
> > >
> > >  
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > >
> >
> >
> >  
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
>


Re: Loosing significant space in LSSerializer

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
You should also be able to control whether spaces are preserved by
registering an LSSerializerFilter.

When I added one to your test program:

        if (useXerces)
        {
            domWriter = new DOMSerializerImpl();
            domWriter.setFilter(new LSSerializerFilter() {
                public int getWhatToShow() {
                    return LSSerializerFilter.SHOW_ALL;)
                }
                public short acceptNode(Node n) {
                    return LSSerializerFilter.FILTER_ACCEPT;
                }});
        }

the output I get is:

Program started
Xerces serializer will be used
<?xml version="1.0" encoding="UTF-16"?>
<root>
    <child1>text</child1>
    <child2>   </child2>>
</root>

Xalan serializer will be used
<?xml version="1.0" encoding="UTF-16"?><root>.
   <child1>text</child1>
   <child2>   </child2>>
</root>

which I believe is what you were expecting.

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Dick Deneer <di...@donkeydevelopment.com> wrote on 11/21/2009
01:19:27 PM:

> Hi Jake,
>
>
> I just tried your suggestion and the spaces are indeed preserved.
> But still, I woud prefer another solution. I do not have any clue
> about the xml (I use xerces in a xml editor) and I do not want to
> change the xml.
> And also I would like to stay with the LSSerializer (it also
> serilalizes doctype nodes).
> If there is another way please let me know.
>
> Thanks
> Dick Deneer
>
>
>
> Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:
>
> > Have you tried xml:space="preserve"?
> >
> > Jake
> >
> > On 11/20/2009 4:36 PM, Dick Deneer wrote:
> >> I am still using the deprecated LSSerializer because the xalan
> >> serializer has issues with the pretty print.
> >> But when I have simple elements with only space, the serializer
> >> produces
> >> empty elements. Is there a tweak to keep the spaces in this elements?
> >>
> >> Sample xml:
> >> <root><child1>text</child1><child2> </child2></root>
> >> I attached a simple test program, that you can just run to see the
> >> results:
> >>
> >> Program started
> >> Xerces serializer will be used
> >> <?xml version="1.0" encoding="UTF-16"?>
> >> <root>
> >> <child1>text</child1>
> >> <child2/>
> >> </root>
> >>
> >> Xalan serializer will be used
> >> <?xml version="1.0" encoding="UTF-16"?><root>
> >> <child1>text</child1>
> >> <child2> </child2>
> >> </root>
> >>
> >> Regards
> >> Dick Deneer
> >>
> >> ---------------------------------------------------------------------
> >> ---
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Re: Loosing significant space in LSSerializer

Posted by Dick Deneer <di...@donkeydevelopment.com>.
Hi Jake,


I just tried your suggestion and the spaces are indeed preserved.
But still, I woud prefer another solution. I do not have any clue  
about the xml (I use xerces in a xml editor) and I do not want to  
change the xml.
And also I would like to stay with the LSSerializer (it also  
serilalizes doctype nodes).
If there is another way please let me know.

Thanks
Dick Deneer



Op 21-nov-2009, om 19:03 heeft Jacob Kjome het volgende geschreven:

> Have you tried xml:space="preserve"?
>
> Jake
>
> On 11/20/2009 4:36 PM, Dick Deneer wrote:
>> I am still using the deprecated LSSerializer because the xalan
>> serializer has issues with the pretty print.
>> But when I have simple elements with only space, the serializer  
>> produces
>> empty elements. Is there a tweak to keep the spaces in this elements?
>>
>> Sample xml:
>> <root><child1>text</child1><child2> </child2></root>
>> I attached a simple test program, that you can just run to see the  
>> results:
>>
>> Program started
>> Xerces serializer will be used
>> <?xml version="1.0" encoding="UTF-16"?>
>> <root>
>> <child1>text</child1>
>> <child2/>
>> </root>
>>
>> Xalan serializer will be used
>> <?xml version="1.0" encoding="UTF-16"?><root>
>> <child1>text</child1>
>> <child2> </child2>
>> </root>
>>
>> Regards
>> Dick Deneer
>>
>> --------------------------------------------------------------------- 
>> ---
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Loosing significant space in LSSerializer

Posted by Jacob Kjome <ho...@visi.com>.
Have you tried xml:space="preserve"?

Jake

On 11/20/2009 4:36 PM, Dick Deneer wrote:
> I am still using the deprecated LSSerializer because the xalan
> serializer has issues with the pretty print.
> But when I have simple elements with only space, the serializer produces
> empty elements. Is there a tweak to keep the spaces in this elements?
>
> Sample xml:
> <root><child1>text</child1><child2> </child2></root>
> I attached a simple test program, that you can just run to see the results:
>
> Program started
> Xerces serializer will be used
> <?xml version="1.0" encoding="UTF-16"?>
> <root>
> <child1>text</child1>
> <child2/>
> </root>
>
> Xalan serializer will be used
> <?xml version="1.0" encoding="UTF-16"?><root>
> <child1>text</child1>
> <child2> </child2>
> </root>
>
> Regards
> Dick Deneer
>
> ------------------------------------------------------------------------
>

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org