Fundamental XML For Developers: Dr. Timothy M. Chester Texas A&M University
Fundamental XML For Developers: Dr. Timothy M. Chester Texas A&M University
Developers
Dr. Timothy M. Chester
Texas A&M University
Timothy M. Chester is. . .
• Senior IT Manager, Texas A&M University
– Application Development, Systems Integration, Developer Tools & Training
• Lecturer, Texas A&M College of Business
– Courses on Business Programming Fundamentals (VB.NET, C#), XML &
Advanced Web Development.
• Author
– Visual Studio Magazine, Dr. Dobbs Journal, IT Professional
• Consultant
– President & Principal, eInternet Studios
• Contact Information
– E-mail: [email protected]
– Web: http://tim-chester.tamu.edu
Texas A&M University
You Are. . .
• Software Developers
– New to XML, Object Oriented Development
– Require ‘basics’ of XML course
• IT Managers
– Need familiarity with XML basics and
terminology
– Interested in how XML can affect both
software development and legacy system
integration
This session . . .
• Assumes you know nothing about XML or
XML based technologies
• Provides a basic introduction to XML
based technologies
• Demonstrates some of the basics of
working with the DOM, XSLT, Schema,
WSDL, and SOAP.
Agenda
XML
• Document Object Model (DOM)
• XPATH
• XSLT
• Schema
• WSDL
• SOAP
• Questions
Underlying Technologies
XML Is the Glue
L
XML
HTM
gy /I P
h no lo TCP
Tec
Connecting
Connectivity Presentation
Inn Applications
FTP,
ov E-ma
ati il, Go
pher
on Web P
ages
Connect Web
Se rvice
the Web Browse s
the Web Program
the Web
Evolution of Web
HTML, XML
HTML HTML
HTML, XML
Partner
Web Service
Internet + XML
Other Applications
Introducing XML
• XML stands for Extensible Markup
Language. A markup language specifies
the structure and content of a document.
processing The part of the processing The target of the Represents an XML
instruction instruction that follows the processing processing instruction.
target and any whitespace. instruction.
namespace The URI of the namespace. The namespace Represents an XML
prefix. namespace.
Location Paths
• Location path
– Expression specifying how to navigate XPath
tree
– Composed of location steps
• Each location step composed of
– Axis
– Node test
– Predicate
Axes
• XPath searches are made relative to context
node
• Axis
– Indicates which nodes are included in search
• Relative to context node
– Dictates node ordering in set
• Forward axes select nodes that follow context node
• Reverse axes select nodes that precede context node
Node Tests
• Node tests
– Refine set of nodes selected by axis
• Rely upon axis’ principle node type
– Corresponds to type of node axis can select
Node-set Operators and
Functions (cont.)
• Location-path expressions
– Combine node-set operators and functions
• Select all head and body children element nodes
head | body
• Select last bold element node in head element node
head/title[ last() ]
• Select third book element
book[ position() = 3 ]
– Or alternatively
book[ 3 ]
• Return total number of element-node children
count( * )
• Select all book element nodes in document
//book
Agenda
XML
Document Object Model (DOM)
XPATH
XSLT
• Schema
• WSDL
• SOAP
• Questions
Introduction
• Extensible Stylesheet Language (XSL)
– Used to format XML documents
– Consist of two parts
• XSL Transformation Language (XSLT)
– Transform XML document from one form to another
– Use XPath to match nodes
• XSL formatting objects
– Alternative to CSS
Setup
• XSLT processor
– Microsoft Internet Explorer 6
– Java 2 Standard Edition
– Microsoft.NET System.Xml Namespace
Templates
• XSLT document
– XML document with root element stylesheet
– template element
• Matches specific XML document nodes
• Uses XPath expression in attribute match
Templates (cont.)
• XSLT
– Two trees of nodes
• Source tree corresponds to original XML document
• Result tree contains nodes produced by
transformation
– Transforms intro.xml into HTML document
Iteration and Sorting
• XSLT allows
– Iteration through node set
• Element for-each
– Sorting node set
• Element sort
– Attribute ascending (i.e., A-Z)
– Attribute descending (i.e., Z-A)
Conditional Processing
• Perform conditional processing
– Such as if statement
– Use element choose
• Allows alternate conditional statements
• Similar to switch statement
• Has child elements when and otherwise
– when element content used if condition is met
– otherwise element content used if no conditions in
when condition are met
XSLT and XPath
• XPath Expression
– locates elements, attributes and text in XML
document
Agenda
XML
Document Object Model (DOM)
XPATH
XSLT
Schema
• WSDL
• SOAP
• Questions
Working with Namespaces
• Name collision occurs when elements from two
or more documents share the same name.
<?xml:namespace ns=http://uhosp/patients/ns
prefix=“pat”>
<?xml version=“1.0”?>
<soap:Envelope ...>
...
</soap:Envelope>
SOAP
Message Structure
<?xml version=“1.0”?>
<soap:Envelope ...>
<soap:Header ...>
...
</soap:Header>
<soap:Body>
<Add xmlns=“http://tempuri.org/”>
<n1>12</n1>
<n2>10</n2>
</Add>
</soap:Body>
</soap:Envelope>
SOAP
Server Responses
• Server replies with a “result” message:
HTTP/1.1 200 OK
...
Content-Type:text/xml
Content-Length: 391
<?xml version=“1.0”?>
<soap:Envelope ...>
<soap:Body>
<AddResult xmlns=“http://tempuri.org/”>
<result>28.6</result>
</AddResult>
</soap:Body>
</soap:Envelope>
SOAP
Industry Support
• DevelopMentor Inc. • Microsoft
• Digital Creations • Rogue Wave Software Inc.
• IONA Technologies PLC • Scriptics Corp.
• Jetform • Secret Labs AB
• ObjectSpace Inc. • UserLand Software Inc.
• Rockwell Software Inc. • Zveno Pty. Ltd.
• SAP • IBM
• Compaq • Hewlett Packard
• Intel
Agenda
XML
Document Object Model (DOM)
XPATH
XSLT
Schema
WSDL
SOAP
Questions
Questions
Bibliography
• Harvey Deitel’s “XML:How To Program”
• Prentice Hall XML Reference
• Microsoft Academic Resource Kit