XDR XML Data Reduced An earlier XML schemaCSS Cascading Style Sheets Allows you to specify styles XSL Extensible Stylesheet Language Language for expressing stylesheets; consists of XS
Trang 1Standards in Information
Management: XML
Arijit Sengupta
Trang 2Learning Objectives
• Learn what XML is
• Learn the various ways in which XML is used
• Learn the key companion technologies
• See how XML is being used in industry as a language
Trang 3Agenda
• Overview
• Syntax and Structure
• The XML Alphabet Soup
• XML as a meta-language
Trang 4Overview
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)
Trang 7Overview
XML and Structured Data
• Pre-XML representation of data:
• XML representation of the same data:
1234”,”CUST001”,”X9876”,”5”,”14.98
“PO-”
<PURCHASE_ORDER>
<PO_NUM> PO-1234 </PO_NUM>
<CUST_ID> CUST001 </CUST_ID>
<ITEM_NUM> X9876 </ITEM_NUM>
<QUANTITY> 5 </QUANTITY>
<PRICE> 14.98 </PRICE>
</PURCHASE_ORDER>
Trang 10Agenda
• Overview
• Syntax and Structure
• The XML Alphabet Soup
• XML as a meta-language
Trang 12<ELEMENT3 type=‘string’> </ELEMENT3>
<ELEMENT4 type=‘integer’ value=‘9.3’> </ELEMENT4>
</ROOT>
Elements
Elements with Attributes
Trang 13Syntax 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
<tag> and <TAG> are not the same type of
element
Trang 18Syntax and Structure
Namespaces: Overview
• Part of XML’s 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
Trang 19Namespace declaration examples:
Namespace declaration Prefix URI (URL)
xmlns: bk =
“http://www.example.com/bookinfo/”
Trang 21Syntax 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:
<BOOK
xmlns=“http://www.bookstuff.org/bookinfo”> <TITLE>All About XML</TITLE>
<AUTHOR>Joe Developer</AUTHOR>
Trang 23Syntax 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
Trang 24• 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.
Entity Substitution
< <
& &
Trang 25Agenda
• Overview
• Syntax and Structure
• The XML Alphabet Soup
• XML as a meta-language
Trang 26The XML ‘Alphabet Soup’
• XML itself is fairly simple
• Most of the learning curve is knowing about
all of the related technologies
Trang 27XDR 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
Trang 28The 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 Describes links between XML documents XQuery XML Query Language
(draft) Flexible mechanism for querying XML data as if it were a database DOM Document Object
Model API to read, create and edit XML documents; creates in-memory
object model SAX Simple API for XML API to parse XML documents;
event-driven Data Island XML data embedded in a HTML page
Data Automatic population of HTML elements from XML data
Trang 29 Supports data types
Current standard recommended by W3C
Trang 30 More restrictive than well-formed XML
• Define which elements are present and
in what order
• Define the structural relationships of elements
Trang 31<!ELEMENT BOOK (TITLE+, AUTHOR) >
<!ELEMENT TITLE (#PCDATA) >
<!ELEMENT AUTHOR (#PCDATA) >
Trang 34The 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
Trang 35The XML ‘Alphabet Soup’
Transformations: XSL
• Language for expressing document styles
• Specifies the presentation of XML
More powerful than CSS
Trang 36The XML ‘Alphabet Soup’
Transformations: Overview
• XSLT – a language used to transform XML data into a
different form (commonly XML or HTML)
XML, HTML,
… XML
XSLT
Trang 37The 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.
Trang 38The 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.)
Trang 39The 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
Selects the parent of the current node
* Wildcard
@ Prefix to attribute name (when alone, it is an attribute
wildcard)[ ] Applies filter pattern
Trang 40The 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)
Trang 41More XPath Examples
Path Expression Result
/bookstore/book[1] Selects the first book element that is the child of the
bookstore element /bookstore/book[last()] Selects the last book element that is the child of the
bookstore element /bookstore/book[last()-1] Selects the last but one book element that is the child of
the bookstore element /bookstore/book[position()<3] Selects the first two book elements that are children of the
bookstore element //title[@lang] Selects all the title elements that have an attribute named
lang //title[@lang='eng'] Selects all the title elements that have an attribute named
lang with a value of 'eng' /bookstore/book[price>35.00] Selects all the book elements of the bookstore element
that have a price element with a value greater than 35.00
/bookstore/book[price>35.00]/title Selects all the title elements of the book elements of the
bookstore element that have a price element with a value greater than 35.00
Trang 42XPath Functions
• Accessor functions:
node-name, data, base-uri, document-uri
• Numeric value functions:
abs, ceiling, floor, round, …
• String functions:
compare, concat, substring, string-length, uppercase, lowercase, starts-with, ends-with, matches, replace, …
• Other functions include functions on boolean values, dates, nodes, etc
Trang 44The XML ‘Alphabet Soup’
Data Islands
• Can be embedded in an HTML SCRIPT element
• XML is accessible via the DOM:
<SCRIPT language=“xml” id=“XMLID”>
<SCRIPT type=“text/xml” id=“XMLID”>
<SCRIPT language=“xml” id=“XMLID”
src=“mydocument.xml”>
Trang 45Join XML data with existing database tables
Update the database via XML Updategrams
New XML data type in SQL 2005
• Microsoft Exchange Server
XML is native representation of many types of
data
Used to enhance performance of UI scenarios
(for example, Outlook Web Access (OWA))
Trang 46Agenda
• Overview
• Syntax and Structure
• The XML Alphabet Soup
• XML as a meta-language
Trang 47WML
XQL
A Language to create Languages
GO
Trang 48Gene Ontology (GO)
• Describing and manipulating information about the molecular function, biological process and cellular component of gene products
• Gene Ontology website:
Trang 50 see sample documents here
some require plug-in downloads, can be slow
Trang 51Wireless ML
• Allows web pages to be displayed over mobile devices
• WML works with WAP to deliver the content
• Underlying model: Deck of Cards that the User can sift
Trang 52Scalable Vector Graphics
• Describing vector graphics data for use over the web
• Rendering is done on the browser
• Bandwidth demands lower, scaling easier
www.irt.org/articles/js176 1999 article and
good, brief tutorial
planet.svg An Example from Deitel
Trang 53Bean ML
• Describing software components such as Java Beans
• Defines how the components are interconnected and can be used
• Bean ML Specs and Tools
www.alphaworks.ibm.com/aw.nsf/techmain/bml
• Bean ML Resources
www.oasis-open.org/cover/beanML.html
With Bean ML
• You can mark-up beans using Bean ML
• And invoke different operations on Beans
• Includes BML Scripting Framework
Trang 54XBRL
• Extensible Business Reporting Language
• Capturing and representing financial and accounting information
• Variety of situations
e.g publishing reports, extracting data for
analysis, regulatory forms etc.
• Initiated under the direction of AICPA
Trang 56 See also Whitepapers link explaining how these can be used for
• E-procurement
• E-fulfillment
• And others
Trang 58ebXML
• UN/CEFACT: the United Nations body whose mandate covers worldwide policy and technical development in the area of trade facilitation and electronic business
Still needs buy-in from the larger IS/IT vendors
• Related Effort: RosettaNet
http://www.rosettanet.org/rosettanet/Rooms/DisplayPages
/LayoutInitial
Business Processes for IT, Component and Chip companies
Trang 59Conclusion
• Overview
• Syntax and Structure
• The XML Alphabet Soup
• XML as a meta-language