Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
Validate XML with XSD Schema with DOMBuilder

Validate XML with XSD Schema with DOMBuilder

2007-05-28       - By kerod@(protected)

 Back
Hi,

I have a big problem with DOMBuilder. I want to parse an XML document and
validate it with a XML Schema but with DOMBuilder it can't do it. Why ?
Here my code :

public int validXMLWithDOM(File xmlFile)
   {
       try
       {
           DOMParser dom           = new DOMParser();    //Instanciation d'un
?l?ment DOM
           DOMBuilder jdomParser   = new DOMBuilder("org.apache.xerces.parsers
.DOMParser");   //Instanciation d'un ?l?ment JDOM
           
           //Parse le document afin de r?cup?rer un arbre DOM
           dom.setFeature("http://xml.org/sax/features/validation", true);
           dom.parse("Durand.xml");  
           
           org.w3c.dom.Document docDom  = dom.getDocument();
           //R?cup?ration de notre arbre JDOM
           org.jdom.Element jdomDoc = jdomParser.build(docDom
.getDocumentElement());
           
        }
       catch(DOMParseException e)
       {
           e.printStackTrace();
       }
       catch(Exception e)
       {
           e.printStackTrace();
       }
     
       return 0;  
   }

Where is the problem ? How Can I get the error with DOMParseException ?

Thanks
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=iso-8859 (See http://iso-8859.ora-code.com)-1>
<STYLE></STYLE>

<META content="MSHTML 6.00.2900.3086" name=GENERATOR></HEAD>
<BODY id=MailContainerBody
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FONT-SIZE: 10pt; COLOR: #000080
; PADDING-TOP: 15px; FONT-FAMILY: Palatino Linotype"
bgColor=#ffffff leftMargin=0 topMargin=0 CanvasTabStop="true" acc_role="text"
name="Compose message area">
<DIV>Hi,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I have a big problem with DOMBuilder. I want to parse an XML document and
validate it with a XML Schema but with DOMBuilder it can't do it. Why ?</DIV>
<DIV>Here my code : </DIV>
<DIV>&nbsp;</DIV>
<DIV>public int validXMLWithDOM(File xmlFile) <BR>&nbsp;&nbsp;&nbsp;
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
DOMParser dom&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = new
DOMParser();&nbsp;&nbsp;&nbsp; //Instanciation d'un ?l?ment
DOM<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
DOMBuilder jdomParser&nbsp;&nbsp; = new
DOMBuilder("org.apache.xerces.parsers.DOMParser");&nbsp;&nbsp; //Instanciation
d'un ?l?ment
JDOM<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Parse
le document afin de r?cup?rer un arbre
DOM<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
dom.setFeature("<A title=http://xml.org/sax/features/validation
href="http://xml.org/sax/features/validation">http://xml.org/sax/features
/validation</A>",
true);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
dom.parse("Durand.xml");&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
org.w3c.dom.Document docDom&nbsp; =
dom.getDocument();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;
//R?cup?ration de notre arbre
JDOM<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
org.jdom.Element jdomDoc =
jdomParser.build(docDom.getDocumentElement());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
catch(DOMParseException e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
e.printStackTrace();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(Exception
e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
e.printStackTrace();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;&nbsp;&nbsp;
<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>Where is the problem ? How Can I get the error with DOMParseException
?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks</DIV></BODY></HTML>

__ ____ ____ ____ ____ ____ ____ ____ ____ ____
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.