You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Michael Glavassevich <mr...@ca.ibm.com> on 2009/03/23 04:18:04 UTC

Re: LSSerializer configuration for namespaces

Hi Tommaso,

I've tried this out myself and it appears to be a bug in the Xalan
serializer. You can report the issue here [1]. It is possible to work
around the problem by removing serializer.jar from your classpath. Xerces
will fall back to using its old deprecated serializer if it cannot find the
Xalan one and you should get the result you expected.

Thanks.

[1] 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

tommaso.agnoloni@gmail.com wrote on 03/17/2009 11:11:16 AM:

> Hi Michael,
>
> thanks for your reply.
>
>
> Actually you are right, I will try to explain with an example:
>
>
> This is the whole document:
>
> ______________________________________________
>
>
> <?xml version="1.0" encoding="iso-8859-15"?>
> <!DOCTYPE NIR SYSTEM "nircompleto.dtd">
> <NIR xmlns="http://www.normeinrete.it/nir/2.2/" xmlns:dsp="http:
> //www.normeinrete.it/nir/disposizioni/2.2/" xmlns:h="http://www.w3.
> org/HTML/1998/html4" xmlns:xlink="http://www.w3.org/1999/xlink"
> tipo="originale">
> <Legge>
>   <meta>
>     <descrittori>
>       <pubblicazione norm="" num="" tipo="GU"/>
>       <entratainvigore norm=""/>
>       <redazione id="red1" nome="" norm=""/>
>       <urn valore="urn:nir:stato:legge:aaaa-mm-gg;nnn"/>
>      </descrittori>
>   </meta>
>   <intestazione>
>     <tipoDoc>LEGGE</tipoDoc>
>     <dataDoc norm=""/>, n.<numDoc/>
>     <titoloDoc/>
>   </intestazione>
>   <formulainiziale>
>    <h:p>La Camera dei deputati ed il Senato della Repubblica hanno
> approvato;</h:p>
>    <h:p>IL PRESIDENTE DELLA REPUBBLICA</h:p>
>    <h:p>PROMULGA</h:p>
>    <h:p>la seguente legge:</h:p>
>   </formulainiziale>
>   <articolato>
>    <articolo id="art1">
>      <num>Art. 1</num>
>      <rubrica/>
>        <comma id="art1-com1">
>          <num>1.</num>
>          <corpo>text<h:p>paragraph</h:p>
>          </corpo>
>        </comma>
>     </articolo>
>   </articolato>
>  </Legge>
> </NIR>
>
>
> _____________________________________________________________________
>
>
> what I need is to serialize a subtree of this document for example
<articolo>
>
> What I expect to obtain disabling namespaces normalization is just
> the portion of xml related to <articolo> like this:
>
> <articolo id="art1">
>      <num>Art. 1</num>
>      <rubrica/>
>        <comma id="art1-com1">
>          <num>1.</num>
>          <corpo>text<h:p>paragraph</h:p>
>          </corpo>
>        </comma>
>   </articolo>
>
>
> what I actually obtain is :
>
>
> <articolo xmlns="http://www.normeinrete.it/nir/2.2/" id="art1">
>    <num>Art. 1</num>
>      <rubrica/>
>      <comma id="art1-com1">
>        <num>1.</num>
>        <corpo>text
>           <h:p
xmlns:h="http://www.w3.org/HTML/1998/html4">paragraph</h:p>
>        </corpo>
>      </comma>
> </articolo>
>
> How can I avoid the addition of the namespaces declaration in the
> subtree serialization ?
>
>
>
> Tommaso

> 2009/3/17 Michael Glavassevich <mr...@ca.ibm.com>
> Hi Tommaso,
>
> tommaso.agnoloni@gmail.com wrote on 03/16/2009 02:16:33 PM:
>
>
> > Hi,
> >
> > I need to use the LSSerializer provided by xerces to serialize a DOM
> > document subtree without namespaces completion processing, i.e., the
> > desired output is just the xml serialization of the subtree as one
> > could extract it by selection from the whole document serialization.
> >
> > To this end, if I understood well, setting the property "namespaces"
> > to "false" the normalization algorithm described in Appendix B1 of
> > Dom Level 3 specification should be skipped.
> >
> > I'm using this code:
> >
> > but it doesn't have effect.
> >
> > What is wrong?
>
>
> Hard to say. You haven't shown us the document you're serializing or
> the result from serialization. That might help.
>
>
> > Is the "namespaces" properties setting working in
> > Xerces LSSerializer implementation ?

> Xalan now provides the LSSerializer (serializer.jar) for Xerces.
> Disabling the "namespaces" parameter is supposed to work but I can't
> say I've ever tried it myself.
>
>
> >  DOMImplementationLS impl = (DOMImplementationLS)registry.
> > getDOMImplementation("LS");
> >  LSSerializer writer = impl.createLSSerializer();
> >  DOMConfiguration domConfig = writer.getDomConfig();
> >  domConfig.setParameter("namespaces",Boolean.FALSE);
> >  String str = writer.writeToString(node);
> >
> > Thanks for any help,
> >
> > Tommaso

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