project course xml validation in making up the slides for this lecture, i borrowed material from...

93
Project Course XML Validation ng up the slides for this lecture, I borrowed mater veral very nice sources: ta on the Web” Abiteboul, Buneman and Suciu L in a Nutshell” Harold and Means e XML Companion” Bradley idation examples were originally tested with an old the specific outputs may differ from those shown.

Post on 21-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

XML Validation

In making up the slides for this lecture, I borrowed materialfrom several very nice sources:

“Data on the Web” Abiteboul, Buneman and Suciu “XML in a Nutshell” Harold and Means “The XML Companion” Bradley

The validation examples were originally tested with an older parserand so the specific outputs may differ from those shown.

Page 2: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

XML Validation

A batch validating process involves comparing the DTD against a complete document instance and producing a report containing any errors or warnings.

Software developers should consider batch validation to be analogous to program compilation, with similar errors detected.

Interactive validation involves constant comparison of the DTDagainst a document as it is being created.

Page 3: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

XML Validation

The benefits of validating documents against a DTD include:

• Programmers can write extraction and manipulation filters without fear of their software ever processing unexpected input.

• Using an XML-aware word processor, authors and editors can be guided and constrained to produce conforming documents.

Page 4: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

XML Validation Examples

XML elements may contain further, embedded elements, andthe entire document must be enclosed by a single documentelement.

The degree to which an element’s content is organized into childelements is often termed its granularity.

Some hierarchical structures are recursive.

The Document Type Definition (DTD) contains rules for each elementallowed within a specific class of documents.

Page 5: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Things the DTD does not do:

Tell us the document root.

Specify the number of instances of each kind of element.

Describe the character data inside an element (precisesyntax and semantics).

The XML schema language is new and may replace theuse of DTD’s

Page 6: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

We’ll run this program against several xml fileswith DTD’s. We’ll study thecode soon.

// Validate.java using Xerces

import java.io.*;

import org.xml.sax.ErrorHandler;import org.xml.sax.SAXException;import org.xml.sax.SAXParseException;import org.xml.sax.XMLReader;import org.xml.sax.InputSource;import org.xml.sax.helpers.XMLReaderFactory;import org.xml.sax.helpers.DefaultHandler;

This slide shows the importedclasses.

Page 7: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

public class Validate { public static boolean valid = true;

public static void main (String argv []) { if (argv.length != 1) { System.err.println ("Usage: java Validate filename.xml"); System.exit (1); }

Here we check if the commandline is correct.

Page 8: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

try { // get a parser XMLReader reader = XMLReaderFactory.createXMLReader( "org.apache.xerces.parsers.SAXParser");

// request validation reader.setFeature("http://xml.org/sax/features/validation", true);

// associate an InputSource object with the file name InputSource inputSource = new InputSource(argv[0]);

// go ahead and parse reader.parse(inputSource); }

Page 9: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

catch(org.xml.sax.SAXException e) { System.out.println("Error in parsing " + e); valid = false; } catch(java.io.IOException e) { System.out.println("Error in I/O " + e); System.exit(0); } System.out.println("Valid Document is " + valid); }}

// Catch any errors or fatal errors here.// The parser will handle simple warnings.

Page 10: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd"><FixedFloatSwap> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments></FixedFloatSwap>

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) >

XML Document

DTD

Valid document is true

Page 11: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "http://localhost:8001/dtd/FixedFloatSwap.dtd"><FixedFloatSwap> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments></FixedFloatSwap>

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) >

XML Document

DTD on the Web?VERY NICE

Valid document is true

Page 12: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap [

<!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) > <!ELEMENT Notional (#PCDATA) > <!ELEMENT Fixed_Rate (#PCDATA) > <!ELEMENT NumYears (#PCDATA) > <!ELEMENT NumPayments (#PCDATA) >]>

<FixedFloatSwap> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments></FixedFloatSwap>

XML Document withan internal subset

Valid document is true

Page 13: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd"><FixedFloatSwap> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments></FixedFloatSwap>

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) >

XML Document

DTD

Valid document is false

Page 14: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Swaps SYSTEM "FixedFloatSwap.dtd"><Swaps> <FixedFloatSwap> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap>

<FixedFloatSwap> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap></Swaps>

XML Document

Page 15: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="utf-8"?><!ELEMENT Swaps (FixedFloatSwap+) ><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) >

DTD

C:\McCarthy\www\examples\sax>java Validate FixedFloatSwap.xml

Quantity Indicators ? 0 or 1 time + 1 or more times * 0 or more times

Valid document is true

Page 16: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Is this a valid document?

<?xml version="1.0"?><!DOCTYPE person [ <!ELEMENT person (name+, profession*)> <!ELEMENT profession (#PCDATA)> <!ELEMENT name (#PCDATA)>]>

<person> <name>Alan Turing</name> <profession>computer scientist</profession> <profession>cryptographer</profession></person>

Sure!

Page 17: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

The locations where document text data is allowed are indicated by the keyword ‘PCDATA’ (Parsed Character Data).

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd">

<FixedFloatSwap> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears> <StartYear>2000</StartYear> <EndYear>2002</EndYear> </NumYears> <NumPayments>6</NumPayments>

</FixedFloatSwap>

XML Document

Page 18: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) >

C:\McCarthy\www\46-928\examples\sax>java Validate FixedFloatSwap.xmlorg.xml.sax.SAXParseException: Element "NumYears" does not allow "StartYear" --(#PCDATA)org.xml.sax.SAXParseException: Element type "StartYear" is not declared.org.xml.sax.SAXParseException: Element "NumYears" does not allow "EndYear" -- (#PCDATA)org.xml.sax.SAXParseException: Element type "EndYear" is not declared.Valid document is false

Output

DTD

Page 19: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

There are strict rules which must be applied when an element is allowed to contain both text and child elements.

The PCDATA keyword must be the first token in the group, and the group must be a choice group (using “|” not “,”).

The group must be optional and repeatable.

This is known as a mixed content model.

Mixed Content

Page 20: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="utf-8"?><!ELEMENT Mixed (emph) ><!ELEMENT emph (#PCDATA | sub | super)* ><!ELEMENT sub (#PCDATA)><!ELEMENT super (#PCDATA)>

DTD

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Mixed SYSTEM "Mixed.dtd"><Mixed> <emph>H<sub>2</sub>O is water.</emph></Mixed>

XML Document

Valid document istrue

Page 21: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Is this a valid document?<?xml version="1.0"?><!DOCTYPE page [ <!ELEMENT page (paragraph+)> <!ELEMENT paragraph ( #PCDATA | profession | bold)*> <!ELEMENT profession (#PCDATA)> <!ELEMENT bold (#PCDATA)>]><page> <paragraph> Alan Turing broke codes during <bold>World War II</bold>. He very precisely defined the notion of "algorithm". And so he had several professions: <profession>computer scientist</profession> <profession>cryptographer</profession> And <profession>mathematician</profession> </paragraph></page>

Sure!

Page 22: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

How about this one?

java Validate mixed.xmlorg.xml.sax.SAXParseException:The content of element type "page" must match "(paragraph)+".Valid document is false

<?xml version="1.0"?><!DOCTYPE page [ <!ELEMENT page (paragraph+)> <!ELEMENT paragraph ( #PCDATA | profession | bold)*> <!ELEMENT profession (#PCDATA)> <!ELEMENT bold (#PCDATA)>]><page> The following is a paragraph marked up in XML. <paragraph> Alan Turing broke codes during <bold>World War II</bold>. He very precisely defined the notion of "algorithm". And so he had several professions: <profession>computer scientist</profession> <profession>cryptographer</profession> And <profession>mathemetician </profession> </paragraph></page>

Page 23: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd"> <FixedFloatSwap> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> <Note> <![CDATA[This is text that <b>will not be parsed for markup]]> </Note> </FixedFloatSwap>

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap ( Notional, Fixed_Rate, NumYears, NumPayments, Note ) ><!ELEMENT Notional (#PCDATA)><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) ><!ELEMENT Note (#PCDATA) >

XML Document

DTD

CDATA Section

Page 24: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Recursion<?xml version="1.0"?><!DOCTYPE tree [ <!ELEMENT tree (node)> <!ELEMENT node (leaf | (node,node))>

<!ELEMENT leaf (#PCDATA)>]>

<tree> <node> <leaf>A DTD is a context-free grammar</leaf> </node></tree>

java Validate recursive1.xmlValid document is true

Page 25: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

How about this one?<?xml version="1.0"?><!DOCTYPE tree [ <!ELEMENT tree (node)> <!ELEMENT node (leaf | (node,node))>

<!ELEMENT leaf (#PCDATA)>]><tree> <node> <leaf>Alan Turing would like this</leaf> </node> <node> <leaf>Alan Turing would like this</leaf> </node></tree>

java Validate recursive1.xmlorg.xml.sax.SAXParseException:The content of element type"tree" must match "(node)".Valid document is false

Page 26: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Relational Databases and XML

Consider the relational database r1(a,b,c), r2(c,d)

r1: a b c r2: c d a1 b1 c1 c2 d2 a2 b2 c2 c3 d3 c4 d4

How can we represent this database with an XML DTD?

Page 27: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Relations<?xml version="1.0"?><!DOCTYPE db [ <!ELEMENT db (r1*, r2*)> <!ELEMENT r1 (a,b,c)> <!ELEMENT r2 (c,d)> <!ELEMENT a (#PCDATA)> <!ELEMENT b (#PCDATA)> <!ELEMENT c (#PCDATA)> <!ELEMENT d (#PCDATA)> ]>

<db> <r1><a> a1 </a> <b> b1 </b> <c> c1 </c> </r1> <r1><a> a1 </a> <b> b1 </b> <c> c1 </c> </r1> <r2><c> c2 </c> <d> d2 </d> </r2> <r2><c> c3 </c> <d> d3 </d> </r2> <r2><c> c4 </c> <d> d4 </d> </r2></db>

java Validate Db.xmlValid document is true

There is a small problem….

Page 28: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Relations<?xml version="1.0"?><!DOCTYPE db [ <!ELEMENT db (r1|r2)* > <!ELEMENT r1 ((a,b,c) | (a,c,b) | (b,a,c) | (b,c,a) | (c,a,b) | (c,b,a))> <!ELEMENT r2 ((c,d) | (d,c))> <!ELEMENT a (#PCDATA)> <!ELEMENT b (#PCDATA)> <!ELEMENT c (#PCDATA)> <!ELEMENT d (#PCDATA)> ]><db> <r1><a> a1 </a> <b> b1 </b> <c> c1 </c> </r1> <r1><a> a1 </a> <b> b1 </b> <c> c1 </c> </r1> <r2><c> c2 </c> <d> d2 </d> </r2> <r2><c> c3 </c> <d> d3 </d> </r2> <r2><c> c4 </c> <d> d4 </d> </r2></db>

The order of the relationsshould not count and neithershould the order ofcolumns within rows.

Page 29: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

AttributesAn attribute is associated with a particular element by the DTDand is assigned an attribute type.

The attribute type can restrict the range of values it can hold.

Example attribute types include :

CDATA indicates a simple string of characters NMTOKEN indicates a word or token A named token group such as (left | center | right) ID an element id that holds a unique value (among other element ID’s in the document) IDREF attributes refer to an ID

Page 30: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) ><!ATTLIST Notional currency (Dollars | Pounds) #REQUIRED>

DTD

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd"> <FixedFloatSwap> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap>

XML Document

C:\McCarthy\www\46-928\examples\sax>java Validate FixedFloatSwap.xmlorg.xml.sax.SAXParseException: Attribute value for "currency" is #REQUIRED.

Valid document is false

Page 31: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) ><!ATTLIST Notional currency (Dollars | Pounds) #REQUIRED>

DTD

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd"> <FixedFloatSwap> <Notional currency = “Pounds”>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap>

XML Document

Valid document is true

Page 32: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

DTD

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd"> <FixedFloatSwap> <Notional currency = “Pounds”>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap>

XML Document

Valid document is true#IMPLIED means optional

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) ><!ATTLIST Notional currency (Dollars | Pounds) #REQUIRED><!ATTLIST FixedFloatSwap note CDATA #IMPLIED>

Page 33: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

DTD

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd"> <FixedFloatSwap note = “For your eyes only”> <Notional currency = “Pounds”>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap>

XML Document

Valid document is true

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) ><!ATTLIST Notional currency (Dollars | Pounds) #REQUIRED><!ATTLIST FixedFloatSwap note CDATA #IMPLIED>

Page 34: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

DTD

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd"> <FixedFloatSwap> <Notional currency = “Pounds”>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap>

XML Document

Valid document is true#IMPLIED means optional

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) ><!ATTLIST Notional currency (Dollars | Pounds) #REQUIRED><!ATTLIST FixedFloatSwap note CDATA #IMPLIED>

Page 35: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

DTD

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd"> <FixedFloatSwap note = “For your eyes only”> <Notional currency = “Pounds”>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap>

XML Document

Valid document is true

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) ><!ATTLIST Notional currency (Dollars | Pounds) #REQUIRED><!ATTLIST FixedFloatSwap note CDATA #IMPLIED>

Page 36: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

ID and IDREF Attributes

We can represent complex relationships within an XML document using ID and IDREF attributes.

Page 37: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

An Undirected Graph

u v w

x y z

edgevertex

Page 38: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

A Directed Graph

uw

v

y x

Page 39: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Math 100 Geom100

Calc100 Calc200 Calc300

Philo45CS1 CS2

This is called a DAG (Directed Acyclic Graph)

Page 40: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0"?>

<!DOCTYPE Course_Descriptions SYSTEM "course_descriptions.dtd">

<Course_Descriptions>

<Course>

<Course-ID id = "Math100" />

<Title>Algebra I</Title>

<Description> Students in this course study

introductory algebra.

</Description>

<Prerequisites/>

</Course>

This course has an ID

But no prerequisites

Page 41: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<Course>

<Course-ID id = "Geom100" />

<Title>Geometry I</Title>

<Description> Students in this course study how to

prove several theorems in geometry.

</Description>

<Prerequisites/>

</Course>

The DTD will forcethis to be unique.

Page 42: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<Course>

<Course-ID id="Calc100" />

<Title>Calculus I</Title>

<Description> Students in this course study the derivative.

</Description>

<Prerequisites pre="Math100 Geom100" />

</Course>

<Course>

These are references toID’s. (IDREFS)

Page 43: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<Course-ID id = "Calc200" />

<Title>Calculus II</Title>

<Description> Students in this course study the integral.

</Description>

<Prerequisites pre="Calc100" />

</Course>

The DTD requires that this namebe a unique id defined within thisdocument. Otherwise, the documentis invalid.

Page 44: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<Course>

<Course-ID id = "Calc300" />

<Title>Calculus II</Title>

<Description> Students in this course study the derivative

and the integral (in 3-space).

</Description>

<Prerequisites pre="Calc200" />

</Course>

Prerequisites is an EMPTYelement. It’s used only for itsattributes.

Page 45: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<Course>

<Course-ID id = "CS1" />

<Title>Introduction to Computer Science I</Title>

<Description> In this course we study Turing machines.

</Description>

<Prerequisites pre="Calc100" />

</Course>

<Course>

IDREF ID

A One-to-one link

Page 46: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<Course-ID id = "CS2" />

<Title>Introduction to Computer Science II</Title>

<Description> In this course we study basic data structures.

</Description>

<Prerequisites pre="Calc200 CS1"/>

</Course>

<Course>

IDREFS

ID

ID

One-to-many links

Page 47: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<Course-ID id = "Philo45" />

<Title>Ethical Implications of Information Technology</Title>

<Description> TBA

</Description>

<Prerequisites/>

</Course>

</Course_Descriptions>

Page 48: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0"?>

<!-- Course Description DTD --> <!ELEMENT Course_Descriptions (Course)+> <!ELEMENT Course (Course-ID,Title,Description,Prerequisites)> <!ELEMENT Course-ID EMPTY> <!ELEMENT Title (#PCDATA)> <!ELEMENT Description (#PCDATA)> <!ELEMENT Prerequisites EMPTY>

<!ATTLIST Course-ID id ID #REQUIRED>

<!ATTLIST Prerequisites pre IDREFS #IMPLIED>

The Course_Descriptions.dtd

Page 49: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

General Entities &

General entities are used to place text into the XML document.

They may be declared in the DTD and referenced in the document.

They may also be declared in the DTD as residing in a file. Theymay then be referenced in the document.

Page 50: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd" [ <!ENTITY bankname "Mellon National Bank and Trust" > ]> <FixedFloatSwap> <Bank>&bankname;</Bank> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap>

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Bank,Notional, Fixed_Rate, NumYears, NumPayments ) ><!ELEMENT Bank (#PCDATA) ><!ELEMENT Notional (#PCDATA) ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) >

DTD

Document usinga General Entity

Validate is true

Page 51: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match = "Bank"> <WML> <CARD> <xsl:apply-templates/> </CARD> </WML> </xsl:template>

<xsl:template match = "Notional | Fixed_Rate | NumYears | NumPayments"> </xsl:template> </xsl:stylesheet>

XSLT Program

The general entity is replaced before xslt sees it.

Page 52: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

C:\McCarthy\www\46-928\examples\sax>java -Dcom.jclark.xsl.sax.parser=com.jclark.xml.sax.CommentDriver com.jclark.xsl.sax.Driver FixedFloatSwap.xml FixedFloatSwap.xsl FixedFloatSwap.wml

C:\McCarthy\www\46-928\examples\sax>type FixedFloatSwap.wml

<?xml version="1.0" encoding="utf-8"?>

<WML><CARD>Mellon National Bank and Trust</CARD></WML>

XSLT OUTPUT

Page 53: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd" [

<!ENTITY bankname SYSTEM "JustAFile.dat" >

]> <FixedFloatSwap> <Bank>&bankname;</Bank> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap>

An external text entity

Page 54: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Mellon Bank And Trust CorporationPittsburgh PA

XSLT Output

<?xml version="1.0" encoding="utf-8"?>

<WML><CARD>Mellon Bank And Trust CorporationPittsburgh PA</CARD></WML>

JustAFile.dat

Page 55: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Parameter Entities %

While general entities are used to place text into the XML documentparameter entities are used to modify the DTD.

We want to build modular DTD’s so that we can create new DTD’susing existing ones.

We’ll look at slide from www.fpml.org and the see some examples.

Page 56: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

FpML is a Complete Description of the Trade

Pool of modular componentsgrouped into separate namespaces

Date ScheduleProduct

Rate

Adjustable PeriodNotional

Party

Trade

Trade ID

Product

Rate

Adjustable Period

Notional

Party

Vanilla SwapVanilla Fixed Float SwapCancellableSwaptionFX SpotFX OutrightFX SwapForward Rate Agreement...

MoneyDate

Page 57: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<?xml version="1.0" encoding="utf-8"?><!ELEMENT FixedFloatSwap (Notional, Fixed_Rate, NumYears, NumPayments ) ><!ENTITY % parsedCharacterData "(#PCDATA)"><!ELEMENT Notional %parsedCharacterData; ><!ELEMENT Fixed_Rate (#PCDATA) ><!ELEMENT NumYears (#PCDATA) ><!ELEMENT NumPayments (#PCDATA) >

XML Document

DTD

Internal Parameter Entities

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FixedFloatSwap SYSTEM "FixedFloatSwap.dtd"> <FixedFloatSwap> <Notional>100</Notional> <Fixed_Rate>5</Fixed_Rate> <NumYears>3</NumYears> <NumPayments>6</NumPayments> </FixedFloatSwap>

Page 58: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

External Parameter Entities and DTD Components

<?xml version="1.0" encoding = "UTF-8"?><!DOCTYPE ORDER SYSTEM "order.dtd"><!-- example order form from “XML A Manager’s Guide” --><ORDER SOURCE ="web" CUSTOMERTYPE="consumer" CURRENCY="USD"> <addresses> <address ADDTYPE="billship"> <firstname>Kevin</firstname> <lastname>Dick</lastname> <street ORDER="1">123 Anywhere Lane</street> <street ORDER="2">Apt 1b</street> <city>Palo Alto</city> <state>CA</state> <postal>94303</postal> <country>USA</country> </address>

Order.xml

Page 59: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<address ADDTYPE="bill"> <firstname>Kevin</firstname> <lastname>Dick</lastname> <street ORDER="1">123 Not The Same Lane</street> <street ORDER="2">Work Place</street> <city>Palo Alto</city> <state>CA</state> <postal>94300</postal> <country>USA</country> </address> </addresses>

An order may have more than oneaddress.

Page 60: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<lineitems> <lineitem ID="line1"> <product CAT="MBoard">440BX Motherboard</product> <quantity>1</quantity> <unitprice>200</unitprice> </lineitem> <lineitem ID="line2"> <product CAT = "RAM">128 MB PC-100 DIMM</product> <quantity>2</quantity> <unitprice>175</unitprice> </lineitem> <lineitem ID="line3"> <product CAT="CDROM">40x CD-ROM</product> <quantity>1</quantity> <unitprice>50</unitprice> </lineitem> </lineitems>

Several productsmay be purchased.

Page 61: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<payment> <card CARDTYPE="VISA"> <cardholder>Kevin S. Dick</cardholder> <cardnumber>11111-22222-33333</cardnumber> <expiration>01/01</expiration> </card> </payment></ORDER>

The payment is witha Visa card.

We want this document to be validated.

Page 62: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

order.dtd<?xml version="1.0" encoding="UTF-8"?>

<!-- Example Order form DTD adapted from XML: A Manager's Guide -->

<!-- Define an ORDER element -->

<!ELEMENT ORDER (addresses, lineitems, payment)> <!ATTLIST ORDER SOURCE (web | phone | retail) #REQUIRED CUSTOMERTYPE (consumer | business) "consumer" CURRENCY CDATA "USD">

Define an order based on other elements.

Page 63: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<!ENTITY % anAddress SYSTEM "address.dtd" >%anAddress;

<!-- Collection of Addresses --><!ELEMENT addresses (address+)>

<!ENTITY % aLineItem SYSTEM "lineitem.dtd" >%aLineItem;

<!-- Collection of LineItems --><!ELEMENT lineitems (lineitem+)>

<!ENTITY % aPayment SYSTEM "payment.dtd" >%aPayment;

External parameterentity declaration %

External parameter entity reference %

Page 64: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

address.dtd<!-- Address Structure --><!ELEMENT address (firstname, middlename?, lastname, street+, city, state,postal,country)>

<!ELEMENT firstname (#PCDATA)><!ELEMENT middlename (#PCDATA)><!ELEMENT lastname (#PCDATA)><!ELEMENT street (#PCDATA)><!ELEMENT city (#PCDATA)><!ELEMENT state (#PCDATA)><!ELEMENT postal (#PCDATA)><!ELEMENT country (#PCDATA)><!ATTLIST address ADDTYPE (bill | ship | billship) "billship"><!ATTLIST street ORDER CDATA #IMPLIED>

Page 65: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

lineitem.dtd<!ELEMENT lineitem (product,quantity,unitprice)><!ATTLIST lineitem ID ID #REQUIRED>

<!ELEMENT product (#PCDATA)><!ATTLIST product CAT (CDROM|MBoard|RAM) #REQUIRED>

<!ELEMENT quantity (#PCDATA)><!ELEMENT unitprice (#PCDATA)>

Page 66: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<!ELEMENT payment (card | PO)><!ELEMENT card (cardholder, cardnumber, expiration)><!ELEMENT cardholder (#PCDATA)><!ELEMENT cardnumber (#PCDATA)><!ELEMENT expiration (#PCDATA)><!ELEMENT PO (number,authorization*)><!ELEMENT number (#PCDATA)><!ELEMENT authorization (#PCDATA)>

<!ATTLIST card CARDTYPE (VISA|MasterCard|Amex) #REQUIRED>

payment.dtd

Page 67: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

XML Schemas are Coming

• “XML Schema” is the official name

• XSDL (XML Schema Definition Language) is the language used to create schema definitions

• Can be used to more tightly constrain a document instance

• Supports namespaces

• Permits type derivation

Page 68: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

A Simple Purchase Order

<?xml version="1.0" encoding="UTF-8"?> <!-- po.xml -->

<purchaseOrder orderDate="07.23.2001" xmlns="http://www.cds-r-us.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cds-r-us.com po.xsd">

Page 69: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<recipient country="USA"> <name>Dennis Scannel</name> <street>175 Perry Lea Side Road</street> <city>Waterbury</city> <state>VT</state> <postalCode>15216</postalCode> </recipient>

<order> <cd artist="Brooks Williams" title="Little Lion" /> <cd artist="David Wilcox" title="What you whispered" /> </order>

</purchaseOrder>

Page 70: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Purchase Order XSDL

<?xml version="1.0" encoding="utf-8"?> <!-- po.xsd --><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.cds-r-us.com" targetNamespace="http://www.cds-r-us.com" >

Page 71: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<xs:element name="purchaseOrder">

<xs:complexType> <xs:sequence> <xs:element ref="recipient" /> <xs:element ref="order" /> </xs:sequence> <xs:attribute name="orderDate" type="xs:string" /> </xs:complexType>

</xs:element>

Page 72: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<xs:element name = "recipient">

<xs:complexType> <xs:sequence> <xs:element ref="name" /> <xs:element ref="street" /> <xs:element ref="city" /> <xs:element ref="state" /> <xs:element ref="postalCode" /> </xs:sequence> <xs:attribute name="country" type="xs:string" /> </xs:complexType>

</xs:element>

Page 73: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<xs:element name = "name" type="xs:string" /> <xs:element name = "street" type="xs:string" /> <xs:element name = "city" type="xs:string" /> <xs:element name = "state" type="xs:string" /> <xs:element name = "postalCode" type="xs:short" />

<xs:element name = "order"> <xs:complexType> <xs:sequence> <xs:element ref="cd" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element>

Page 74: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<xs:element name="cd"> <xs:complexType> <xs:attribute name="artist" type="xs:string" /> <xs:attribute name="title" type="xs:string" /> </xs:complexType> </xs:element>

</xs:schema>

Page 75: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

FpML

These notes were made from the FpML Architecture V1.0 Recommendation.

Some of the material on these slides was taken from the “FpML Architecture V1.0 Recommendation”

See http://www.fpml.org

Page 76: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

FpML

FpML 1.0 is a DTD based standard.

XML Schema will probably be incorporated in the future.

FpML uses a content model based on Object-OrientedDesign.

Page 77: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

FpML

Consider a Java class and its FpML representation

class Money { String currency; decimal amount; }

Page 78: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

FpML DTD

<!-- Member list entity (used for inheritance and instantiation) --><!ENTITY % Money "currency, amount"><!-- Member declarations --><!ELEMENT currency (#PCDATA)><!ATTLIST currency type NMTOKEN #FIXED "string"><!ELEMENT amount (#PCDATA)>

<!ATTLIST amount type NMTOKEN #FIXED "decimal">

Page 79: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

FpML DTD

<!-- Class type element --><!ELEMENT premium (%Money;)><!ATTLIST premium type NMTOKEN #FIXED "Money">

Page 80: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

FpML Document

<premium> <currency>GBP</currency> <amount>1000000.00</amount></premium>

Page 81: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

In the future - XML Schema

<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">

<xsd:element name="currency" type="xsd:string"/><xsd:element name="amount" type="xsd:decimal"/><xsd:complexType name="Money"> <xsd:sequence> <xsd:element ref="currency"/> <xsd:element ref="amount"/> </xsd:sequence></xsd:complexType> <!-- Matching example element --><xsd:element name="premium" type="Money"/> </xsd:schema>

Page 82: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Inheritance

// A Java-like class hierarchy

class Shape { decimal x; decimal y;}class Square extends Shape { decimal width;}class Circle { decimal radius;}

Page 83: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Inheritance in FpML DTD<!-- Member list entities --><!ENTITY % Shape "x, y"><!ENTITY % Circle "(%Shape;), radius"><!ENTITY % Square "(%Shape;), width">

<!-- Member declarations --><!ELEMENT x (#PCDATA)><!ATTLIST x type NMTOKEN #FIXED "decimal"><!ELEMENT y (#PCDATA)><!ATTLIST y type NMTOKEN #FIXED "decimal"><!ELEMENT radius (#PCDATA)><!ATTLIST radius type NMTOKEN #FIXED "decimal"><!ELEMENT width (#PCDATA)><!ATTLIST width type NMTOKEN #FIXED "decimal">

Page 84: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Inheritance in FpML DTD<!– Class type element <!ELEMENT mySquare(%Square;) ><!ATTLIST mySquare type NMTOKEN #FIXED “Square” base MNTOKEN #FIXED “Shape”>

The FpML Document

<mySquare> <x>4.5</x> <y>2.3</y> <width> 100 </width></mySquare>

Other OODStructures definedin the specification

Page 85: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Enumerated Types

Supported in XML with ….

<!ELEMENT option (…)><!ATTLIST option type (PUT | CALL) #REQUIRED>

FpML has no business data in attributes.Schemes are used instead.

Page 86: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Schemes1.1         SchemesIn In the case of an element whose "legal" values are restricted to those of a specific domain, values in that domain should be handled as follows:         Elements containing domain values should be of string type and will hold a single valid domain value identifier.

         A defaulted attribute, ‘<schemeName>SchemeDefault’, will be provided on the FpML document’s root element to define the default Scheme URI. This will be used if no overriding URI is provided.         An optional attribute, ‘<schemeName>Scheme’, will be provided on each domain valued element to override the URI reference for the domain.

Page 87: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<FpML currencySchemeDefault="http://www.fpml.org/ext/iso4217" businessCenterSchemeDefault= "http://www.fpml.org/spec/2000/business-center-1-0" > <trade> <fxSwap> <nearLeg> <currency1>CHF</currency1> <currency2 currencyScheme= "http://www.chase.com/ext/realmoney" > UK_Pence </currency2> … </nearLeg> </fxSwap> </trade></FpML>

Page 88: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

The DTD

<!ATTLIST FpML currencySchemeDefault CDATA #IMPLIED businessCenterSchemeDefault CDATA #IMPLIED>

<!ATTLIST currency currencyScheme CDATA #IMPLIED>

Page 89: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

Fixed/Float Swap Example<?xml version="1.0"?><!DOCTYPE FpML SYSTEM "fpml-dtd-2-0-2001-10-17.dtd"><!--DOCTYPE FpML PUBLIC "-//FpML//DTD Financial product Markup Language 2-0//EN" "" >--><FpML version="2-0" businessCenterSchemeDefault= "http://www.fpml.org/spec/2000/business-center-1-0"

businessDayConventionSchemeDefault=" http://www.fpml.org/spec/2000/business-day-convention-1-0"

Page 90: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

currencySchemeDefault="http://www.fpml.org/ext/iso4217"

dateRelativeToSchemeDefault= "http://www.fpml.org/spec/2001/date-relative-to-2-0"

dayCountFractionSchemeDefault="http://www.fpml.org/spec/2000/day-count-fraction-1-0"

dayTypeSchemeDefault= "http://www.fpml.org/spec/2000/day-type-1-0"

floatingRateIndexSchemeDefault="http://www.fpml.org/ext/isda-1991-definitions"

partyIdSchemeDefault= "http://www.fpml.org/ext/iso9362"

Page 91: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

payRelativeToSchemeDefault="http://www.fpml.org/spec/2000/pay-relative-to-1-0"

periodSchemeDefault="http://www.fpml.org/spec/2000/period-1-0"

resetRelativeToSchemeDefault="http://www.fpml.org/spec/2000/reset-relative-to-1-0"

rollConventionSchemeDefault="http://www.fpml.org/spec/2000/roll-convention-1-0">

Page 92: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<trade> <tradeHeader>

<partyTradeIdentifier> <partyReference href="#CHASE"/>

<tradeId tradeIdScheme= "http://www.chase.com/swaps/trade-id"> TW9235 </tradeId>

</partyTradeIdentifier><partyTradeIdentifier>

<partyReference href="#BARCLAYS"/><tradeId tradeIdScheme=

"http://www.barclays.com/swaps/trade-id"> SW2000 </tradeId>

</partyTradeIdentifier><tradeDate>1994-12-12</tradeDate>

</tradeHeader>

Page 93: Project Course XML Validation In making up the slides for this lecture, I borrowed material from several very nice sources: “Data on the Web” Abiteboul,

Project Course

<swap> <!-- Chase pays the floating rate every 6 months, based on 6M DEM-LIBOR-BBA, on an ACT/360 basis --> <swapStream>

<payerPartyReference href="#CHASE"/><receiverPartyReference href="#BARCLAYS"/><calculationPeriodDates id="floatingCalcPeriodDates"><effectiveDate><unadjustedDate>1994-12-14</unadjustedDate><dateAdjustments><businessDayConvention>NONE

</businessDayConvention>

See Rest of Document on the course web page