That's what I was suspecting, so I made sure it throws an IllegalStateException with a proper message and just committed that change. So if you do this honest mistake it will complain and explain why.
Keith also suggested I use System.out by default, but then I'll get people complaining of seeing stuff in the console instead of the output file. You're prefectly right on the entity side, I'll try to get your patch in and update the CVS. arkin Andy Clark wrote: > > 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] -- ---------------------------------------------------------------------- Assaf Arkin www.exoffice.com CTO, Exoffice Technologies, Inc. www.exolab.org