<bookpic>images\da0817.jpg</bookpic>
和 
<bookpdfpath>book\da0817.pdf</bookpdfpath>
应该是一样的 
没道理会有错看看解析的程序吧

解决方案 »

  1.   

    不是,绝大多数图书信息解析都没有问题,只有几个图书会有问题,会出现两个连续bookpdfpath。
      

  2.   

    难道xml文件不是你生成的
    查xml文件的生成部分
      

  3.   

    xml是我生成的,我看了没有问题。之前用ibm的parser解析xml的时候也有这个问题,我只要在xml里面加几个回车就好了。
      

  4.   

    我这刚在做着点,让你看看我的代码,用的是基本的jaxp,sax 而已
    是一个问题对应几个答案或者资源。xml 结构:
    <?xml version="1.0" encoding="GB2312"?>
    <!DOCTYPE questions
         PUBLIC "-//Amid co, Ltd.//DTD TK Application 1.0//CH"
        "http://211.94.206.59/dtd/tk.dtd">
    <questions>
    <question difficult="1" correctSeq="2">
    <question-content>循环使用???</question-content>
    <question-Resource seq="1" resType="A" mediaType="1" content="生的费用由该号码承"/>
    <question-Resource seq="2" resType="A" mediaType="1" content="2:按条计费"/>
    <question-Resource seq="3" resType="A" mediaType="1" content="承担"/>
    </question>
    </questions>
    DefaultHandler progress:
    package com.unicom.race.util.xml;import org.xml.sax.Attributes;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;import com.unicom.race.admin.dao.Answer;
    import com.unicom.race.admin.dao.Question;
    import com.unicom.race.admin.dao.QuestionDAO;
    import com.unicom.race.util.*;import java.util.Vector;
    import java.text.SimpleDateFormat;
    import java.sql.Timestamp;/**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2003</p>
     * <p>Company: </p>
     * @author rex
     * @version 1.0
     */public class ParserProcess  extends DefaultHandler { private String currentName;
    private StringBuffer currentValue = new StringBuffer();
    private StringBuffer buf = new StringBuffer();
    Question question = null;
    Vector vet = null;
    int group_id ;
    int cpid ;
    Timestamp createTime ;
    String uni_id ;
    int processID ;
    int questionId; public ParserProcess() {
    } public ParserProcess(int cpId, int groupId) { this.group_id = groupId;
    this.cpid = cpId; long mills = System.currentTimeMillis();
    createTime = new Timestamp(mills); uni_id = "";
    processID = 0;
    questionId = 0;
    }
    /*  指定名称空间
    <surveys xmlns="http://www.nicholaschase.com/surveys/"
    xmlns:rating="http://www.nicholaschase.com/surveys/revised/">
    */
    //定义开始解析元素的方法. 这里是将<xxx>中的名称xxx提取出来. public void startElement(String namespaceURI, String localName,
     String qName, Attributes attributes)
    throws SAXException { //System.out.println("qName:"+qName);
    currentValue.delete(0, currentValue.length());
    if(qName != null && qName.equals("question")){
    question = new Question();
    vet = new Vector();
    //本次序号
    this.processID = this.processID + 1; String cpidStr = UtilTools.expandStringEnd(Integer.toString(cpid),"0",11);
    SimpleDateFormat f1 = new SimpleDateFormat("yyMMddHHmmss");
    String strdate = f1.format(createTime);
    String processIDStr = UtilTools.expandStringEnd(Integer.toString(this.processID),"0",5); //System.out.println("question:"+qName+"processID"+processIDStr);
    this.uni_id = processIDStr + strdate + cpidStr; question.setCpId(this.cpid);
    question.setGroupId(this.group_id);
    question.setUniID(this.uni_id);
    question.setDiffLevel( Integer.parseInt(attributes.getValue("difficult")));
    question.setSeq(attributes.getValue("correctSeq"));
    question.setCreateTime(this.createTime); } if(qName != null && qName.equals("question-Resource")){
    //System.out.println("question-Resource:"+qName);
    Answer answer = new Answer();
    answer.setSeq(attributes.getValue("seq"));
    answer.setMediaType(Integer.parseInt(attributes.getValue("mediaType")));
    answer.setFlag(attributes.getValue("resType"));
    try{
    answer.setContent( new String(attributes.getValue("content").getBytes("GB2312") ));
    }catch(Exception e){
    System.out.println(e.toString());
    }
    vet.add(answer);
    }
    this.currentName =qName;
    //检查名称空间
    //属性也可以属于特定的名称空
    //Attributes 列表有一些允许您确定属性的名称空间的方法。
    //使用这些 getURI() 和 getQName 方法非常类似于元素本身的 qname 和 localName 方法。 /*
    if (namespaceURI == "http://www.nicholaschase.com/surveys/") {
    if (localName == "question") {
    this.Question = attributes.getValue("subject");
    }
    }
    */ } //这里是将<xxx></xxx>之间的值加入到currentValue public void characters(char[] ch, int start, int length)
    throws SAXException { currentValue.append(ch, start, length); if(this.currentName != null && this.currentName.equals("question-content")){
    try{
    question.setContent( new String(currentValue.toString().getBytes("GB2312")));
    }catch(Exception e){
    System.out.println(e.toString());
    }
    }
    //System.out.println(currentValue.toString());
    } //在遇到</xxx>结束后,将之前的名称和值一一对应保存在props中 public void endElement(String uri, String localName, String qName)
    throws SAXException { //System.out.println("qName:"+qName);
    currentValue.delete(0, currentValue.length());
    if(qName != null && qName.equals("question")){
    if(question != null){
    //建立问题
    try{ question.create();
    this.questionId = QuestionDAO.getQuestionId(this.uni_id);
    System.out.println(" questionId:"+this.questionId
       +" MediaType:"+question.getMediaType() + " created!");
    if(vet != null && vet.size() > 0){
    for(int i=0;i<vet.size();i++){
    Answer answerTemp = (Answer)vet.elementAt(i);
    answerTemp.setQuestionId(this.questionId);
    answerTemp.create();
    }
    }
    question = null;
    if( vet != null ){
    vet.removeAllElements();
    vet.trimToSize();
    vet = null;
    }
    }catch(Exception e){
    if(e instanceof SAXException){
    throw (SAXException)e;
    }
    System.out.println("error in create Questions & answers:"+e.toString());
    Logger.log("error in create Questions & answers by XML file:\n"+e.toString());
    } }
    }
    } public void startDocument()
    throws SAXException {
    //System.out.println("start parsering XML document...\n");
    }
    public void endDocument() {
    //System.out.println("end parsering XML document...\n");
    } /**
     其它应用程序可以以类似的方式来获取信息。
     <?xml version="1.0" encoding="UTF-8"?>
     <?SurveyReader factor="2" ?>
     <surveys>
     ...
     processingInstruction() 事件将会拾取它,该事件将它划分成 target 和 data。
     */
    public void processingInstruction(String target, String data)
    throws SAXException {
    System.out.println("Target = ("+target+")");
    System.out.println("Data = ("+data+")");
    }}
      

  5.   

    我的程序也大概如此,就是不知道你这程序能不能够处理很多信息,比如有2000条questions会不会出问题?