Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strange XML Parsing problem

1 view
Skip to first unread message

Steve Goyette

unread,
Sep 5, 2002, 3:34:42 PM9/5/02
to
Hi All,

I have the following XML being output from my server:

<?xml version="1.0"?>
<Server Name="bit-slap">
<Memory Max="128.0" Used="4.0" Free="0.0" Total="4.0"/>
<DB FreeConnections="2" BusyConnections="0"/>
<Item Hits="0" Requests="14" Size="14" Name="DataObject"/>
<Item Hits="0" Requests="6" Size="6" Name="SectionFile"/>
</Server>

If I use the following code to parse it into a DOM Document and dump it to
stderr:
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
org.w3c.dom.Document doc = builder.parse( theUrl );
javax.xml.transform.TransformerFactory tFactory =
javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer transformer = tFactory.newTransformer();
transformer.transform( new javax.xml.transform.dom.DOMSource( doc ), new
javax.xml.transform.stream.StreamResult( System.err ) );
} catch ( Exception e ) {
e.printStackTrace();
}

I get this:

<?xml version="1.0"?>
<Server Name="bit-slap"><Memory Max="128.0" Used="15.0" Free="1.0"
Total="16.0"/><DB FreeConnections="0" BusyConnections="0"/></Server>

Now the problem is that the <item elements are missing. If I use a SAX
parser then I get the same behaviour. I've even created a DTD to go with it
to see if it made a difference and nada.
The server I'm using is Resin 2.1.4 and I've just updated to j2sdk 1.4.1 to
make sure it wasn't a version specific bug. I've also tried installing
xerces and doing the following:

System.setProperty(
"javax.xml.parsers.SAXParserFactory","org.apache.xerces.jaxp.SAXParserFactor
yImpl" );

This made absolutely no difference so it would lead me to believe there's
something wrong with the XML but if I run it through XML Spy or XML mind
both say it's valid XML.....what gives?

Can ANYONE see what's wrong with this code?

Thanks in Advance,

Steve


0 new messages