Thứ Năm, 31 tháng 7, 2014

Validate XML


Module 3.1:Sr. No. Assignment Question Create an application, which demonstrates the generation of an error during parsing an XML document. Write the code for handling different types of errors and exceptions. Define an endDocument() method to override the contentHandler. Declare a method to override the error method of errorhandler.

B1: Tạo java class gồm các  class sau:


B2: Triển khai code cho lớp Handler.java,override method endDocument()


B3:Code cho hàm main


Kết quả:



Module3.2:Create an application, which demonstrates the implementations of DTDHandler interface methods. As the DefaultHandler implements the DTDHandler interface, you need to override the desired methods of DTDHandler interface.

B1: Tạo java class gồm các  class sau:



B2: Tạo file tomcat-users.xml


B3:Triển khai code cho lớp Handler.java,override  các  method endDocument(),notationDecl(),unparsedEntityDecl()


B4:Code cho hàm main

Kết quả:



Module 3.3:Create an XML file Report.xml that contains the sales data for this financial year. 
Create an application that demonstrates the implementations of LexicalHandler interface methods 
The application should display the number of entities, CDATA, and comments in the Report.xml document.

B1: Tạo java class gồm các  class sau:


B2:Tạo file sample.xml


B3:Triển khai code cho lớp Handler.java,override 1 số phương thức


B4:code cho hàm main


Kết quả:



Nhận xét:
-Các advance of SAX giúp cho việc kiểm soát lỗi tốt hơn.
-Giúp cho việc xây dựng ứng dụng đơn giản hơn













Không có nhận xét nào:

Đăng nhận xét