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 "Jesus M. Salvo Jr." <js...@powerserve.com.au> on 2001/02/08 05:33:55 UTC

Re: Howto: SAX Serializer

While trying to do this, I came upon a stumbling block:

   SAXParser parser = new org.apache.xerces.parsers.SAXParser();
   XMLSerializer serializer = new XMLSerializer();

   parser.setContentHandler( serializer );
  
   parser.startDocument();
   parser.startDTD( new QName( .... ), 1, 2, );
   .......
   parser.endDTD();
   parser.endDocument();

Reading through the source, it appears that:

* A lot of the methods of SAXParser, including startDTD() as shown 
above, requires QName.
* For SAXParser to understand with QName is, it somehow maps them to a 
StringPool.

However, there is no way tell the SAXParser the StringPool that you want 
it to use.
The SAXParser constructor that requires StringPool is protected. I think 
this constructor should have been declared public.


John.


Arnaud Le Hors wrote:

> Jesus,
> all you need to do is to define your own class that walks through your
> object structure and generates the appropriate SAX events by calling the
> DocumentHandler methods of the serializer. See
> org.xml.sax.DocumentHandler interface for the methods to call.
> You basically have to act like if you were the parser with regard to the
> serializer in Jeff's example.