• No results found

Tim's XML Braindump I

N/A
N/A
Protected

Academic year: 2021

Share "Tim's XML Braindump I"

Copied!
22
0
0

Loading.... (view fulltext now)

Full text

(1)

Tim's XML Braindump I

An Overview of XML

Stolen from lots of online sources!

compiled by Tim

(2)

Outline

 XML in a Nutshell

 What does XML mean to you?

 What’s Real and What’s Hype?

 XML Technologies (XSLT/XPath)

 XML and Object “databases”

 Something for the coders

(3)

XML in a Nutshell

 Structured data in a text file via markup

 Looks like HTML but isn't

 Human-legible but not designed for that

 New, but not that new

 License-free, platform-independent and well-supported

 A family of technologies

 Related to Unicode, URNs, Web Services

(4)

Uses of XML

 Configuration files

 Gnome desktop, Pedro

 Data interchange

 OpenOffice documents, MAGE-ML,

 maxdML

 Web services and B2B transactions

 RSS, SOAP, IFX (financial exchange)

(5)

Why should you know about XML?

 XML solves real world problems

 Standards are multiplying like rabbits (both good and bad)

 Everyone is using it - companies and academia

 It may even be interesting!

(6)

The rant - what XML is not

 Not a drop-in solution

 Not an alternative to RDBMS

 Not for storing 'bulk' data

 Not self-describing (though it can be self-validating)

 Not pretty

 Not for end-users

(7)

The rant - the witty quote

“XML is not the answer to all the world’s problems—it creates new problems, that are awfully damn

interesting to solve.”

Simon St. Laurent,

author of XML: A Primer,

on the xml-dev mailing list

(8)

Anatomy of an XML Document

<?xml version="1.0"?>

<beerlist>

<beer name=”Old Speckled Hen”>

<abv>5.2</abv>

<brewery>Moorland</brewery>

</beer>

<beer name=”Chocolate Stout”>

<abv>4.5</abv>

<brewery>Youngs</brewery>

</beer>

<!-- Beer is your friend -->

</beerlist>

(9)

Anatomy of an XML Document

<?xml version="1.0"?>

<beerlist>

<beer name=”Old Speckled Hen”>

<abv>5.2</abv>

<brewery>Moorland</brewery>

</beer>

<beer name=”Chocolate Stout”>

<abv>4.5</abv>

<brewery>Youngs</brewery>

</beer>

<!-- Beer is your friend -->

</beerlist>

Prolog

Text Closing tag

Tag with attribute/value pair Document element tag

Comment

(10)

Well formed and valid XML

 To be XML a document must be “well formed”.

 eg:

 Has an <?XML ...> declaration on line 1

 Only one document element

 All tags nested properly and closed

 All tag names are valid

 No special characters in the text fields

(11)

Additionally XML may be validated

 Validate against a DTD specific to a document type.

 DTD may be in the document or in a separate file.

<?xml version="1.0" standalone="yes"?>

<DOCTYPE beerlist [

<!ELEMENT beerlist (beer)*>

<!ATTLIST beerlist name CDATA #IMPLIED>

<!ELEMENT beer (abv, brewery)>

<!ELEMENT abv (#PCDATA)>

<!ELEMENT brewery (#PCDATA)>

]>

(12)

XML Schemas - why?

 Various limitations of DTDs

 DTD itself is not in XML format - more work for parsers

 Does not express data types (weak data typing)

 No namespace support

 Document can override external DTD definitions

 No DOM support

 XML Schema is intended to resolve these issues

but ... DTDs are going to be around for a while

(13)

XML Schema basics

 Schema is a separate XML document

 A document maps namespaces to schemas.

 Pedro or XMLSpy can 'animate' a schema.

 A schema document can be validated

against the schema-schema!

(14)

<!-- XML Schema schema for XML Schemas : Part 1: Structures -->

<xs:schema targetNamespace="http://www.w3.org/2001/XMLSchema" blockDefault="#all"

elementFormDefault="qualified" version="1.0" xml:lang="EN">

<xs:annotation>

<xs:documentation>

Part 1 version: Id: structures.xsd,v 1.2 2004/01/15 11:34:25 ht Exp Part 2 version: Id: datatypes.xsd,v 1.3 2004/01/23 18:11:13 ht Exp </xs:documentation>

</xs:annotation>

<xs:annotation>

<xs:documentation source="http://www.w3.org/TR/2004/PER-xmlschema-1- 20040318/structures.html">

The schema corresponding to this document is normative, with respect to the syntactic constraints it expresses in the XML Schema language. The documentation (within

<documentation> elements) below, is not normative, but rather highlights important aspects of the W3C Recommendation of which this is a part

</xs:documentation>

</xs:annotation>

<xs:import namespace="http://www.w3.org/XML/1998/namespace"

schemaLocation="http://www.w3.org/2001/xml.xsd">

<xs:annotation>

<xs:documentation> Get access to the xml: attribute groups for xml:lang as declared on 'schema' and 'documentation' below </xs:documentation>

</xs:annotation>

</xs:import>

<xs:complexType name="openAttrs">

...

(15)

Searching and transforming

 XPath

 Navigate XML document with UNIX-like path expressions

 XSLT

 Transform one XML document into another (uses XPath)

 XSLT is written in XML

 Turing-complete : ie you can

theoretically specify any operation

(16)

Can XML be used for databasing?

 No formal design methodology

 No normal forms

 Not compatible with relational

models, or at least not in the general case.

 Inefficient for large files

(17)

XML Databases

 Xindices (formarly dbXML)

 Manages a collection of documents

 Efficient searching

 Built-in XSLT

 Transactional

 But a large collection of documents is not the same as storing a large XML document.

 Can we edit documents in the DB?

(18)

More XML file types

 XHTML

 RSS

 SMIL

 SVG

 MAGE-ML

 SOAP

 see http://www.oasis-open.org

(19)

For the Programmers -SAX

 SAX and DOM are the two

technologies for manipulationg XML.

 SAX is stream-based.

 You basically need to make a state- machine to parse your document

 Read-only

(20)

For the Programmers - DOM

 Navigate a document in memory using various methods.

 Can modify and re-write the document

 May depend on SAX to load files

 May utilise XPATH expressions

(21)

Eg. Perl:

use XML::DOM

my $parser = new XML::DOM::Parser;

my $doc = $parser->parse($xml_as_string) or die "failed to parse XML!\n";

my @beers = $doc->getElementsByTagName('beer', 1);

Loads of other XML modules, including XML::Twig which

combines aspects of SAX and DOM.

(22)

Conclusion

It has to be better than this, from /etc/termcap:

x10term|vs100-x10|xterm terminal emulator (X10 window system):\

:am:bs:km:mi:ms:xn:xo:\

:co#80:it#8:li#65:\

:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:RA=\E[?7l:SA=\E[?7h:\

:al=\E[L:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:\

:cs=\E[%i%d;%dr:dc=\E[P:dl=\E[M:do=^J:ei=\E[4l:ho=\E[H:\

:im=\E[4h:is=\E\E[m\E[?7h\E[?1;4l:k1=\EOP:k2=\EOQ:\

:k3=\EOR:k4=\EOS:kb=^H:kd=\EOB:ke=\E[?1l\E>:kl=\EOD:\

:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:le=^H:md=\E[1m:me=\E[m:\

:mr=\E[7m:nd=\E[C:se=\E[m:sf=^J:so=\E[7m:sr=\EM:ta=^I:\

:ue=\E[m:up=\E[A:us=\E[4m:

...and so on for 17122 lines

References

Related documents

This research work reports the outcome of a primary quantitative investigation into the factors responsible for the quick completion of project research by

3 Version Repository Shared Source Escalation Shared Object Cache Shared Version Cache Reproducible Build Version-Controlled Environment Bill of Materials Legend Context

Aras Innovator IN OUT Request Response Innovator Server Other System &lt;AML/&gt; &lt;XML/&gt; WSDL &lt;XML/&gt; Web Service Integration Code &lt;AML/&gt; Flat File

Series 5700 General Purpose controllers are ideally suited for for use on Wallace &amp; Tiernan® Armored Purge Meters, Armored Flow Meters, Direct View Flow Meters, Glass

The table below provides a comparison of the cost per square foot for Menlo Park Fire District Station 2, located in East Palo Alto, bid and rebuilt starting in 2013, and Station

It also differs from the other two species of Stenocyphus by the following characters: elytral disc with fine, dark, erect setae scat- tered on posterior 2/3, rostrum

The exact estimation of quantization effects requires numerical simulation and is not amenable to exact analytical methods.. But an approach that has proven useful is to treat

Drivers exhibited greater variability in steering under single- task conditions when talking to an outside-vehicle caller, and older drivers showed greater variability in velocity