You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/04/22 00:27:53 UTC
DO NOT REPLY [Bug 18259] -
Serialize empty attribute couses NullPointerException
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18259>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18259
Serialize empty attribute couses NullPointerException
------- Additional Comments From minchau@ca.ibm.com 2003-04-21 22:27 -------
Works for me with the latest code in CVS. Here is the Java code I used:
package bugzilla;
import java.io.FileInputStream;
import java.io.StringWriter;
import java.util.Properties;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import org.apache.xml.serializer.DOMSerializer;
import org.apache.xml.serializer.OutputPropertiesFactory;
import org.apache.xml.serializer.Serializer;
import org.apache.xml.serializer.SerializerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
public class bug18259
{
public static void main(String[] args)
{
try
{
Document docXML = parseToDOM("D:/XSLT/xml/bug18259.xml");
Element el = docXML.getDocumentElement();
Properties oprops =
new Properties(
OutputPropertiesFactory.getDefaultMethodProperties("xml"));
oprops.put(OutputKeys.INDENT, "yes");
oprops.put(OutputKeys.ENCODING, "ISO-8859-2");
Serializer serializer = SerializerFactory.getSerializer(oprops);
StringWriter stringOut = new StringWriter();
serializer.setWriter(stringOut);
serializer.setOutputFormat(oprops);
DOMSerializer ds = serializer.asDOMSerializer();
ds.serialize(el);
}
catch (Exception e)
{
{
System.out.println("ERROR: failed" + e);
}
}
}
/** Worker method to parse file into a DOM. */
protected static Document parseToDOM(String filename) throws Exception
{ // Set up a DOM tree to query.
InputSource in;
in = new InputSource(new FileInputStream(filename));
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
Document doc;
doc = dfactory.newDocumentBuilder().parse(in);
return doc;
}
}
I changed the contents of the XML file, which was in "D:/XSLT/xml/bug18259.xml"
on my system ( typo in the closing </LS> ):
<?xml version="1.0" encoding="UTF-8"?>
<LS>
<L alias="aaaaa">
<!-- here id attribute is empty -->
<V id="">ssss</V>
</L>
</LS>
Please provide a more complete testcase that fails with the latest in CVS or
this bug should be considered FIXED.
Regards,
Brian Minchau