Presentation is loading. Please wait.

Presentation is loading. Please wait.

<Discussion>.

Similar presentations


Presentation on theme: "<Discussion>."— Presentation transcript:

1 <Discussion>

2 XML – Extensible Markup Language

3 XML eXtensible – add to language. Markup – delimit info using tags.
Language – a way to express info.

4 Major Roles for XML

5 Store Data XML Document XML Schema

6 Exchange Data XML Document XML Schema

7 Client Access to XML Data
Present Info XSL Stylesheet 1 XML Document XML Document XSL Stylesheet 2 Client Access to XML Data

8 Simplify Data Capture (eventually)
Database Data encapsulation into data node Insert data node

9 XML Includes … Marked up text XSD XForms Model XSL Parser XSLT XSL-FO
XHTML HTML XPath Rendering Agent XForms Processor

10 XML Documents -

11 An XML Document … A text document. Stores data.
Data items are delimited using tags. Hierarchical structure. -

12 Tags: Data: <?xml version="1.0"?> <Customers>
<Id>5003</Id> <CName>Jane</CName> <Transaction> <TDate> </TDate> <Amt>-27.85</Amt> </Transaction> <TDate> </TDate> <Amt>49.50</Amt> </Customer> </Customers> Tags: Delimit data. Show meaning. You make tags! Data: Rich data types. Constraints.

13 Well Formed XML All data items are between tags.
Closing tags start with /. Tags are case sensitive. No spaces or symbols in tags. (Data may contain spaces and some symbols.) Tags balance.

14 Tags and Data <?xml version="1.0"?> <Customers>
<Id>5003</Id> <CName>Jane</CName> <Transaction> <TDate> </TDate> <Amt>-27.85</Amt> </Transaction> </Customer> </Customers>

15 Well Formed? <Cost>123.45<Cost>
<Cost><Quantity>123.45</Cost>15</Quantity> <Cost>123.45</Cost><Quantity>15</Quantity> <Cost>Homer Simpson</Cost>

16 XML Document Structure
<?xml version="1.0"?> <Customers> <Customer> <Id>5003</Id> <CName>Jane</CName> <Transaction> <TDate> </TDate> <Amt>-27.85</Amt> </Transaction> <TDate> </TDate> <Amt>49.50</Amt> </Customer> <Id>5004</Id> <CName>Tom</CName> <TDate> </TDate> <Amt>58.85</Amt> </Customers> Customers Customer Id CName 5003 Jane Customer Id CName 5004 Tom Transaction TDate Amt 1/1/03 -27.95 1/7/03 49.50 Transaction TDate Amt 1/3/03 58.85

17 Hierarchy of Nodes Root Node / Document Element or Document Node
Customers Document Element or Document Node Customer Id CName 5004 Tom 5003 Jane Node or Complex Element (Simple) Element Transaction TDate Amt 1/1/03 -27.95 1/7/03 49.50 Transaction TDate Amt 1/3/03 58.85

18 Key to Understanding? Meaningful, descriptive tag names! 103.95
<z>103.95</z> <Price>103.95</Price> <ListPrice>103.95</ListPrice> <SalesPrice>103.95</SalesPrice> Meaningful, descriptive tag names!

19 XML Schemas

20 An XML Schema … Defines the structure of an XML document.
Nodes. Hierarchy. Defines the elements in each node. Tag. Data type. Constraints. XML Document XML Schema

21 Valid XML Document Well formed. XML Document
XML document conforms to structure defined in XML schema. XML Schema

22 XML Schema - Exchange Data
Document XML Schema Based on Standards

23 Identify Data Requirements
Defining an XML Schema Agree on Definitions Identify Data Requirements Specify Structure Specify Tags

24 Some Major XML Standards
eXtensible Business Reporting Language (XBRL) Financial Reporting EDI XML/EDI and electronic business using XML (ebXML) EFT Direct Deposit Open Financial Exchange (OFX) Tax Reporting IRS e-file Standards

25 <?xml version="1.0"?> <Customers> <Customer> <Id>5003</Id> <CName>Jane</CName> <Transaction> <TDate> </TDate> <Amt>-27.85</Amt> </Transaction> <TDate> </TDate> <Amt>49.50</Amt> </Customer> <Id>5004</Id> <CName>Tom</CName> <TDate> </TDate> <Amt>58.85</Amt> </Customers> Transaction TDate Amt 1/1/03 -27.95 1/7/03 49.50 Customer Id CName 5004 Tom 5003 Jane 1/3/03 58.85 Customers

26 <xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
<?xml version = "1.0"?> <xsd:schema xmlns:xsd = " <xsd:element name = "Customers"> <xsd:complexType> <xsd:sequence> <xsd:element ref = "Customer" maxOccurs = "unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> Transaction TDate Amt 1/1/03 -27.95 1/7/03 49.50 Customer Id CName 5004 Tom 5003 Jane 1/3/03 58.85 Customers

27 <xsd:element name = "Customer"> <xsd:complexType>
<xsd:element name = "Customer"> <xsd:complexType> <xsd:sequence> <xsd:element name = "Id" type = "xsd:string"/> <xsd:element name = "CName" type = "xsd:string"/> <xsd:element ref = "Transaction" maxOccurs = "unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> Transaction TDate Amt 1/1/03 -27.95 1/7/03 49.50 Customer Id CName 5004 Tom 5003 Jane 1/3/03 58.85 Customers

28 <xsd:element name = "Transaction"> <xsd:complexType>
<xsd:element name = "Transaction"> <xsd:complexType> <xsd:sequence> <xsd:element name = "TDate" type = "xsd:date"/> <xsd:element name = "Amt" type = "xsd:decimal"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Transaction TDate Amt 1/1/03 -27.95 1/7/03 49.50 Customer Id CName 5004 Tom 5003 Jane 1/3/03 58.85 Customers

29 <?xml version = "1.0"?> <xsd:schema xmlns:xsd = " <xsd:element name = "Customers"> <xsd:complexType> <xsd:sequence> <xsd:element ref = "Customer" maxOccurs = "unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name = "Customer"> <xsd:element name = "Id" type = "xsd:string"/> <xsd:element name = "CName" type = "xsd:string"/> <xsd:element ref = "Transaction" maxOccurs = "unbounded"/> <xsd:element name = "Transaction"> <xsd:element name = "TDate" type = "xsd:date"/> <xsd:element name = "Amt" type = "xsd:decimal"/> </xsd:schema>

30 Validating XML Documents
Use software or web tools. Topologi Schematron Validator. GotDotNet Schema Validator.

31 XSL Stylesheet, etc.

32 An XSL Stylesheet … Gets and filters nodes in an XML document.
Transforms nodes. Formats output.

33 Many XSL Stylesheets XSL Stylesheet #1 XML Document XSL Stylesheet #2

34 XSL Stylesheet “Languages”
XML Path XSL Transformations XPath: gets nodes using paths and filtering patterns. XSLT: transforms a document tree into a new document tree. XSL-Formatting Objects XSL-FO: describes how output looks. (HTML on steroids!)

35 Parsed and Rendered Output
XML Document XSL Stylesheet + =

36 <xsl:stylesheet xmlns:xsl=" version="1.0"> <xsl:template match="/Customers"> <html> <body> <h1>Customer Information</h1> <xsl:apply-templates select="Customer" /> </body> </html> </xsl:template> <xsl:template match="Customer"> <b>Id: </b> <xsl:value-of select="Id" /><br /> <b>Name: </b> <xsl:value-of select="CName" /><br /> <xsl:apply-templates select="Transaction" /> <br /><hr /><br /> <xsl:template match="Transaction"> <b>Date: </b> <xsl:value-of select="TDate" /> <b>Amount: </b> <xsl:value-of select="Amt" /><br /> </xsl:stylesheet> Transaction TDate Amt 1/1/03 -27.95 1/7/03 49.50 Customer Id CName 5004 Tom 5003 Jane 1/3/03 58.85 Customers

37 Alphabet Soup of Xtechs
XForms XML Document XSL Stylesheet XML Schema Languages & Formats XForms Model Marked up text XPath XSL-FO XHTML XSD XSLT HTML Software XForms Processor Editor & Validator XSL Parser Rendering Agent

38 </Discussion>

39 Nodes and Elements Customers Customer Id CName Transaction Transaction
5004 Tom 5003 Jane Transaction TDate Amt 1/1/03 -27.95 1/7/03 49.50 Transaction TDate Amt 1/3/03 58.85

40 <xsl:stylesheet xmlns:xsl=" version="1.0"> <xsl:template match="/Customers"> <html> <body> <h1>Customer Information</h1> <xsl:apply-templates select="Customer" /> </body> </html> </xsl:template> <xsl:template match="Customer"> <b>Id: </b> <xsl:value-of select="Id" /><br /> <b>Name: </b> <xsl:value-of select="CName" /><br /> <xsl:apply-templates select="Transaction" /> <br /><hr /><br /> <xsl:template match="Transaction"> <b>Date: </b> <xsl:value-of select="TDate" /> <b> Amount: </b> <xsl:value-of select="Amt" /><br /> </xsl:stylesheet>

41 <html> <body> <h1>Customer Information</h1> <b>Id: </b>5003<br> <b>Name: </b>Jane<br> <b>Date: </b> <b> Amount: </b>-27.85<br> <b>Date: </b> <b> Amount: </b>49.50<br> <br><hr><br> <b>Id: </b>5004<br> <b>Name: </b>Tom<br> <b>Date: </b> <b> Amount: </b>58.85<br> </body> </html>

42 <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="Customers.xsl"?> <Customers xmlns:mySchema="Customers.xsd"> <Customer> <Id>5003</Id> <CName>Jane</CName> <Transaction> <TDate> </TDate> <Amt>-27.85</Amt> </Transaction> <TDate> </TDate> <Amt>49.50</Amt> </Customer> <Id>5004</Id> <CName>Tom</CName> <TDate> </TDate> <Amt>58.85</Amt> </Customers>

43 Context and Selection Path
/ Transaction TDate Amt 1/1/03 -27.95 1/7/03 49.50 Customer Id CName 5004 Tom 5003 Jane 1/3/03 58.85 Customers /Customers /Customers/Customer /Customers/Customer/Transaction

44 Processing Order & Data Exposed
/ Transaction TDate Amt 1/1/03 -27.95 1/7/03 49.50 Customer Id CName 5004 Tom 5003 Jane 1/3/03 58.85 Customers Customers Customer #1 Customer #2 Transaction #1 Transaction #2 Transaction

45 Transform and Render XSLT Parser Transformation XPath XSLT
Well-formed Tree XSLT Parser XPath Transformation XSLT XSL Stylesheet Well-formed Tree XSL-FO (HTML/CSS) Rendering Agent Rendering

46 Alphabet Soup of Xtechs
XForms XML Document XSL Stylesheet XML Schema Languages & Formats XForms Model Marked up text XPath XSL-FO XHTML XSD XSLT HTML Software XForms Processor Editor & Validator XSL Parser Rendering Agent


Download ppt "<Discussion>."

Similar presentations


Ads by Google