Web Technologies Lab
Week:-
Date:-
Objective:-
Write an XML file which will display the Book information which includes the following: 1) 2) 3) 4) 5) 6)
Title of the book Author number ISBN number Publisher name Edition Price
Write a Document Type Definition (DTD) to validate the above xml file.Display the XML file as follows.The contents should be displayed in a table. The header of the table should be in color GREY. And the Author names column should be displayed in one color and should be capitalized and in bold. Use your own colors for remaining columns. Use XML schemas XSL and CSS for the above purpose.
DTD FILE: books.dtd
< ! ELEMENT data (inner)> < ! ELEMENT inner (title, author, isbn, pname, edition, price)> XML FILE: books.xml
Java server pages HANS BERGSTEN
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Web Technologies Lab
5466 pearson 2nd 455 Computer Networks ANDREW S TANENBUM 7899 Person Education 4 th 500 Java Programing with CORBA G.BROSE 1230 Wiley Dreamtech 3 rd 400 Data Mining-Concepts and designs HAN AND KAMBER 9720
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Web Technologies Lab
600 DOMValidateDTD.java:
import java.io.*; import org.w3c.dom.*; import org.xml.sax.*; import javax.xml.parsers.*; import javax.xml.validation.*; import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; public class DOMValidateDTD { public static void main(String args[]) { try{ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(true); DocumentBuilder builder = factory.newDocumentBuilder(); builder.setErrorHandler(new org.xml.sax.ErrorHandler() org.xml.sax.ErrorHandler() { //Ignore the fatal errors
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Web Technologies Lab
public void error(SAXParseException e)throws SAXParseException { System.out.println("Error at " +e.getLineNumber() + " line."); System.out.println(e.getMessage()); System.exit(0); } //Show warnings public void warning(SAXParseException err)throws SAXParseException { System.out.println(err.getMessage()); System.exit(0); } } //line-19 ); Document xmlDocument = builder.parse(new FileInputStream("books.xml")); DOMSource source = new DOMSource(xmlDocument); StreamResult result = new StreamResult(System.out); S treamResult(System.out); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "books.dtd"); transformer.transform(source, transformer.transform( source, result); }
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Web Technologies Lab
} } } Output:C:\>CSE>javac DOMValidateDTD.java C:\>CSE>java DOMValidateDTD
Java server pages HANS BERGSTEN 5466 pearson 2nd 455 Computer Networks ANDREW S TANENBUM 7899 Person Education 4 th 500
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Web Technologies Lab
G.BROSE 1230 Wiley Dreamtech 3 rd 400 Data Mining-Concepts and designs HAN AND KAMBER 9720 Pearson 4 th 600 XSL FILE:
naga Title of the book | Author Name | ISBN Number | Publisher name |
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Web Technologies Lab
| | | /> | | |
Output:-