Computer Science E-259 XML with Java

Lecture 4: XPath 1.0 (and 2.0) and XSLT 1.0 (and 2.0) 15 October 2007 David J. Malan [email protected]

1 Copyright © 2007, David J. Malan . All Rights Reserved.

Computer Science E-259 Last Time ƒ ƒ ƒ

DOM Level 3 JAXP 1.3 and Xerces 2.7.1 My First XML Parser

2 Copyright © 2007, David J. Malan . All Rights Reserved.

Last Time DOM Level 3 Document

Comment Jim Bob graduate Text: \n\t

Text: \n\t\t

Element: name

Text: Jim Bob

Element: students

Element: student

Text: \n\t\t

Attr: id

Element: status

Text: \n

Text: \n\t

Text: graduate

3 Copyright © 2007, David J. Malan . All Rights Reserved.

Last Time JAXP 1.3 and Xerces 2.7.1 javax.xml.parsers.DocumentBuilderFactory javax.xml.parsers.DocumentBuilder org.w3c.dom.* ...

4 Copyright © 2007, David J. Malan . All Rights Reserved.

Last Time My First XML Parser cscie259.project1.mf.*

5 Copyright © 2007, David J. Malan . All Rights Reserved.

Computer Science E-259 This Time ƒ ƒ ƒ ƒ ƒ

CSS Level 2 XPath 1.0 (and 2.0) XSLT 1.0 (and 2.0) TrAX Project 2

6 Copyright © 2007, David J. Malan . All Rights Reserved.

CSS Level 2 By Example

7 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) History ƒ ƒ

XML Path Language (XPath) Version 1.0 is a Recommendation since 11/99 XML Path Language (XPath) Version 2.0 is a Recommendation since 1/07

8 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) Location Paths

/child::movies/child::movie[@rating='R']

step

axis

node test

predicate

location path

9 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) Axes ƒ ƒ ƒ ƒ ƒ ƒ ƒ ƒ ƒ

ancestor, ancestor-or-self attribute child descendant, descendant-or-self following, following-sibling namespace parent preceding, preceding-sibling self

10 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) following-sibling

1

2

11 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) descendant

1

3

2

4

5

6

12 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) ancestor 2

1

13 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) ...

14 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) Node Tests ƒ ƒ ƒ ƒ ƒ ƒ ƒ ƒ

foo foo:bar foo:* * node() comment() text() processing-instruction()

15 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) Abbreviated Synatx ƒ ƒ ƒ ƒ ƒ

child:: attribute:: /descendant-or-self::node()/ self::node() parent::node()

≡ ≡ ≡ ≡ ≡

'' @ // . ..

16 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) Data Types ƒ ƒ ƒ ƒ ƒ

boolean number string node-set external object

17 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) boolean ƒ ƒ ƒ ƒ

true(), false() =, !=, <, >, <=, >= and, or not()

18 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) number ƒ ƒ ƒ ƒ

=, !=, <, >, <=, >= +, -, *, div, mod, floor(), ceiling() ...

19 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) string ƒ ƒ

ƒ

"foo", 'foo' concat(), contains(), starts-with(), string-length(), substring(), substring-after(), substring-before(), translate() ...

20 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) node set ƒ ƒ ƒ

count(), current(), last(), name(), position(), sum() | ...

21 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) Converting Types ƒ

Explicit Conversion ƒ boolean(), string(), number()

ƒ

Implicit Conversion ƒ false » 0, true » 1 ƒ false » 'false', true » 'true' ƒ 0 » false, other » true ƒ '' » false, other » true ƒ empty » false, other » true ƒ ...

22 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Motivation ƒ ƒ ƒ

XML provides a syntax for structured data formats No one format is likely to enable all possible uses for data Transforming XML can be useful in two different scenarios ƒ Data conversion: transforming one format to another ƒ Multiple data formats for B2B purchase orders ƒ Different description formats for family trees ƒ Publishing: transforming data to a human viewable form ƒ Displaying XML data on the Web as HTML ƒ Displaying XML data in print using PDF

23 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) History ƒ ƒ

XSL Transformations (XSLT) Version 1.0 is a Recommendation since 11/99 (first draft dates back to 8/98) XSL Transformations (XSLT) Version 2.0 is a Recommendation since 1/07

24 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) XHTML 1.0 My First XSLT-Generated Webpage

25 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Nodes ƒ ƒ ƒ ƒ ƒ ƒ ƒ

root node element nodes attribute nodes text nodes comment nodes PI nodes ...

26 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Elements ƒ ƒ ƒ ƒ ƒ

xsl:stylesheet xsl:apply-templates, xsl:call-template, xsl:template, xsl:with-param xsl:for-each xsl:value-of ...

27 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Matching Templates ... ...

28 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Named Templates ... ...

29 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Applying Templates

30 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Built-In Templates

31 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Values of Nodes

32 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Recursive Descent Processing ƒ ƒ ƒ

ƒ

Start from the root node Find a matching template Instantiate the body of the template ƒ Send literal result elements (i.e., non-XSLT elements) to standard output ƒ Interpret XSLT elements as instructions In other words, selects nodes to which the processor recursively applies the same algorithm: match templates and instantiate their bodies

33 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Processors ƒ

Xalan-J 2.7.0 ƒ

ƒ ƒ ƒ ƒ ƒ

java org.apache.xalan.xslt.Process -IN foo.xml -XSL foo.xsl

Microsoft Core XML Services (MSXML) 6.0 SAXON 8.9 Stylus Studio 2007 XML Enterprise Suite XMLSpy 2008 Enterprise Edition ...

34 Copyright © 2007, David J. Malan . All Rights Reserved.

XSLT 1.0 (and 2.0) Versus CSS Level 2 Why two stylesheet languages?

35 Copyright © 2007, David J. Malan . All Rights Reserved.

TrAX APIs javax.xml.transform.* javax.xml.transform.stream.* javax.xml.transform.dom.* javax.xml.transform.sax.*

36 Copyright © 2007, David J. Malan . All Rights Reserved.

Project 2 Overview ƒ ƒ ƒ

It's B2B Time! My Blockbuster XTube

37 Copyright © 2007, David J. Malan . All Rights Reserved.

Next Time XPath 1.0 (and 2.0) and XSLT 1.0 (and 2.0), Continued ƒ ƒ

XPath 1.0 (and 2.0), Continued XSLT 1.0 (and 2.0), Continued

38 Copyright © 2007, David J. Malan . All Rights Reserved.

Computer Science E-259 XML with Java

Lecture 4: XPath 1.0 (and 2.0) and XSLT 1.0 (and 2.0) 15 October 2007 David J. Malan [email protected]

39 Copyright © 2007, David J. Malan . All Rights Reserved.

XPath 1.0 (and 2.0) - Fas Harvard

Computer Science E-259. This Time. ▫ CSS Level 2. ▫ XPath 1.0 (and 2.0). ▫ XSLT 1.0 (and 2.0). ▫ TrAX. ▫ Project 2 .... Displaying XML data on the Web as HTML.

83KB Sizes 1 Downloads 181 Views

Recommend Documents

anchor.svg 1/1 - Fas Harvard
anchor.svg. 1/1 examples6/svg/. 1: 2:

foo.xml 1/1 - Fas Harvard
15: * characters are displayed as "\n", "\t", and "\r". 16: * explicitly, and line numbers are reported in errors. 17: *. 18: * @author Computer Science E-259. 19: **/.

books.xml 1/1 - Fas Harvard
2: . 3: DOCTYPE emails SYSTEM "emails.dtd">. 4: . 5:

README.txt 1/2 - Fas Harvard
3: Computer Science E-259. 4: 5: 6: OVERVIEW. 7: 8: In these directories are ... 13: * @author Computer Science E-259. 14: **/. 15: 16: public class TaxClient.

DiagServer.java 1/2 - Fas Harvard
DiagServer.java. 2/2 examples7/. 46: byteCount++;. 47: System.out.write(b); ... 2:

XML Schema (Second Edition) - Fas Harvard
After the release of XML 1.0, DTDs were soon recognized as insufficient. ▫ Work towards new schema standards began in early 1998. ▫ Different companies all ...

AttributeConverter1.xsl 1/2 - Fas Harvard
2/2 examples5/. 46: . 47: .... 2/2 examples5/. 44: 45: . 46: 47: . 48:  ...

Computer Science E-259 - Fas Harvard
“SVG is a language for describing two-dimensional graphics in XML. SVG allows ... Adapted from http://www.adobe.com/svg/basics/getstarted2.html. Viewable at ...

Computer Science E-259 - Fas Harvard
Computer Science E-259. XML with Java, Java ... Computer. Laptop. PDA. Web Server. JSP/servlet. JSP/servlet. EJB Server. EJB. EJB. DB. XML? ... Page 10 ...

Computer Science E-259 - Fas Harvard
Apr 13, 2005 - 1. Copyright © 2007, David J. Malan . All Rights Reserved. Computer Science E-259. XML with Java. Lecture 11:.

XML Schema (Second Edition) - Fas Harvard
Establish a contract with trading partners. ▫ Documentation. ▫ Augmentation of instance with default values. ▫ Storage of application information ...

Computer Science E-259 - Fas Harvard
Cut through the hype and get to the value. ▫ Focus on. ▫ practicality: what you need to know to do real work. ▫ applications: what are the tools and technologies.

Computer Science E-259 - Fas Harvard
Computer Science E-259. XML with Java. Lecture 5: XPath 1.0 (and 2.0) and XSLT ... All Rights Reserved. Computer Science E-259. Last Time. ▫ CSS Level 2.

Computer Science E-259 - Fas Harvard
Page 2 .... . . .... unidirectional hyperlinks of today's HTML, as well as.

Computer Science E-259 - Fas Harvard
All Rights Reserved. Computer Science E-259. XML with Java. Lecture 2: XML 1.1 and SAX 2.0.2. 24 September 2007. David J. Malan [email protected] ...

0400-20-10
Sep 12, 2017 - ... sources used in educational demonstrations (such as cloud ...... Os–185. 7 x 10–4. Os–191m. 3 x 10–2. Os–191. 2 x 10–3. Os–193. 6 x 10–4.

0400-20-10
Sep 12, 2017 - address in Rule 0400-20-04-.07 a plan for ensuring that the premises and environs ...... Principal: (legal name and business address of applicant or licensee). Type of ...... The generator or reagent kit is to be manufactured, labeled

0400-20-10
12 Sep 2017 - license under 10 CFR 32.22 and for a certificate of registration in accordance with 10 ..... (VI) Certification by the responsible representative of the general ...... CHAPTER 0400-20-10. Rule 0400-20-10-.38 Appendix—Schedules (contin

10-20-09NRGCampusAdvisoryMeetingAgenda.pdf
Sign in. Loading… Whoops! There was a problem loading more pages. Retrying... Whoops! There was a problem previewing this document. Retrying.

10-20-09NRGCampusAdvisoryCommitteeMinutes.pdf
Overview of the Campus Master Plan for Facilities & Construction and introduction of Pamela Collier,. Project Manager, Facilities & Operations. Also discussed ...

10-20-09NRGCampusAdvisoryCommitteeMinutes.pdf
Mary Hensley. Andy Kim. Tim Mahoney. Soon Merz. Bill Mullane. Louella Tate. Minutes. Agenda item: Welcome & Agenda Review Presenter: Belvolyn Smith. NRG Campus Manager. Discussion: Introduction of panel and overview of the evening's agenda. Decision/

Simpson - XPath and XPointer (O'Reilly, 2002).pdf
Simpson - XPath and XPointer (O'Reilly, 2002).pdf. Simpson - XPath and XPointer (O'Reilly, 2002).pdf. Open. Extract. Open with. Sign In. Main menu.

Horario FAS Docente.pdf
TALLER DE LENGUA. Y COMUNICACIÓN I. Código 0103011. Agustín Prado. SEMINARIO DE. PENSAMIENTO LÓGICO. MATEMÁTICO. Código 0207010.