クラス org.objectweb.cjdbc.common.xml.XmlValidator

すべてのメンバ一覧

説明

Validate a document and its DTD.

作者:
Nicolas Modrzyk

XmlValidator.java51 行で定義されています。

Public メソッド

 XmlValidator (String pathToDtd, String xml)
 XmlValidator (String pathToDtd, FileReader file) throws IOException
String getXmlContent ()
void validate (String pathToDtd, String xml)
InputSource resolveEntity (String publicId, String systemId) throws SAXException
void error (SAXParseException exception) throws SAXException
void fatalError (SAXParseException exception) throws SAXException
void warning (SAXParseException exception) throws SAXException
void endDocument () throws SAXException
boolean isValid ()
Exception getLastException ()
ArrayList getExceptions ()
void comment (char[] ch, int start, int length) throws SAXException
void endCDATA () throws SAXException
void endDTD () throws SAXException
void endEntity (String name) throws SAXException
void startCDATA () throws SAXException
void startDTD (String name, String publicId, String systemId) throws SAXException
void startEntity (String name) throws SAXException
boolean isDtdValid ()
void setDtdValid (boolean isDtdValid)
boolean isXmlValid ()
void setXmlValid (boolean isXmlValid)
ArrayList getWarnings ()

Static Public メソッド

void main (String args[]) throws Exception

Private メソッド

void addError (Exception e)

Private 変数

XMLReader parser
String pathToDtd
boolean isXmlValid = false
boolean isDtdValid = false
String xmlContent
ArrayList errors
ArrayList warnings


コンストラクタとデストラクタ

org.objectweb.cjdbc.common.xml.XmlValidator.XmlValidator String  pathToDtd,
String  xml
 

Check the given dtd, and the given xml are valid.

引数:
pathToDtd path to dtd
xml source to parse as a string
XmlValidator.java138 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.validate().

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.main().

00139 { 00140 validate(pathToDtd, xml); 00141 }

org.objectweb.cjdbc.common.xml.XmlValidator.XmlValidator String  pathToDtd,
FileReader  file
throws IOException
 

参照:
XmlValidator(String pathToDtd,String xml)
XmlValidator.java146 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.pathToDtd, org.objectweb.cjdbc.common.xml.XmlValidator.validate(), と org.objectweb.cjdbc.common.xml.XmlValidator.xmlContent.

00147 { 00148 // Read the file 00149 BufferedReader in = new BufferedReader(file); 00150 StringBuffer xml = new StringBuffer(); 00151 String line; 00152 do 00153 { 00154 line = in.readLine(); 00155 if (line != null) 00156 xml.append(line.trim()); 00157 } 00158 while (line != null); 00159 xmlContent = xml.toString(); 00160 validate(pathToDtd, xmlContent); 00161 }


メソッド

void org.objectweb.cjdbc.common.xml.XmlValidator.addError Exception  e  )  [private]
 

XmlValidator.java405 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.errors.

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.error(), org.objectweb.cjdbc.common.xml.XmlValidator.fatalError(), org.objectweb.cjdbc.common.xml.XmlValidator.resolveEntity(), と org.objectweb.cjdbc.common.xml.XmlValidator.validate().

00406 { 00407 errors.add(e); 00408 }

void org.objectweb.cjdbc.common.xml.XmlValidator.comment char[]  ch,
int  start,
int  length
throws SAXException
 

参照:
org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
XmlValidator.java317 行で定義されています。
00318 { 00319 }

void org.objectweb.cjdbc.common.xml.XmlValidator.endCDATA  )  throws SAXException
 

参照:
org.xml.sax.ext.LexicalHandler#endCDATA()
XmlValidator.java324 行で定義されています。
00325 { 00326 }

void org.objectweb.cjdbc.common.xml.XmlValidator.endDocument  )  throws SAXException
 

参照:
org.xml.sax.ContentHandler#endDocument()
XmlValidator.java277 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.errors.

00278 { 00279 if (errors.size() == 0) 00280 this.isXmlValid = true; 00281 }

void org.objectweb.cjdbc.common.xml.XmlValidator.endDTD  )  throws SAXException
 

参照:
org.xml.sax.ext.LexicalHandler#endDTD()
XmlValidator.java331 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.errors, と org.objectweb.cjdbc.common.xml.XmlValidator.isDtdValid.

00332 { 00333 if (errors.size() == 0) 00334 { 00335 isDtdValid = true; 00336 } 00337 else 00338 { 00339 isDtdValid = false; 00340 } 00341 }

void org.objectweb.cjdbc.common.xml.XmlValidator.endEntity String  name  )  throws SAXException
 

参照:
org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
XmlValidator.java346 行で定義されています。
00347 { 00348 }

void org.objectweb.cjdbc.common.xml.XmlValidator.error SAXParseException  exception  )  throws SAXException
 

参照:
org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
XmlValidator.java253 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.addError().

00254 { 00255 addError(exception); 00256 }

void org.objectweb.cjdbc.common.xml.XmlValidator.fatalError SAXParseException  exception  )  throws SAXException
 

参照:
org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
XmlValidator.java261 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.addError().

00262 { 00263 addError(exception); 00264 }

ArrayList org.objectweb.cjdbc.common.xml.XmlValidator.getExceptions  ) 
 

Retrieve an ArrayList of all parsing exceptions

戻り値:
an ArrayList of Exception
XmlValidator.java309 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.errors.

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.main(), org.objectweb.cjdbc.controller.xml.DatabasesParser.readXML(), org.objectweb.cjdbc.controller.xml.ControllerParser.readXML(), と org.objectweb.cjdbc.console.gui.threads.GuiParsingThread.run().

00310 { 00311 return errors; 00312 }

Exception org.objectweb.cjdbc.common.xml.XmlValidator.getLastException  ) 
 

Return the last cause of parsing failure

戻り値:
exception, null if no exception
XmlValidator.java296 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.errors.

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.main().

00297 { 00298 if (errors.size() == 0) 00299 return null; 00300 else 00301 return (Exception) errors.get(errors.size() - 1); 00302 }

ArrayList org.objectweb.cjdbc.common.xml.XmlValidator.getWarnings  ) 
 

戻り値:
Returns the warnings.
XmlValidator.java413 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.warnings.

参照元 org.objectweb.cjdbc.controller.xml.DatabasesParser.readXML(), と org.objectweb.cjdbc.controller.xml.ControllerParser.readXML().

00414 { 00415 return warnings; 00416 }

String org.objectweb.cjdbc.common.xml.XmlValidator.getXmlContent  ) 
 

get the xml that was formatted

戻り値:
xml
XmlValidator.java168 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.xmlContent.

00169 { 00170 return xmlContent; 00171 }

boolean org.objectweb.cjdbc.common.xml.XmlValidator.isDtdValid  ) 
 

戻り値:
Returns the isDtdValid.
XmlValidator.java376 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.isDtdValid.

00377 { 00378 return isDtdValid; 00379 }

boolean org.objectweb.cjdbc.common.xml.XmlValidator.isValid  ) 
 

戻り値:
Returns the isXmlValid.
XmlValidator.java286 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.isDtdValid, と org.objectweb.cjdbc.common.xml.XmlValidator.isXmlValid.

参照元 org.objectweb.cjdbc.controller.xml.DatabasesParser.readXML(), と org.objectweb.cjdbc.controller.xml.ControllerParser.readXML().

00287 { 00288 return isXmlValid && isDtdValid; 00289 }

boolean org.objectweb.cjdbc.common.xml.XmlValidator.isXmlValid  ) 
 

戻り値:
Returns the isXmlValid.
XmlValidator.java392 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.isXmlValid.

00393 { 00394 return isXmlValid; 00395 }

void org.objectweb.cjdbc.common.xml.XmlValidator.main String  args[]  )  throws Exception [static]
 

Allow to use the xml validator as an external program

引数:
args the xmlfile and the dtd file
例外:
Exception if fails
XmlValidator.java72 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.errors, org.objectweb.cjdbc.common.xml.XmlValidator.getExceptions(), org.objectweb.cjdbc.common.xml.XmlValidator.getLastException(), org.objectweb.cjdbc.common.xml.XmlValidator.isDtdValid, org.objectweb.cjdbc.common.xml.XmlValidator.isXmlValid, と org.objectweb.cjdbc.common.xml.XmlValidator.XmlValidator().

00073 { 00074 if(args.length<1 || args.length >2) 00075 { 00076 System.out.println("usage: XmlValidator [xmlFile] ([dtd]) "); 00077 System.exit(0); 00078 } 00079 00080 String fileName = args[0]; 00081 String dtdName = ControllerConstants.C_JDBC_DTD_FILE; 00082 if(args.length == 2) 00083 dtdName = args[1]; 00084 else 00085 System.out.println("Using default DTD:"+ControllerConstants.C_JDBC_DTD_FILE); 00086 00087 File dtd = null; 00088 dtd = new File(ClassLoader.getSystemResource(dtdName).getFile()); 00089 File xmlFile = null; 00090 try 00091 { 00092 xmlFile = new File(ClassLoader.getSystemResource(fileName).getFile()); 00093 } 00094 catch (RuntimeException e) 00095 { 00096 xmlFile = new File(fileName); 00097 } 00098 00099 if(!dtd.exists()) 00100 { 00101 System.out.println("Cannot find specified dtd"); 00102 System.exit(1); 00103 } 00104 if(!xmlFile.exists()) 00105 { 00106 System.out.println("Cannot find specified xml file"); 00107 System.exit(1); 00108 } 00109 00110 System.out.println("Validating:\tFile:" + xmlFile.getName() + " with dtd:" + dtd.getName()); 00111 00112 // Validate xml and dtd 00113 XmlValidator validator = new XmlValidator(dtd.getAbsolutePath(),new FileReader(xmlFile)); 00114 00115 // Display Results 00116 if (!validator.isDtdValid()) 00117 System.out.println("[FAILED:Dtd is not valid]"); 00118 else if (!validator.isXmlValid()) 00119 System.out.println("[FAILED:xml is not valid]"); 00120 else if (validator.isXmlValid()) 00121 System.out.println("[OK]"); 00122 00123 if (validator.getLastException() != null) 00124 { 00125 ArrayList errors = validator.getExceptions(); 00126 for (int i = 0; i < errors.size(); i++) 00127 System.out.println("\t(parsing error):" 00128 + ((Exception) errors.get(i)).getMessage()); 00129 } 00130 }

InputSource org.objectweb.cjdbc.common.xml.XmlValidator.resolveEntity String  publicId,
String  systemId
throws SAXException
 

Allows to parse the document with a local copy of the DTD whatever the original DOCTYPE found. Warning, this method is called only if the XML document contains a DOCTYPE.

参照:
org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
XmlValidator.java220 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.addError(), と org.objectweb.cjdbc.common.xml.XmlValidator.pathToDtd.

00222 { 00223 00224 File dtd = new File(pathToDtd); 00225 if (dtd.exists()) 00226 { 00227 try 00228 { 00229 FileReader reader = new FileReader(dtd); 00230 return new InputSource(reader); 00231 } 00232 catch (Exception e) 00233 { //impossible 00234 } 00235 } 00236 00237 InputStream stream = XmlValidator.class 00238 .getResourceAsStream("/" + pathToDtd); 00239 if (stream == null) 00240 { 00241 SAXException sax = new SAXException(Translate.get( 00242 "virtualdatabase.xml.dtd.not.found", pathToDtd)); 00243 addError(sax); 00244 throw sax; 00245 } 00246 00247 return new InputSource(stream); 00248 }

void org.objectweb.cjdbc.common.xml.XmlValidator.setDtdValid boolean  isDtdValid  ) 
 

引数:
isDtdValid The isDtdValid to set.
XmlValidator.java384 行で定義されています。
00385 { 00386 this.isDtdValid = isDtdValid; 00387 }

void org.objectweb.cjdbc.common.xml.XmlValidator.setXmlValid boolean  isXmlValid  ) 
 

引数:
isXmlValid The isXmlValid to set.
XmlValidator.java400 行で定義されています。
00401 { 00402 this.isXmlValid = isXmlValid; 00403 }

void org.objectweb.cjdbc.common.xml.XmlValidator.startCDATA  )  throws SAXException
 

参照:
org.xml.sax.ext.LexicalHandler#startCDATA()
XmlValidator.java353 行で定義されています。
00354 { 00355 }

void org.objectweb.cjdbc.common.xml.XmlValidator.startDTD String  name,
String  publicId,
String  systemId
throws SAXException
 

参照:
org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
XmlValidator.java361 行で定義されています。
00363 { 00364 }

void org.objectweb.cjdbc.common.xml.XmlValidator.startEntity String  name  )  throws SAXException
 

参照:
org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
XmlValidator.java369 行で定義されています。
00370 { 00371 }

void org.objectweb.cjdbc.common.xml.XmlValidator.validate String  pathToDtd,
String  xml
 

Starts the verification of the xml document AND the dtd

引数:
pathToDtd path
xml content
XmlValidator.java179 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.addError(), org.objectweb.cjdbc.common.xml.XmlValidator.errors, org.objectweb.cjdbc.common.xml.XmlValidator.isXmlValid, org.objectweb.cjdbc.common.xml.XmlValidator.parser, と org.objectweb.cjdbc.common.xml.XmlValidator.warnings.

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.XmlValidator().

00180 { 00181 System.setProperty("org.xml.sax.driver", 00182 "org.apache.crimson.parser.XMLReaderImpl"); 00183 errors = new ArrayList(); 00184 warnings = new ArrayList(); 00185 try 00186 { 00187 // Store dtd reference 00188 this.pathToDtd = pathToDtd; 00189 // Instantiate a new parser 00190 parser = XMLReaderFactory.createXMLReader(); 00191 // Activate validation 00192 parser.setFeature("http://xml.org/sax/features/validation", true); 00193 // Install error handler 00194 parser.setErrorHandler(this); 00195 // Install document handler 00196 parser.setContentHandler(this); 00197 parser.setProperty("http://xml.org/sax/properties/lexical-handler", this); 00198 // Install local entity resolver 00199 parser.setEntityResolver(this); 00200 InputSource input = new InputSource(new StringReader(xml)); 00201 parser.parse(input); 00202 } 00203 catch (Exception e) 00204 { 00205 //throw new Exception("Xml document can not be validated."); 00206 //e.printStackTrace(); 00207 addError(e); 00208 isXmlValid = false; 00209 } 00210 }

void org.objectweb.cjdbc.common.xml.XmlValidator.warning SAXParseException  exception  )  throws SAXException
 

参照:
org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
XmlValidator.java269 行で定義されています。

参照先 org.objectweb.cjdbc.common.xml.XmlValidator.warnings.

00270 { 00271 warnings.add(exception); 00272 }


変数

ArrayList org.objectweb.cjdbc.common.xml.XmlValidator.errors [private]
 

XmlValidator.java63 行で定義されています。

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.addError(), org.objectweb.cjdbc.common.xml.XmlValidator.endDocument(), org.objectweb.cjdbc.common.xml.XmlValidator.endDTD(), org.objectweb.cjdbc.common.xml.XmlValidator.getExceptions(), org.objectweb.cjdbc.common.xml.XmlValidator.getLastException(), org.objectweb.cjdbc.common.xml.XmlValidator.main(), と org.objectweb.cjdbc.common.xml.XmlValidator.validate().

boolean org.objectweb.cjdbc.common.xml.XmlValidator.isDtdValid = false [private]
 

XmlValidator.java61 行で定義されています。

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.endDTD(), org.objectweb.cjdbc.common.xml.XmlValidator.isDtdValid(), org.objectweb.cjdbc.common.xml.XmlValidator.isValid(), org.objectweb.cjdbc.common.xml.XmlValidator.main(), org.objectweb.cjdbc.controller.xml.DatabasesParser.readXML(), と org.objectweb.cjdbc.controller.xml.ControllerParser.readXML().

boolean org.objectweb.cjdbc.common.xml.XmlValidator.isXmlValid = false [private]
 

XmlValidator.java60 行で定義されています。

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.isValid(), org.objectweb.cjdbc.common.xml.XmlValidator.isXmlValid(), org.objectweb.cjdbc.common.xml.XmlValidator.main(), org.objectweb.cjdbc.controller.xml.DatabasesParser.readXML(), org.objectweb.cjdbc.controller.xml.ControllerParser.readXML(), と org.objectweb.cjdbc.common.xml.XmlValidator.validate().

XMLReader org.objectweb.cjdbc.common.xml.XmlValidator.parser [private]
 

XML parser. XmlValidator.java58 行で定義されています。

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.validate().

String org.objectweb.cjdbc.common.xml.XmlValidator.pathToDtd [private]
 

XmlValidator.java59 行で定義されています。

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.resolveEntity(), と org.objectweb.cjdbc.common.xml.XmlValidator.XmlValidator().

ArrayList org.objectweb.cjdbc.common.xml.XmlValidator.warnings [private]
 

XmlValidator.java64 行で定義されています。

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.getWarnings(), org.objectweb.cjdbc.common.xml.XmlValidator.validate(), と org.objectweb.cjdbc.common.xml.XmlValidator.warning().

String org.objectweb.cjdbc.common.xml.XmlValidator.xmlContent [private]
 

XmlValidator.java62 行で定義されています。

参照元 org.objectweb.cjdbc.common.xml.XmlValidator.getXmlContent(), と org.objectweb.cjdbc.common.xml.XmlValidator.XmlValidator().


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0.4に対してTue Oct 12 15:16:20 2004に生成されました。 doxygen 1.3.8