15
COP 3813 COP 3813 Intro to Internet Intro to Internet Computing Computing Prof. Roy Levow Prof. Roy Levow XML XML

COP 3813 Intro to Internet Computing Prof. Roy Levow XML

Embed Size (px)

Citation preview

Page 1: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

COP 3813COP 3813Intro to Internet Intro to Internet

ComputingComputing

Prof. Roy LevowProf. Roy Levow

XMLXML

Page 2: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

XMLXML

W3C StandardW3C Standard Elements describe dataElements describe data

– Propertes and OperationsPropertes and Operations– No formatting instructionsNo formatting instructions

But may be provided by XSLBut may be provided by XSL Language used to define other Language used to define other

markup languagesmarkup languages– XHTML, MathML, VoiceXML, …XHTML, MathML, VoiceXML, …

Processing requires and XML parserProcessing requires and XML parser

Page 3: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

XML MarkupXML Markup

Creates a tree-structure for a Creates a tree-structure for a documentdocument

Example: News article Example: News article fig. 20.1fig. 20.1

Latest generation of browsers display Latest generation of browsers display parsed XML using indentation to parsed XML using indentation to show tree structureshow tree structure

Page 4: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

XML DTDXML DTD

Document type definition (DTD)Document type definition (DTD)– Defines allowed content of an XML Defines allowed content of an XML

documentdocument Example: Example:

– Business Letter XML Business Letter XML fig. 20.3fig. 20.3– Business Letter DTD fig. 20.6Business Letter DTD fig. 20.6

Page 5: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

XML ValidationXML Validation

XML validation tools are available for XML validation tools are available for download from the webdownload from the web– Microsoft’s tool is available from Microsoft’s tool is available from

msdn.microsoft.com, search for XML msdn.microsoft.com, search for XML ValidatorValidator

Page 6: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

XML NamespacesXML Namespaces

XML components can come from XML components can come from many sourcesmany sources

Need to be able to differentiate Need to be able to differentiate among possible duplicate names among possible duplicate names from different sourcesfrom different sources

Use namespaceUse namespace– Uniform Resource Identifier (URI)Uniform Resource Identifier (URI)– Like a URL but more generalLike a URL but more general

Page 7: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

XML Namespaces.2XML Namespaces.2

Namespace uriNamespace uri– similar to a url similar to a url

includes urls but more generalincludes urls but more general

– must be uniquemust be unique Rather than use a complete uri, Rather than use a complete uri,

define a short dictionary name to use define a short dictionary name to use in documentin document– specify xmlnsspecify xmlns

Page 8: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

XML Namespaces .3XML Namespaces .3

Example namespacesExample namespaces– fig. 20.4fig. 20.4

Example with defaultExample with default– note no name on xmlns for defaultnote no name on xmlns for default– fig. 20.5fig. 20.5

Page 9: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

XML DTDs and SchemasXML DTDs and Schemas

Document Type DefinitionDocument Type Definition– Specifies elements for markup of a Specifies elements for markup of a

particular type of documentparticular type of document Example: Example: fig 20.6fig 20.6

SchemasSchemas– More versatile than DTDsMore versatile than DTDs

Example: Example: fig. 20.7fig. 20.7, , fig. 20.8fig. 20.8

Page 10: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

Really Simple Syndicaton – RSSReally Simple Syndicaton – RSS

Also known asAlso known as– Rich Site SummaryRich Site Summary– RDF (Resource Description Framework) RDF (Resource Description Framework)

Site SummarySite Summary Used to deliver content, a feed, that Used to deliver content, a feed, that

is manipulated by other programsis manipulated by other programs Aggregator is an RSS program that Aggregator is an RSS program that

combines data from multiple feedscombines data from multiple feeds

Page 11: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

RSS VersionsRSS Versions

Multiple versions in useMultiple versions in use– v0.90 – Netscape (for news headlines)v0.90 – Netscape (for news headlines)– v0.9x – UserLandv0.9x – UserLand– v1.0 – RSS-DEV Working Groupv1.0 – RSS-DEV Working Group– v2.0 –UserLandv2.0 –UserLand

UserLand is community effortUserLand is community effort RSS-DEV is single vendorRSS-DEV is single vendor

Page 12: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

Document Object Model - DOMDocument Object Model - DOM

Parser produces tree of objectsParser produces tree of objects– reflecting document structurereflecting document structure– JavaScript provides methods toJavaScript provides methods to

Traverse treeTraverse treeGet node informationGet node informationModify treeModify tree

Create withCreate withxmlDoucment.load(“file”);xmlDoucment.load(“file”);

Page 13: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

Some DOM MethodsSome DOM Methods

getNodeName – returns #namegetNodeName – returns #name getParentNodegetParentNode getFirstChild, getLastChildgetFirstChild, getLastChild getNextSibling, getPreviousSiblinggetNextSibling, getPreviousSibling getNamedItemgetNamedItem getValue, getNamegetValue, getName Example: fig 20.19Example: fig 20.19

Page 14: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

Extensible Stylesheet Language - Extensible Stylesheet Language - XLSXLS

XSL-FO, Formatting ObjectsXSL-FO, Formatting Objects XSLT, TransformationsXSLT, Transformations XPath, Locates nodesXPath, Locates nodes SXL Elements (form)SXL Elements (form)

– <xsl:name parameters><xsl:name parameters>

Page 15: COP 3813 Intro to Internet Computing Prof. Roy Levow XML

XSL ElementsXSL Elements

<xls:output><xls:output> <xsl:value-of select = “expr”><xsl:value-of select = “expr”> <xsl:for-each select = “expr”><xsl:for-each select = “expr”> <xsl:sort select = “expr”><xsl:sort select = “expr”>

Examples: fig 20.29, 20.30Examples: fig 20.29, 20.30