BookStore.xml examples9/BookStore/example01/ 1: 2: 7: 8: My Life and Times 9: Paul McCartney 10: 1998 11: 1-56592-235-2 12: McMillin Publishing 13: 14: 15: Illusions The Adventures of a Reluctant Messiah 16: Richard Bach 17: 1977 18: 0-440-34319-4 19: Dell Publishing Co. 20: 21: 22: The First and Last Freedom 23: J. Krishnamurti 24: 1954 25: 0-06-064831-7 26: Harper & Row 27: 28:

1/1

BookStore.xsd examples9/BookStore/example01/ 1: 2: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30:

1/1

BookStore.xsd examples9/BookStore/example02/ 1: 2: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29:

1/1

BookStore.xsd examples9/BookStore/example03/ 1: 2: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:

1/1

BookStore.xsd examples9/BookStore/example04/ 1: 2: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:

1/1

BookStore.xsd examples9/BookStore/example05/ 1: 2: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28:

1/1

po.xml examples9/ 1: 2: 5: 6: Alice Smith 7: 123 Maple Street 8: Mill Valley 9: CA 10: 90952 11: 12: 13: Robert Smith 14: 8 Oak Avenue 15: Old Town 16: PA 17: 95819 18: 19: Hurry, my lawn is going wild! 20: 21: 22: Lawnmower 23: 1 24: 148.95 25: Confirm this is electric 26: 27: 28: Baby Monitor 29: 1 30: 39.98 31: 1999-05-21 32: 33: 34:

1/1

po.xsd examples9/ 1: 2: 3: 4: 5: 6: 7: Purchase order schema. 8: Copyright 2007 Harvard University. All rights reserved. 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45:

1/2

po.xsd examples9/ 46: 47:
48:
49:
50: 51: 52: 53:
54: 55:
56:
57:
58:
59: 60: 61: 62: 63: 64: 65: 66: 67:


2/2

SAXValidator2.java examples9/ 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45:

import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler;

/** * Lecture 9’s demonstration of validation * by XML DTD or XML Schema. * * @author Computer Science E-259 **/ public class SAXValidator2 extends DefaultHandler { /** * Main driver. Expects one command-line argument: * the name of the XML file to validate * * @param argv [0] - filename */ public static void main(String [] argv) { if (argv.length == 0) { System.out.println("Usage: SAXValidator2 file [dtd|xsd]"); System.exit(1); } // grab filename String input = argv[0]; // grab validation mechanism, if any String validator = (argv.length > 1) ? argv[1] : null; // process input as requested try { // instantiate a reference to a SAX parser SAXParser parser = null;

1/3

SAXValidator2.java examples9/ 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90:

// instantiate a SAX parser factory SAXParserFactory factory = SAXParserFactory.newInstance(); // instantiate a SAX parser, enabling validation as requested if (validator != null && validator.equals("dtd")) { factory.setValidating(true); parser = factory.newSAXParser(); System.out.println("Validation by DTD on."); } else if (validator != null && validator.equals("xsd")) { factory.setNamespaceAware(true); factory.setValidating(true); parser = factory.newSAXParser(); parser.setProperty ( "http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema" ); System.out.println("Validation by XML Schema on."); } else { factory.setValidating(false); parser = factory.newSAXParser(); System.out.println("Validation off."); } // instantiate our little handler SAXValidator2 handler = new SAXValidator2(); // parse the file parser.parse(input, handler); } catch (Exception e) { e.printStackTrace(); } }

/** * Receive notification of a recoverable parser error. * * @param e the exception thrown

2/3

SAXValidator2.java

3/3

examples9/ 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: }

*/ public void error (SAXParseException e) { System.out.println("Parsing error: " + e.getMessage()); }

/** * Receive notification of a parser warning. * * @param e the exception thrown */ public void warning (SAXParseException e) { System.out.println("Parsing warning: " + e.getMessage()); }

/** * Report a fatal XML parsing error. * * @param e the exception thrown */ public void fatalError (SAXParseException e) { System.out.println("Fatal parsing error: System.exit(1); }

" + e.getMessage());

BookStore.xml 1/1 - Harvard University

7: . 8: <em>My</em> Life and Times. 9: .... 19: Hurry, my lawn is going wild! ... 30: >.

13KB Sizes 2 Downloads 289 Views

Recommend Documents

MAY 2017 - Harvard University
Email: [email protected]. ... Email: [email protected]. ..... impact of providing voters with a benchmark against which to compare their ...

MAY 2017 - Harvard University
conditions prevented us from reaching a precinct. We preserve ..... sance Revelations, Coordination Through Social Networks and Electoral Sanctioning: Experi-.

Dominant Currency Paradigm - Harvard University
Aug 7, 2017 - ... Jackson Hole Symposium, volume 27. Federal. Reserve Bank at Kansas City. ... MIT Press, Cambridge. Kugler, M. and Verhoogen, E. (2009).

Online Appendix for - Harvard University
Notice first that solving program (5), we obtain the following optimal choice of investment by the ... 1−α . Plugging this express into the marginal contribution function r (m) = ρ α ...... Year started .... (2002), we obtained a master-list of

Online Appendix for - Harvard University
As pointed out in the main text, we can express program (7) as a standard calculus of variation problem where the firm chooses the real-value function v that ...

California's Electricity Crisis - Harvard University
28 Sep 2001 - visit to England and Wales in early 1994 to study the competitive electricity system that had been created .... 18 LADWP, Pasadena, and the Imperial Irrigation District maintain their own control area, accounting for ...... about electr

Dynamic Random Utility - Harvard University
Jun 21, 2017 - outside-the-home options and some of these parents subsequently ...... consists of wealth and a consumption bundle and the utility of wealth is ..... to a constant consumption plan more than another agent if and only if her ...

Online PDF The Harvard Dictionary of Music (Harvard University Press ...
Un ebook scritto anche e book o eBook in italiano libro elettronico 232 un libro in formato digitale a cui si pu 242 avere accesso mediante computer e dispositivi ...

Nation Building Through Foreign Intervention ... - Harvard University
during the Vietnam War by exploiting two distinct policy discontinuities: one varies the intensity of a .... Bombing also decreased access to primary school by 16 percentage points and ... drug trade backfired in Mexico, generating significant increa

Profiling a warehouse-scale computer - Harvard University
Google to increasingly invest effort in automated, compiler- ... services that spend virtually all their time paying tax, and ...... Transactions of Computer. Systems ...

Profiling a warehouse-scale computer - Harvard University
presents a detailed microarchitectural analysis of live data- center jobs, measured on more than 20,000 .... Continuous profiling We collect performance-related data from the many live datacenter workloads using ..... base with a well-defined feature

Frontiers in Global Health Seminars - Harvard University
Frontiers in Global Health Seminars. Presents. The True Costs of Maternal Mortality on Children and Families: A Discussion of Findings from. Tanzania, Ethiopia ...

Dani Rodrik Harvard University
this paper concern non-traditional activities in agriculture or services. There is no evidence that .... guidelines for institutionalizing industrial policies and describe an illustrative range of programs. In section IV, I .... India for software ge

Nation Building Through Foreign Intervention ... - Harvard University
Bombing also decreased access to primary school by 16 percentage .... computers in Saigon and Washington and used to determine resource allocation. ...... geneous Spatial Effects of the Black Death and Long-Run Growth,” Tech. rep.

Evidence from Head Start - Harvard University
http://www.aeaweb.org/articles.php?doi=10.1257/app.1.3.111 .... and local matching grants in addition to the federal funds reported on the HHS Web site. ...... To project the impact of Head Start on wages, I first take all original members of.

STM-103i Governance and Development ... - Harvard University
Aug 6, 2015 - in the class Dropbox, though be sure to check the syllabus as not all items will be available there (e.g. book chapters, websites): https://www.dropbox.com/sh/3tqlsc5vha6389s/AAAgKeIeCI3G7T6cBDoI-zHka?dl=0. 1. Jan Teorell. 2010. Determi

STM-103i Governance and Development ... - Harvard University
Aug 6, 2015 - and the role of political culture, religion and social capital. Part VI looks at the consequences of democratic governance for ... Social capital and democracy. Part VI: Consequences of democratic governance. 22 .... Introduction: Road

Syllabus - HUIT Sites Hosting - Harvard University
Oct 15, 2007 - the form [email protected], where username is your FAS username. .... your plan at any point, provided you obtain the staff's approval for any modifications. ... Any of these texts should prove a valuable reference for.

Working Paper 15-10: Recent Declines in Labor's ... - Harvard University
Keywords: Inequality, Labor Share, Elasticity of Substitution, Labor-Augmenting Technical Change. Robert Z. Lawrence is senior fellow at the Peterson Institute ...

how social networks help voters coordinate ... - Harvard University
diverted to unauthorized projects (e.g. personal expenses and election campaigns, or expenditures that cannot be accounted for). The latter constitutes what is often regarded as corruption (e.g.. Ferraz and Finan 2008). Our study's sample consists mo