程序编译没错,运行时候出错
ExceptionConverter: java.net.MalformedURLException
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:807)
at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityManager.java:753)
at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentScannerImpl.java:260)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:499)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at com.lowagie.text.xml.TagMap.init(Unknown Source)
at com.lowagie.text.xml.TagMap.<init>(Unknown Source)
at com.longtop.hr.report.Chap0703.main(Chap0703.java:59)请问是何错误,谢谢了~
ExceptionConverter: java.net.MalformedURLException
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:807)
at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityManager.java:753)
at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentScannerImpl.java:260)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:499)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at com.lowagie.text.xml.TagMap.init(Unknown Source)
at com.lowagie.text.xml.TagMap.<init>(Unknown Source)
at com.longtop.hr.report.Chap0703.main(Chap0703.java:59)请问是何错误,谢谢了~
建议楼主仔细查看你的文本文件,包括不可见字符
<tag name="itext" alias="PLAY" />
<tag name="newpage" alias="NEWPAGE" />
<tag name="newline" alias="NEWLINE" />
<tag name="paragraph" alias="PLAYTITLE">
<attribute name="size" value="18" />
<attribute name="align" value="Center" />
</tag>
<tag name="paragraph" alias="FM">
<attribute name="leading" value="11" />
<attribute name="align" value="Center" />
</tag>
<tag name="paragraph" alias="P">
<attribute name="size" value="9" />
</tag>
<tag name="paragraph" alias="DRAMATISPERSONAE" content="Dramatis Personae">
<attribute name="size" value="14" />
<attribute name="align" value="Center" />
</tag>
<tag name="list" alias="PERSONAE">
<attribute name="numbered" value="false" />
<attribute name="symbolindent" value="20" />
<attribute name="listsymbol" value="o" />
<attribute name="align" value="Left" />
</tag>
<tag name="list" alias="PGROUP">
<attribute name="numbered" value="false" />
<attribute name="symbolindent" value="0" />
<attribute name="listsymbol" value="" />
</tag>
<tag name="listitem" alias="PERSONA">
<attribute name="size" value="11" />
<attribute name="align" value="Left" />
</tag>
<tag name="listitem" alias="GRPDESCR">
<attribute name="size" value="10" />
<attribute name="style" value="italic" />
<attribute name="align" value="Right" />
</tag>
<tag name="paragraph" alias="SCNDESCR">
<attribute name="size" value="11" />
<attribute name="style" value="italic" />
<attribute name="align" value="Justify" />
</tag>
<tag name="paragraph" alias="PLAYSUBT">
<attribute name="size" value="16" />
<attribute name="align" value="Center" />
</tag>
<tag name="title" alias="TITLE">
<attribute name="size" value="14" />
<attribute name="align" value="Center" />
</tag>
<tag name="chapter" alias="ACT">
<attribute name="numberdepth" value="0" />
</tag>
<tag name="section" alias="PROLOGUE">
<attribute name="numberdepth" value="0" />
</tag>
<tag name="section" alias="SCENE">
<attribute name="numberdepth" value="0" />
</tag>
<tag name="section" alias="EPILOGUE">
<attribute name="numberdepth" value="0" />
</tag>
<tag name="paragraph" alias="SUBTITLE">
<attribute name="size" value="12" />
<attribute name="style" value="bold" />
<attribute name="align" value="Center" />
</tag>
<tag name="paragraph" alias="SPEECH">
<attribute name="leading" value="14" />
<attribute name="align" value="Left" />
</tag>
<tag name="paragraph" alias="SPEAKER" content="Speaker: ">
<attribute name="leading" value="16" />
<attribute name="size" value="10" />
<attribute name="style" value="bold" />
</tag>
<tag name="paragraph" alias="LINE">
<attribute name="leading" value="15" />
<attribute name="size" value="11" />
<attribute name="align" value="Left" />
</tag>
<tag name="paragraph" alias="STAGEDIR">
<attribute name="leading" value="14" />
<attribute name="size" value="10" />
<attribute name="style" value="italic" />
<attribute name="align" value="Right" />
</tag>
</tagmap>
ExceptionConverter: java.net.MalformedURLException
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:807)
at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntityManager.java:753)
at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocumentScannerImpl.java:260)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:499)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at com.lowagie.text.xml.TagMap.init(Unknown Source)
at com.lowagie.text.xml.TagMap.<init>(Unknown Source)
at Chap0703.main(Chap0703.java:59)
nullimport java.io.FileOutputStream;import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.xml.*;public class Chap0703 {
public static void main(String[] args) {
System.out.println("Chapter 7 example 3: parsing an XML document with custom tags");
// step 1: creation of a document-object
Document document = new Document(PageSize.A4, 80, 50, 30, 65);
try {
// step 2:
// we create a writer that listens to the document
// and directs a XML-stream to a file
PdfWriter.getInstance(document, new FileOutputStream("Chap0703.pdf"));
// step 3: we create a parser and set the document handler
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
// step 4: we parse the document
// XmlParser.parse(document, "Chap0703.xml","tagmap0703.xml");
TagMap tm=new TagMap("tagmap0703.xml");
parser.parse("Chap0703.xml", new SAXmyHandler(document, tm));
}
catch(Exception e) {
e.printStackTrace();
System.err.println(e.getMessage());
}
}
}