Assaf,

One of the problems has been fixed -- the null pointer caused
by not specifying a writer (or output stream) to the serializer.
I was surprised to find out that the serializer doesn't just
write to System.out in the case that no writer/output stream
is specified. I would suggest either 1) not having a constructor
that is guaranteed to cause an exception when you serialize
(assuming, of course, that you haven't set the output), or 2) 
default the writer/output stream to System.out. I would prefer
the second option.

The serializer is still unable to handle text entities. The
solution to this requires some additional work because you
have to serialize all of the Entity node's children into a
string and then write *that* as the value of the entity. The
patch for this particular fix is included below. I wasn't
sure how many variables need to be swapped out during the
serialization of the children so I included _writer, _text,
and _line. Please review this change and then update CVS
appropriately.

// BEGIN Patch
Index: src/org/apache/xml/serialize/BaseMarkupSerializer.java
===================================================================
RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xml/serialize/BaseMarkupSerializer.java,v
retrieving revision 1.3
diff -c -r1.3 BaseMarkupSerializer.java
*** BaseMarkupSerializer.java   2000/01/14 20:40:54     1.3
--- BaseMarkupSerializer.java   2000/01/14 22:46:21
***************
*** 780,789 ****
                map = docType.getEntities();
                if ( map != null ) {
                    for ( i = 0 ; i < map.getLength() ; ++i ) {
!                       entity = (Entity) map.item( i );
!                       unparsedEntityDecl( entity.getNodeName(), 
entity.getPublicId(),
!                                           entity.getSystemId(), 
entity.getNotationName() );
!                   }
                }
                map = docType.getNotations();
                if ( map != null ) {
--- 780,812 ----
                map = docType.getEntities();
                if ( map != null ) {
                    for ( i = 0 ; i < map.getLength() ; ++i ) {
!                       entity = (Entity) map.item( i );
!                 String publicId = entity.getPublicId();
!                 String systemId = entity.getSystemId();
!                 if (publicId == null && systemId == null) {
!                     Writer oldWriter = _writer;
!                     StringBuffer oldText = _text;
!                     StringBuffer oldLine = _line;
!                     _writer = new StringWriter();
!                     _text = new StringBuffer();
!                     _line = new StringBuffer();
!                     Node child = entity.getFirstChild();
!                     while (child != null) {
!                         serializeNode(child);
!                         child = child.getNextSibling();
!                     }
!                     flushLine(true);
!                     String value = _writer.toString();
!                     _writer = oldWriter;
!                     _text = oldText;
!                     _line = oldLine;
!                     internalEntityDecl(entity.getNodeName(), value);
!                 }
!                 else {
!                               unparsedEntityDecl( entity.getNodeName(), 
publicId, systemId,
!                                           entity.getNotationName() );
!                       }
!             }
                }
                map = docType.getNotations();
                if ( map != null ) {
// END Patch

-- 
Andy Clark * IBM, JTC - Silicon Valley * [EMAIL PROTECTED]

Reply via email to