2010-03-04 156 views
1

我的XML文件是這樣的:需要幫助解決XML解析器錯誤

<?xml version="1.0" encoding="UTF-8"?> 
<table_data name="finals"> 
    <row id="2706" lat="40.6894729000" lng="-73.9692572000" body="Rumor:owner does buybacks atBrooklyn Public House in Fort Greene...are the bartenders as nice? #bars #nyC#fortgreene - www.buybacknyc.com"/> 
    <row id="2707" lat="40.7127490000" lng="-73.9567950000" body="http://twitpic.com/163iax - Ottoman Lounge on Grand Street in Williamsburg Brooklyn, next to Taco Chulo restaurant."/> 
    <row id="2708" lat="40.7127490000" lng="-73.9567950000" body="RT @NYCphotos: http://twitpic.com/163iax - Ottoman Lounge on Grand Street in Williamsburg Brooklyn, next to Taco Chulo restaurant."/> 
</table_data> 

在使用ant索引中solr-1.5這個文件,我得到了錯誤:

[java] Exception in thread "main" org.xml.sax.SAXParseException: Element type "row" must be followed by either attribute specifications, ">" or "/>". 
    [java]  at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) 
    [java]  at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174) 
    [java]  at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388) 
    [java]  at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1411) 
    [java]  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.seekCloseOfStartTag(XMLDocumentFragmentScannerImpl.java:1391) 
    [java]  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1324) 
    [java]  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2747) 
    [java]  at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) 
    [java]  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) 
    [java]  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807) 
    [java]  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) 
    [java]  at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107) 
    [java]  at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) 
    [java]  at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) 
    [java]  at javax.xml.parsers.SAXParser.parse(SAXParser.java:395) 
    [java]  at javax.xml.parsers.SAXParser.parse(SAXParser.java:198) 
    [java]  at OSM2Solr.process(OSM2Solr.java:44) 
    [java]  at Driver.main(Driver.java:80) 
    [java] Java Result: 1 

BUILD SUCCESSFUL 

我的元素「行」後面是屬性,爲什麼我得到這個錯誤?

請幫我一把。

在此先感謝。

+0

是您在此處發佈的XML,是從生產環境中複製/粘貼的嗎?或者你是否以任何方式改變它。你得到的錯誤通常意味着屬性之間缺少空格,或者是「在屬性值中打破XML ... – 2010-03-04 14:21:56

+2

根據這個:http://wiki.openstreetmap.org /wiki/.osm這不是一個有效的OSM – 2010-03-04 14:47:18

+0

解析器錯誤得到解決,文件中有1個無效元素 謝謝 Mauricio-是否有必要對任何位置感知搜索數據必須以.osm格式?(我在索爾索引的數據是上面指定的xml格式)。 – kshama 2010-03-05 06:38:30

回答

0

我有同樣的錯誤。

我的問題是schema.xml中的模式名稱。架構名稱必須是1個字!

<schema name="My Schema" version="0.1"> FAIL! 

<schema name="MySchema" version="0.1"> RIGHT!