Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] very strange behavior

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Lowell Kirsh" <lowellk AT gmail.com>
  • To: "Elliotte Harold" <elharo AT metalab.unc.edu>
  • Cc: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] very strange behavior
  • Date: Wed, 16 May 2007 19:26:14 -0700

Here is the code that's been causing trouble:

import java.io.*;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.*;
import nu.xom.*;

public final class XomUtil
{
private XomUtil() {} // no instances

private static final XMLReader xmlReader;
static {
try {
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
xmlReader = parserFactory.newSAXParser().getXMLReader();

xmlReader.setErrorHandler(new ErrorHandler() {
public void warning(SAXParseException e) throws SAXException
{
throw e;
}
public void error(SAXParseException e) throws SAXException {
throw e;
}
public void fatalError(SAXParseException e) throws
SAXException {
throw e;
}
});
}
catch (Exception e) {
throw new RuntimeException(e);
}
}

private static final Builder PARSER = new Builder(xmlReader);

public static Document parse(InputStream is) throws ParsingException,
IOException
{
synchronized (PARSER) {
Document ret = PARSER.build(is);
return ret;
}
}

/** just for testing */
public static void main(String[] args) throws Exception
{
Document doc = XomUtil.parse(new java.io.FileInputStream(args[0]));
new nu.xom.Serializer(System.out).write(doc);
}
}


On 5/16/07, Elliotte Harold <elharo AT metalab.unc.edu> wrote:
Lowell Kirsh wrote:
> All the element and
> attribute names were missing. My xml looked like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <>
> <>
> < ="NA:1:2.0.37I" ="beta-4102"/>
> < ="52848169" ="521245832" ="external"/>
> </>
> ...
>
> Now I understood why my xpath stopped working. Has anyone seen this
> problem before?
>

Very strange indeed. That shouldn't be possible, and I've never seen its
like before. Do you have sample code that can reproduce this?

The only way I can imagine that happening is a parser bug. Have you
recently changed or upgraded your parser?

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
Java I/O 2nd Edition Just Published!
http://www.cafeaulait.org/books/javaio2/
http://www.amazon.com/exec/obidos/ISBN=0596527500/ref=nosim/cafeaulaitA/
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest





Archive powered by MHonArc 2.6.24.

Top of Page