XML - ecs.syr.edu

XML - ecs.syr.edu

XML Mark Sapossnek CS 594 Computer Science Department Metropolitan College Boston University Jump Table Added for CSE681

Components of an XML Document Syntax and Structure An XML Document Syntax and Structure Namespaces: Overview The XML Alphabet Soup Transformations: XSL XPath (XML Path Language) XML in .NET Core Classes in System.XML Learning Objectives Learn what XML is Learn the various ways in which XML is used Learn the key companion technologies Learn how to use the .NET framework to read,

write, and navigate XML documents Agenda Overview Syntax and Structure The XML Alphabet Soup XML in .NET Relational Data and XML Overview What is XML?

A tag-based meta language Designed for structured data representation Represents data hierarchically (in a tree) Provides context to data (makes it meaningful) Self-describing data Separates presentation (HTML) from data (XML) An open W3C standard A subset of SGML

vs. HTML, which is an implementation of SGML Overview What is XML? XML is a use everywhere data specification XML XML Application X Documents XML Repository XML

Database Configuration Overview Documents vs. Data XML is used to represent two main types of things: Documents Lots of text with tags to identify and annotate portions

of the document Data Hierarchical data structures Overview XML and Structured Data Pre-XML representation of data: PO-1234,CUST001,X9876,5,14.98 XML representation of the same data: PO-1234 CUST001 X9876

5 14.98 Overview Benefits of XML Open W3C standard Representation of data across heterogeneous environments Cross platform Allows for high degree of interoperability Strict rules

Syntax Structure Case sensitive Overview Who Uses XML? Submissions by

Microsoft IBM Hewlett-Packard Fujitsu Laboratories Sun Microsystems Netscape (AOL), and others Technologies using XML SOAP, ebXML, BizTalk, WebSphere, many others Agenda

Overview Syntax and Structure The XML Alphabet Soup XML in .NET Relational Data and XML Syntax and Structure Components of an XML Document Elements Each element has a beginning and ending tag

... Elements can be empty () Attributes Describes an element; e.g. data type, data range, etc. Can only appear on beginning tag Processing instructions Encoding specification (Unicode by default) Namespace declaration

Schema declaration Syntax and Structure Components of an XML Document Elements with Attributes Elements Prologue (processing instructions)

Syntax and Structure Rules For Well-Formed XML There must be one, and only one, root element Sub-elements must be properly nested A tag must end within the tag in which it was started Attributes are optional Defined by an optional schema Attribute values must be enclosed in or Processing instructions are optional XML is case-sensitive

and are not the same type of element Syntax and Structure Well-Formed XML? No, CHILD2 and CHILD3 do not nest propertly This is element 1 Number 3 Syntax and Structure Well-Formed XML? No, there are two root elements

This is element 1 This is another element 1 Syntax and Structure Well-Formed XML? Yes This is element 1

Syntax and Structure An XML Document The Autobiography of Benjamin Franklin Benjamin Franklin 8.99 The Confidence Man

Herman Melville 11.99 Syntax and Structure Namespaces: Overview Part of XMLs extensibility Allow authors to differentiate between tags of the same name (using a prefix) Frees author to focus on the data and decide how to

best describe it Allows multiple XML documents from multiple authors to be merged Identified by a URI (Uniform Resource Identifier) When a URL is used, it does NOT have to represent a live server Syntax and Structure Namespaces: Declaration Namespace declaration examples: xmlns: bk = http://www.example.com/bookinfo/ xmlns: bk = urn:mybookstuff.org:bookinfo xmlns: bk = http://www.example.com/bookinfo/

Namespace declaration Prefix URI (URL) Syntax and Structure Namespaces: Examples All About XML Joe Developer 19.99 All About XML Joe Developer

19.99 Syntax and Structure Namespaces: Default Namespace An XML namespace declared without a prefix becomes the default namespace for all sub-elements All elements without a prefix will belong to the default namespace: All About XML Joe Developer Syntax and Structure Namespaces: Scope Unqualified elements belong to the inner-most

default namespace. BOOK, TITLE, and AUTHOR belong to the default book namespace PUBLISHER and NAME belong to the default publisher namespace All About XML Joe Developer Microsoft Press

Syntax and Structure Namespaces: Attributes Unqualified attributes do NOT belong to any namespace Even if there is a default namespace This differs from elements, which belong to the default namespace Syntax and Structure Entities Entities provide a mechanism for textual substitution, e.g. Entity

Substitution < < & & You can define your own entities Parsed entities can contain text and markup Unparsed entities can contain any data JPEG photos, GIF files, movies, etc. Agenda

Overview Syntax and Structure The XML Alphabet Soup XML in .NET Relational Data and XML The XML Alphabet Soup XML itself is fairly simple Most of the learning curve is knowing about all of the related technologies The XML Alphabet Soup XML

Extensible Markup Language Defines XML documents Infoset Information Set Abstract model of XML data; definition of terms DTD Document Type Definition Non-XML schema

XSD XML Schema XML-based schema language XDR XML Data Reduced An earlier XML schema CSS Cascading Style Sheets Allows you to specify styles

XSL Extensible Stylesheet Language Language for expressing stylesheets; consists of XSLT and XSL-FO XSLT XSL Transformations Language for transforming XML documents XSL-FO

XSL Formatting Objects Language to describe precise layout of text on a page The XML Alphabet Soup XPath XML Path Language A language for addressing parts of an XML document, designed to be used by both XSLT and XPointer XPointer XML Pointer Language

Supports addressing into the internal structures of XML documents XLink XML Linking Language XQuery XML Query Language (draft) Describes links between XML documents Flexible mechanism for querying XML data as if it were a database DOM

Document Object Model SAX Simple API for XML Data Island API to read, create and edit XML documents; creates in-memory object model API to parse XML documents; eventdriven XML data embedded in a HTML page Data Binding Automatic population of HTML elements from XML data

The XML Alphabet Soup Schemas: Overview DTD (Document Type Definitions) Not written in XML No support for data types or namespaces XSD (XML Schema Definition) Written in XML Supports data types Current standard recommended by W3C

XDR (XML Data Reduced schema) Interim schema proposed by Microsoft Obsoleted by XSD The XML Alphabet Soup Schemas: Purpose Define the rules (grammar) of the document Data types Value bounds

A XML document that conforms to a schema is said to be valid More restrictive than well-formed XML Define which elements are present and in what order Define the structural relationships of elements The XML Alphabet Soup Schemas: DTD Example XML document: All About XML Joe Developer

DTD schema: BOOK BOOK TITLE AUTHOR [ (TITLE+, AUTHOR) > (#PCDATA) > (#PCDATA) >

The XML Alphabet Soup Schemas: XSD Example XML document: All About XML Joe Developer The XML Alphabet Soup Schemas: XSD Example

xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">

The XML Alphabet Soup Schemas: Why You Should Use XSD Newest W3C Standard Broad support for data types Reusable components Simple data types Complex data types

Extensible Inheritance support Namespace support Ability to map to relational database tables XSD support in Visual Studio.NET The XML Alphabet Soup Transformations: XSL Language for expressing document styles Specifies the presentation of XML More powerful than CSS Consists of:

XSLT XPath XSL Formatting Objects (XSL-FO) The XML Alphabet Soup Transformations: Overview XSLT a language used to transform XML data into a different form (commonly XML or HTML) XML XML, HTML, XSLT

The XML Alphabet Soup Transformations: XSLT The language used for converting XML documents into other forms Describes how the document is transformed Expressed as an XML document (.xsl) Template rules Patterns match nodes in source document Templates instantiated to form part of result document Uses XPath for querying, sorting, etc. The XML Alphabet Soup Transformations: Example

Scootney Publishing Regional Sales Report Sales Report

West Coast ...

/> /> /> /> The XML Alphabet Soup Transformations: Example

...

...

...

Region\Quarter Q
color:red; color:green; The XML Alphabet Soup Transformations: Example The XML Alphabet Soup XSL Formatting Objects (XSL-FO)

A set of formatting semantics Denotes typographic elements (for example: page, paragraph, rule, etc.) Allows finer control obtained via formatting elements Word, letter spacing Indentation Widow, orphan, hyphenation control Font style, etc. The XML Alphabet Soup XPath (XML Path Language)

General purpose query language for identifying nodes in an XML document Declarative (vs. procedural) Contextual the results depend on current node Supports standard comparison, Boolean and mathematical operators (=, <, and, or, *, +, etc.) The XML Alphabet Soup XPath Operators Operator Usage Description / Child operator selects only immediate children (when at the beginning of the pattern, context is root) //

Recursive descent selects elements at any depth (when at the beginning of the pattern, context is root) . Indicates current context * Wildcard @ Prefix to attribute name (when alone, it is an attribute wildcard) [ ]

Applies filter pattern The XML Alphabet Soup XPath Query Examples ./author (finds all author elements within current context) /bookstore (find the bookstore element at the root) /* (find the root element) //author (find all author elements anywhere in document)

/bookstore[@specialty = textbooks] (find all bookstores where the specialty attribute = textbooks) /book[@style = /bookstore/@specialty] (find all books where the style attribute = the specialty attribute of the bookstore element at the root) The XML Alphabet Soup XPointer Builds upon XPath to: Identify sub-node data Identify a range of data

Identify data in local document or remote documents New standard The XML Alphabet Soup XLink XML Linking Language Elements of XML documents Describes links between resources Simple links (for example, HTML HREFs) Extended links Remote resources Local resources Rules for how a link is followed, etc.

The XML Alphabet Soup The XML DOM XML Document Object Model (DOM) Provides a programming interface for manipulating XML documents in memory Includes a set of objects and interfaces that represent the content and structure of an XML document Enables a program to traverse an XML tree Allows elements, attributes, etc., to be added/deleted in an XML tree Allows new XML documents to be created programmatically The XML Alphabet Soup SAX (Simple API for XML)

API to allow developers to read/write XML data Event based Uses a push model Sequential access only (data not cached) Requires less memory to process XML data than the DOM SAX has less overhead (uses small input, work and output buffers) than the DOM DOM constructs the data structure in memory (work and output buffers = to size of data)

The XML Alphabet Soup Data Islands XML embedded in an HTML document Manipulated via client side script or data binding All About XML Joe Developer The XML Alphabet Soup Data Islands Can be embedded in an HTML SCRIPT element

XML is accessible via the DOM:

Recently Viewed Presentations

  • Revoluções de 1830 e 1848

    Revoluções de 1830 e 1848

    Resistência a Napoleão. Lenta decadência. Deposição de monarquias absolutistas na Europa. 1812 - Campanha da Rússia. Grande derrota de Napoleão. "terra arrasada". 1814 - Sexta Coligação (RUS + ING + AUS + PRUS) vence Napoleão. Exílio em Elba. Retorno -...
  • Blueprint reading - Mediapolis Community School

    Blueprint reading - Mediapolis Community School

    Alphabet of lines. Universal language of technician, architect, & engineer. Basis of all construction drawings. Many different line types, thicknesses, and applications. Understanding Line Types. Object lines. Also known as visible lines.
  • Chapter 6 Electronic Structure of Atoms

    Chapter 6 Electronic Structure of Atoms

    Atomic Radius-more levels of. shielding (less attraction) in. creases down . group-more . nuclear charge (more attraction) de. creases across . period. Note: covalent or metallic radius of bonded atoms vs. van der Waals radius of nonbonded atoms (Noble Gases)
  • Evangelio San Juan 14, 15-21 - WordPress.com

    Evangelio San Juan 14, 15-21 - WordPress.com

    Evangelio según San Juan San Juan (14, 15 - 21) Frase de Padre Jaimito Lectura del Santo Evangelio según san Juan (14, 15-21) Gloria a ti, Señor.
  • In Texas, Rivers Flow to the Gulf of Mexico

    In Texas, Rivers Flow to the Gulf of Mexico

    Rivers to the Ocean Texas Waters, Rivers and the Gulf of Mexico The Water Cycle - Nature's Recycling System Watersheds feed our water supply Texas Sources of Fresh Water Surface water Rivers, streams, lakes make up river basins Groundwater Over...
  • Infections in diabetes Dr Priscilla Rupali Dept of

    Infections in diabetes Dr Priscilla Rupali Dept of

    Infections in diabetes Dr Priscilla Rupali Dept of Medicine-I &I.D CMCH Vellore Worrying symptoms Foul smelling vaginal discharge Dysuria, painful urination Fever Painful swallowing Changes in bowel habits Warmth or redness at the site of a scrape or cut Or...
  • Forest Ridge Elementary School Welcome! Back to School

    Forest Ridge Elementary School Welcome! Back to School

    Team 2 will follow the HCPSS guidelines for homework. Second graders should be completing a total of 30 minutes of homework a night. Each student will receive a reading log and a math activity sheet. They should be reading at...
  • Costa Rica June 15th, 2020  June 23rd, 2020

    Costa Rica June 15th, 2020 June 23rd, 2020

    Costa Rica . June 15th, 2020 - June 23rd, 2020. Why I travel. Michelle Nispel. I love to see new and exciting places. I have traveled to: Italy. Switzerland. France . Germany. Austria. ... PowerPoint Presentation Last modified by: Nispel,...