[Castore-commits] ParserListe.java 1.3.2.1 1.3.2.2
Stéphane Bouchet
sbouchet at adullact1.hosting.cri74.org
Lun 6 Mar 13:29:05 CET 2006
Update of /cvsroot/castore/castore-core/src/java/fr/emn/castor/documents/soumission/resources/liste
In directory adullact1:/tmp/cvs-serv24621/src/java/fr/emn/castor/documents/soumission/resources/liste
Modified Files:
Tag: v1_1_branch
ParserListe.java
Log Message:
correction bug du parsing XML
Index: ParserListe.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/documents/soumission/resources/liste/ParserListe.java,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -C2 -d -r1.3.2.1 -r1.3.2.2
*** ParserListe.java 24 Nov 2005 14:30:19 -0000 1.3.2.1
--- ParserListe.java 6 Mar 2006 12:29:03 -0000 1.3.2.2
***************
*** 47,53 ****
import java.util.LinkedHashMap;
- import javax.xml.parsers.SAXParser;
- import javax.xml.parsers.SAXParserFactory;
-
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
--- 47,50 ----
***************
*** 55,58 ****
--- 52,56 ----
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
+ import org.xml.sax.helpers.XMLReaderFactory;
import fr.emn.castor.common.Constants;
***************
*** 98,106 ****
InputStream in = null;
try {
! SAXParserFactory saxParserFactory = SAXParserFactory
! .newInstance();
! saxParserFactory.setValidating(false);
! SAXParser saxParser = saxParserFactory.newSAXParser();
! this.xmlReader = saxParser.getXMLReader();
this.xmlReader.setContentHandler(this);
this.xmlReader.setErrorHandler(this);
--- 96,101 ----
InputStream in = null;
try {
! this.xmlReader = XMLReaderFactory
! .createXMLReader(Constants.XML_SAX_PARSER);
this.xmlReader.setContentHandler(this);
this.xmlReader.setErrorHandler(this);
***************
*** 128,132 ****
* Constructor.
*/
! public ParserListe(String filePath) {
Mutex mutex = FileMutexManager.getMutexForFileCalled(filePath);
mutex.lock();
--- 123,127 ----
* Constructor.
*/
! public ParserListe (String filePath) {
Mutex mutex = FileMutexManager.getMutexForFileCalled(filePath);
mutex.lock();
***************
*** 170,176 ****
StringBuffer buf = new StringBuffer();
buf.append(text, start, length);
this.charBuf.append(buf.toString().trim());
- // on ajoute tout de meme un caractere espace a la fin.
- this.charBuf.append(" ");
}
--- 165,176 ----
StringBuffer buf = new StringBuffer();
buf.append(text, start, length);
+ // si on a pas vidé le buffer, on rajoute un espace entre
+ // les caracteres
+ // on vérifie tout de meme si on est pas au début du buffer de lecture
+ // de SAX, sinon on insere un espace en trop !
+ if ((this.charBuf.length() > 0) && (start != 0)) {
+ this.charBuf.append(" ");
+ }
this.charBuf.append(buf.toString().trim());
}
***************
*** 183,191 ****
if (this.inElementValue) {
this.currentValue = this.charBuf.toString().trim();
- this.charBuf.setLength(0);
this.inElementValue = false;
} else if (this.inLabelValue) {
this.currentLabel = this.charBuf.toString().trim();
- this.charBuf.setLength(0);
this.inLabelValue = false;
} else if (this.inElementList) {
--- 183,189 ----
***************
*** 201,204 ****
--- 199,203 ----
this.currentValue = null;
}
+ this.charBuf.setLength(0);
}
Plus d'informations sur la liste de diffusion Castore-commits