以下の私のxml enter link description here解決方法[org.xml.sax.SAXParseException; lineNumber:1; columnNumber:1;コンテンツはプロローグで許可されていません。]
は私のコーディングは "NMO" を
JAXBContext jaxbContext = JAXBContext.newInstance(NewsMLObj.class);
SAXParserFactory spf = SAXParserFactory.newInstance();
XMLReader xr = spf.newSAXParser().getXMLReader();
// to bypass XML DocType and Entity as Jap did not provide proper XML
xr.setFeature("http://xml.org/sax/features/validation", false);
xr.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
xr.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
xr.setFeature("http://xml.org/sax/features/external-general-entities", false);
xr.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
xr.setFeature("http://xml.org/sax/features/use-entity-resolver2", false);
InputSource is = new InputSource(new FileReader(factoryType.serverXML.getInputFile2() + filename));
SAXSource source = new SAXSource(xr, is);
out.println("input source=" + is);
javax.xml.bind.Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
out.println("jaxbUnmarshaller =" + jaxbUnmarshaller);
NewsMLObj nmo = (NewsMLObj) jaxbUnmarshaller.unmarshal(source);
実行されている場合の例である、それがエラーを持っている「javax.xml.bind.UnmarshalException - リンクされた例外: [org.xml.sax.SAXParseException;行番号:1; ColumnNumberに:図1は、コンテンツは、プロローグでは許可されない。」
javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.]
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unknown Source)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(Unknown Source)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(Unknown Source)
at com.n2n.NekkeiFlashNews.client.imp.PacketToObjectNewsHostServer.processRawNews(PacketToObjectNewsHostServer.java:83)
at com.n2n.NekkeiFlashNews.client.imp.NewsRawFileReceiverThread.run(NewsRawFileReceiverThread.java:57)
at java.lang.Thread.run(Unknown Source)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
... 7 more
私のコーディングに問題はありますか?私の問題を解決するには?
おかげで、宜しく シャロン
XMLが無効であるようです。先頭に印刷できない文字がある場合は、16進エディタを参照してください。 – Jens
@Jens XMLは無効ですか? –
親切に助言してください?どうすればいいですか? –