[Castore-commits] TypeDoc.java 1.1.2.1 1.1.2.2 ParserTypeDoc.java
1.2.2.1 1.2.2.2 ParserMappingFamille.java 1.2.2.1 1.2.2.2
Stéphane Bouchet
sbouchet at adullact1.hosting.cri74.org
Lun 6 Mar 11:18:51 CET 2006
Update of /cvsroot/castore/castore-core/src/java/fr/emn/castor/admin/gestionTypeDoc
In directory adullact1:/tmp/cvs-serv31324/src/java/fr/emn/castor/admin/gestionTypeDoc
Modified Files:
Tag: v1_1_branch
TypeDoc.java ParserTypeDoc.java ParserMappingFamille.java
Log Message:
correction du bug de parsing XML.
Index: ParserMappingFamille.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/admin/gestionTypeDoc/ParserMappingFamille.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -d -r1.2.2.1 -r1.2.2.2
*** ParserMappingFamille.java 24 Nov 2005 14:30:06 -0000 1.2.2.1
--- ParserMappingFamille.java 6 Mar 2006 10:18:49 -0000 1.2.2.2
***************
*** 48,54 ****
import javax.xml.parsers.FactoryConfigurationError;
- import javax.xml.parsers.ParserConfigurationException;
- import javax.xml.parsers.SAXParser;
- import javax.xml.parsers.SAXParserFactory;
import org.apache.commons.logging.Log;
--- 48,51 ----
***************
*** 59,62 ****
--- 56,60 ----
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
+ import org.xml.sax.helpers.XMLReaderFactory;
import fr.emn.castor.common.Constants;
***************
*** 107,111 ****
* Constructor.
*/
! public ParserMappingFamille() {
try {
String filePath = Constants.CASTOR_TYPEDOC_MAPPING_FILE_PATH;
--- 105,109 ----
* Constructor.
*/
! public ParserMappingFamille () {
try {
String filePath = Constants.CASTOR_TYPEDOC_MAPPING_FILE_PATH;
***************
*** 116,128 ****
inputsource.setSystemId(testURL.getPath());
this.entrepot = new Entrepot("Castor", this.listevide);
! SAXParserFactory saxParserFactory = SAXParserFactory
! .newInstance();
! saxParserFactory.setValidating(false);
! SAXParser saxParser = saxParserFactory.newSAXParser();
! this.xmlReader = saxParser.getXMLReader();
this.xmlReader.setContentHandler(this);
this.xmlReader.setErrorHandler(this);
this.xmlReader.parse(inputsource);
-
} catch (FileNotFoundException e) {
if (log.isErrorEnabled()) {
--- 114,122 ----
inputsource.setSystemId(testURL.getPath());
this.entrepot = new Entrepot("Castor", this.listevide);
! this.xmlReader = XMLReaderFactory
! .createXMLReader(Constants.XML_SAX_PARSER);
this.xmlReader.setContentHandler(this);
this.xmlReader.setErrorHandler(this);
this.xmlReader.parse(inputsource);
} catch (FileNotFoundException e) {
if (log.isErrorEnabled()) {
***************
*** 133,140 ****
log.error(e.getMessage(), e);
}
- } catch (ParserConfigurationException e) {
- if (log.isErrorEnabled()) {
- log.error(e.getMessage(), e);
- }
} catch (SAXException e) {
if (log.isErrorEnabled()) {
--- 127,130 ----
***************
*** 149,153 ****
}
! public ParserMappingFamille(String filePath) {
try {
File file = new File(filePath);
--- 139,143 ----
}
! public ParserMappingFamille (String filePath) {
try {
File file = new File(filePath);
***************
*** 157,165 ****
inputsource.setSystemId(testURL.getPath());
this.entrepot = new Entrepot("Castor", this.listevide);
! SAXParserFactory saxParserFactory = SAXParserFactory
! .newInstance();
! saxParserFactory.setValidating(false);
! SAXParser saxParser = saxParserFactory.newSAXParser();
! this.xmlReader = saxParser.getXMLReader();
this.xmlReader.setContentHandler(this);
this.xmlReader.setErrorHandler(this);
--- 147,152 ----
inputsource.setSystemId(testURL.getPath());
this.entrepot = new Entrepot("Castor", this.listevide);
! this.xmlReader = XMLReaderFactory
! .createXMLReader(Constants.XML_SAX_PARSER);
this.xmlReader.setContentHandler(this);
this.xmlReader.setErrorHandler(this);
***************
*** 173,180 ****
log.error(e.getMessage(), e);
}
- } catch (ParserConfigurationException e) {
- if (log.isErrorEnabled()) {
- log.error(e.getMessage(), e);
- }
} catch (SAXException e) {
if (log.isErrorEnabled()) {
--- 160,163 ----
***************
*** 227,231 ****
} else if (qName.equals("file")) {
this.inFiles = true;
- this.charBuf.setLength(0);
} else if (qName.equals("workflow")) {
this.currentTypeDoc.setWorkflowid(attributes.getValue("id"));
--- 210,213 ----
***************
*** 242,248 ****
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(" ");
}
--- 224,235 ----
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());
}
***************
*** 276,282 ****
} else if (qName.equals("file")) {
this.currentTypeDoc.addFile(this.charBuf.toString().trim());
- this.charBuf.setLength(0);
this.inFiles = false;
}
}
--- 263,269 ----
} else if (qName.equals("file")) {
this.currentTypeDoc.addFile(this.charBuf.toString().trim());
this.inFiles = false;
}
+ this.charBuf.setLength(0);
}
Index: TypeDoc.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/admin/gestionTypeDoc/TypeDoc.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** TypeDoc.java 24 Nov 2005 14:30:05 -0000 1.1.2.1
--- TypeDoc.java 6 Mar 2006 10:18:49 -0000 1.1.2.2
***************
*** 131,136 ****
this.datePublication = datePublication;
this.commentaire = commentaire;
- // TODO a reexternaliser
- this.files.add("MD_Base1.xml");
}
--- 131,134 ----
***************
*** 158,163 ****
this.datePublication = datePublication;
this.commentaire = commentaire;
- // TODO a reexternaliser
- this.files.add("MD_Base1.xml");
}
--- 156,159 ----
***************
*** 206,211 ****
Date date = new Date();
this.dateCreation = dateFormat.format(date).toString();
- // TODO a reexternaliser
- this.files.add("MD_Base1.xml");
}
--- 202,205 ----
***************
*** 221,226 ****
this.createur = "";
this.commentaire = "";
- // // TODO a reexternaliser
- this.files.add("MD_Base1.xml");
}
--- 215,218 ----
Index: ParserTypeDoc.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/admin/gestionTypeDoc/ParserTypeDoc.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -d -r1.2.2.1 -r1.2.2.2
*** ParserTypeDoc.java 24 Nov 2005 14:30:06 -0000 1.2.2.1
--- ParserTypeDoc.java 6 Mar 2006 10:18:49 -0000 1.2.2.2
***************
*** 61,64 ****
--- 61,65 ----
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
+ import org.xml.sax.helpers.XMLReaderFactory;
import fr.emn.castor.common.Constants;
***************
*** 104,108 ****
* Constructor.
*/
! public ParserTypeDoc(ArrayList mdFiles) {
try {
for (Iterator iter = mdFiles.iterator(); iter.hasNext();) {
--- 105,109 ----
* Constructor.
*/
! public ParserTypeDoc (ArrayList mdFiles) {
try {
for (Iterator iter = mdFiles.iterator(); iter.hasNext();) {
***************
*** 114,122 ****
InputSource inputsource = new InputSource(in);
inputsource.setSystemId(testURL.getPath());
! SAXParserFactory saxParserFactory = SAXParserFactory
! .newInstance();
! saxParserFactory.setValidating(false);
! SAXParser saxParser = saxParserFactory.newSAXParser();
! this.xmlReader = saxParser.getXMLReader();
this.xmlReader.setContentHandler(this);
this.xmlReader.setErrorHandler(this);
--- 115,120 ----
InputSource inputsource = new InputSource(in);
inputsource.setSystemId(testURL.getPath());
! this.xmlReader = XMLReaderFactory
! .createXMLReader(Constants.XML_SAX_PARSER);
this.xmlReader.setContentHandler(this);
this.xmlReader.setErrorHandler(this);
***************
*** 131,138 ****
log.error(e.getMessage(), e);
}
- } catch (ParserConfigurationException e) {
- if (log.isErrorEnabled()) {
- log.error(e.getMessage(), e);
- }
} catch (SAXException e) {
if (log.isErrorEnabled()) {
--- 129,132 ----
***************
*** 202,208 ****
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(" ");
}
--- 196,207 ----
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());
}
Plus d'informations sur la liste de diffusion Castore-commits