[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Reg Validation of xml

  • From: ganesh_br@p...
  • To: xml-dev@l...
  • Date: Wed, 31 Jan 2001 09:21:33 +0530

validation of xml file
                                                                            
 Hi I am pretty new to XML and I have a doubt about XML Doc. validation     
 against a schema.                                                          
                                                                            
 I have a schema file in d:/jdk1.3/bin named sch.xml                        
 My xml file also resides in the same directory. I want to parse this xml   
 file and validate it against my schema.                                    
                                                                            
 The  schema definition goes like this                                      
                                                                            
 <Schema name="Root"                                                        
 xmlns="urn:schemas-microsoft-com:xml-data"                                 
 xmlns:dt="urn:schemas-microsoft-com:datatypes">                            
 ....                                                                       
 ....                                                                       
                                                                            
 <ElementType name="Root" content="eltOnly"> <AttributeType name="version"  
 dt:type="float" required="yes"/>                                           
                                                                            
 In my xml file i have the following                                        
                                                                            
 <Root version="0.1" >                                                      
                                                                            
 ..............                                                             
                                                                            
 ...........                                                                
 </Root>                                                                    
                                                                            
 We are using the xerces DOM parser from apache. In our code we have set    
 the validation property to true. the code is like this                     
                                                                            
 class validate implements ErrorHandler                                     
 {                                                                          
 ....                                                                       
 ....                                                                       
                                                                            
 DOMParser parser=new DOMParser();                                          
 parser.setFeature("http://org.xml/sax/features/validation",true);          
                                                                            
                                                                            
 ....                                                                       
 ...                                                                        
 }                                                                          
 The error, fatalerror and warning methods of the ErrorHandler interface    
 have been implemented.                                                     
                                                                            
 When i run the program it gives me an SAXParseException :" Element type    
 "Root" must be declared."                                                  
 "Element type "ID" must be declared." etc.                                 
                                                                            
 I feel my parser is not able to locate my schema for the purpose of        
 validation. How do i specify the location of my xml schema file to the     
 parser. How do i specify the url of urn:schemas-microsoft-com:xml-data in  
 my xml file, the xsi attribute.                                            
                                                                            
 My xml file is currently like this                                         
                                                                            
 <?xml version="1.0"?>                                                      
                                                                            
 <Root  version="0.1">                                                      
                                                                            
 ............                                                               
 ..........                                                                 
                                                                            
 </Root>                                                                    
                                                                            
 How do i specify the location of my schema(present in d:\jdk1.3\bin\) to   
 my file. Do i need to implement any other thing.                           
                                                                            
 pls throw light on this with some examples                                 
                                                                            
 Thanks in Advance                                                          
                                                                            
                                                                            
                                                                            






PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.