You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by Burkley Frederick G NPRI <Bu...@Npt.NUWC.Navy.Mil> on 2005/12/28 18:59:09 UTC
Using FastInfoset SAX Parser create a XmlBean
This message may be a bit verbose, but please bear with me as I try to establish background.
I have been working on un-marshalling a FastInfoset compressed binary XML document to a XmlBean.
The XmlOptions class lets me specify an org.xml.sax.XMLReader, so I do this via setLoadUseXMLReader(). I am looking at com.sun.xml.fastinfoset.sax.SAXDocumentParser, as it implements XmlReader.
I FastInfoset compressed a simple XML instance document. As background, my XmlBean class is DatabaseConnectionDocument.java and my XML instance is databaseConnection.xml. Now the task is to instantiate a SAXDocumentParser, set the XmlReader in XmlOptions, and call DatabaseConnectionDocument.Factory.parse().
My problem is I am getting a RuntimeException related to setting the Namespaces Feature in FastInfoset. The full text of the exception is below.
I looked into the com.sun.xml.fastinfoset.sax.SAXDocumentParser.java FastInfoset source code. The setFeature(String name, boolean value) method is coded to throw a SAXNotRecognizedException if called as in:
setFeature("http://xml.org/sax/features/namespaces", true);
It looks like this is what is happening at Locale.java line 3320 (I have not looked at the Local.java source code).
So I modified SAXDocumentParser.java to disable the throwing of SAXNotRecognizedException. I re-compiled FastInfoset.jar, then successfully ran my test code. Thus marshalling a FastInfoset compressed XML document to a XmlBean. My test code also appears below.
The bottom line of this (and my question) is:
Am I not configuring something in XmlBeans properly or is there perhaps an issue with FastInfoset? Perhaps the FastInfoset code (SAXDocumentParser.java) ought to no-op the setFeature("http://xml.org/sax/features/namespaces", true) call rather than throwing the SAXNotRecognizedException.
Thanks,
Fred Burkley
Exception in thread "main" java.lang.RuntimeException: Feature not supported: {0}http://xml.org/sax/features/namespaces
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.<init>(Locale.java:3329)
at org.apache.xmlbeans.impl.store.Locale$XmlReaderSaxLoader.<init>(Locale.java:3050)
at org.apache.xmlbeans.impl.store.Locale.getSaxLoader(Locale.java:3026)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1267)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1254)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:252)
at org.mip.xmlBeans.DatabaseConnectionDocument$Factory.parse(DatabaseConnectionDocument.java:59)
at sample.FastInfosetXmlBeanUnmarshaller.main(FastInfosetXmlBeanUnmarshaller.java:121)
Caused by: org.xml.sax.SAXNotRecognizedException: Feature not supported: {0}http://xml.org/sax/features/namespaces
at com.sun.xml.fastinfoset.sax.SAXDocumentParser.setFeature(Unknown Source)
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.<init>(Locale.java:3320)
... 8 more
------ Here is my test code -------------
// Instantiate the FI SAX parser
XMLReader saxReader = new SAXDocumentParser();
xmlOptions = new XmlOptions();
xmlOptions.setLoadUseXMLReader(saxReader);
try {
DatabaseConnectionDocument dcdoc = DatabaseConnectionDocument.Factory.parse(new File(inputFileName), xmlOptions);
System.out.println(dcdoc);
}
catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org