I ran across this ‘error’ this week. After poking around the internet for awhile it looked like this is due to a bug in an older version of the SAX parser in the xerces library.

Well, we have quite a bit of code in production, so can’t just update the jar.

My original code was simply using the class loader to read in an xsd and use the Source of the xsd for a Schema that would be used to validate some xml entered by the user.

I toyed with this some and thought the exception sounded like it thought there was extra cruff after the closing tag of the xsd. So, I read in the xsd to a byte array, as before. I kept track of the byte count of read bytes, looped over the byte array (for that count), added each byte to a StringBuffer then converted the StringBuffer to a String. Voila!