17
Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COP 4814 – Web Services Dr. Roy Levow Part 4 - XML

Fall 2006

Embed Size (px)

DESCRIPTION

Florida Atlantic University Department of Computer Science & Engineering. COP 4814 – Web Services Dr. Roy Levow Part 4 - XML. Fall 2006. XML support generally limited to IE and Firefox XML in IE Microsoft.XmlDom in IE4.0 MSXML ActiveX in IE 5.0+ But only on Windows; not on MAC - PowerPoint PPT Presentation

Citation preview

Page 1: Fall 2006

Fall 2006

Florida Atlantic UniversityDepartment of Computer Science & Engineering

COP 4814 – Web Services

Dr. Roy Levow

Part 4 - XML

Page 2: Fall 2006

Web Services – Fall 2006

XML, XPath, XSLT XML support generally limited to IE and

Firefox XML in IE

Microsoft.XmlDom in IE4.0MSXML ActiveX in IE 5.0+

• But only on Windows; not on MAC

Text uses createDocument() for cross-IE compatability

XML DOM object created from string

Page 3: Fall 2006

Web Services – Fall 2006

XML DOM Navigation DOM object properties

childNodes, firstChild, lastChild, parentNode, nextSibling, previousSibling, nodeName, nodeType, nodeValuetext, attributesxmlownerDocument – root node

Navigate tree with these functions

Page 4: Fall 2006

Web Services – Fall 2006

IE XML DOM Navigation Examples Examples: IE DOM

DOM creation Get Elements by Tag NameCreate NodeInsert NodeRemove ChildReplace Child

Page 5: Fall 2006

Web Services – Fall 2006

IE XML DOM Error Handling Creates and propagates exception object

parseError parseError object provides details

errorCode, reasonfilePos, line, linePossrcTexturl

Page 6: Fall 2006

Web Services – Fall 2006

XML DOM in Firefox Uses createDocument() method to generate

DOM objectEmptyFrom stringFrom url

load() method loads from a url String version of XML subtree is produced by

XMLSerializer object

Page 7: Fall 2006

Web Services – Fall 2006

XML DOM in Firefox - 2 Error handling

Firefox produces an error document• Not the error object of IE• It can be parsed to get the same information

Page 8: Fall 2006

Web Services – Fall 2006

Firefox XML DOM - 3 Examples: Firefox DOM

DOM DreationDOM ParserGet textSerializeError handling

Page 9: Fall 2006

Web Services – Fall 2006

Cross-Browser XML Requires library to create standard calls for

operationsText provides zXml libraryzXmlDom.createDocument()

Examples: Cross-Browser DOMProcessing Book List

Page 10: Fall 2006

Web Services – Fall 2006

XML Namespaces XML uses namespace concept to resolve

naming conflicts between documents from different sourcesTag name has form ns:tagNameDeclared as xmlsn:ns-prefix=“nsURI”

• URI has same syntax as URL but need not be real address

• Should be unique• Declarations in root tag of document

Page 11: Fall 2006

Web Services – Fall 2006

XPath XPath expressions

Context node is partial path from which selection begins

• book/author – this parent-child sequence

Selection pattern specifies which nodes to include

• book[@isbn=‘0010001001’]• Expressions have own syntax and can be quite

complex

Page 12: Fall 2006

Web Services – Fall 2006

XPath in IE and Firefox IE uses two functions

selectSingleNode()selectNodes()Examples: IE XPath

Firefox uses two objectsXPathEvaluatorXPathResultExamples: Firefox XPath

Page 13: Fall 2006

Web Services – Fall 2006

Cross-Browser XPath Use zXml library

Same functions as IE Examples: Cross-Browser XPath

Page 14: Fall 2006

Web Services – Fall 2006

XSL Transformations Transformation is done with

xsl:stylesheet with XML specific elementsxsl:template to select XMLnodes to processxsl:variable to select attributes from nodes

Examples: XSLT

Page 15: Fall 2006

Web Services – Fall 2006

XSLT in IE Browser becomes an issue when DOM is

used in conjunction with XSLT Must create ActiveX XSLTemplate object Create processor object from template object transform() method does transformation

Result is output property of processor Examples: XSLT in IE

Page 16: Fall 2006

Web Services – Fall 2006

Cross-Browser XSLT Requires library

Text provides this in zXmlSyntax similar to Firefox

Example: Best Picks Revisited

Page 17: Fall 2006

Web Services – Fall 2006

XSLT in Firefox First load XML and XSL into DOM objects Create XSLTProcessor

Import XSL stylesheetTransform XmlDOM document or fragment

Examples: XSL in Firefox