XMLXSL and Information - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

XMLXSL and Information

Description:

no side effects (variables can't be changed, order of application of templates ... I avoid decorations. Charts are my notes (which I share with you). Homework ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 38
Provided by: jeanine2
Category:

less

Transcript and Presenter's Notes

Title: XMLXSL and Information


1
XML/XSL and Information
  • continue with XML/XSL
  • Ideas from Edward Tufte on data density data
    junk
  • Homework find report on data presentation,
    Tufte, statistics, graphs

2
Comments on XSLT
  • declarative as opposed to procedural language
  • no side effects (variables can't be changed,
    order of application of templates is somewhat
    flexible)
  • one main use is matching parts of XML tree using
    patterns and 'declaring' results
  • push processing pushes out results based on
    applying templates
  • pull processing pulls in relevant information
    and produces results

3
Comments, cont.
  • XML still under development (definition of next
    standard)
  • New version will have what are now done with
    so-called extensions.
  • Other options are server-side or client side
    programming
  • XML Schema possible replacement for DTDs
  • XML-Formatting Objects focus more on formatting

4
XSLT examples
  • use of variables defined by more intricate
    Xpath expressions
  • use of recursive calls to named templates
  • template calling itself with new parameters
  • Other mechanisms (for you to look up as needed)
  • mode for template facility to examine (transform
    the same nodes under different conditionsmodes)
  • key function facility to categorize nodes
    according to some calculated expression.

5
World cup data
  • Previous example transformed each match,
    dependent on whether or not match marked as
    'feature' in attribute.
  • What about producing a table of the results?

6
(No Transcript)
7
What do we want to do
  • Transform logic
  • produce HTML table, one row for each team
  • calculate for team certain values that use all
    the matches that that team is 'in'.
  • Implementation
  • use XSLT variables

8
XSLT mechanics
  • ltxslvariable name"teams" select"//teamnot(.pr
    ecedingteam)"/gt
  • The value of variables is set by the Select
    pattern. THEY CANNOT BE CHANGED.
  • The //team means find all the team nodes
    anywhere.
  • The . means the node you are considering now.
  • The square brackets define a condition for which
    teams are to be selected. This variable is a
    node set.
  • the preceding is an example of what is called
    an axis. It is a qualifier.
  • This says make up a node set consisting of
    teams, but don't include any that have occurred
    previously.

9
  • lt?xml version"1.0" encoding"UTF-8" ?gt
  • ltxsltransform
  • xmlnsxsl"http//www.w3.org/1999/XSL/Transform"
    version"1.0"gt
  • ltxsloutput method"html"/gt
  • ltxslvariable name"teams" select"//teamnot(.pr
    ecedingteam)"/gt
  • ltxslvariable name"matches" select"//match"/gt
  • ltxsltemplate match"/results"gt
  • lthtmlgt
  • ltheadgtlttitlegtResults of World Cup
  • lt/titlegt
  • ltLINK REL"stylesheet" TYPE"text/css"
    HREF"results.css"/gt
  • lt/headgt
  • ltbodygt
  • lth2gt Results of World Cup lt/h2gt

10
  • lttable cellpadding"5"gt
  • lttrgt
  • ltthgt Team lt/thgt
  • ltthgt Played lt/thgt
  • ltthgt Won lt/thgt
  • ltthgt Lost lt/thgt
  • ltthgt Tied lt/thgt
  • ltthgt For lt/thgt
  • ltthgt Against lt/thgt
  • ltthgt Points lt/thgt
  • lt/trgt

11
indicates variable
  • ltxslfor-each select "teams"gt
  • ltxslvariable name"this" select"."/gt
  • ltxslvariable name"played" select"count(match
    esteamthis)"/gt
  • ltxslvariable name"won" select"count(matches
    team.this/_at_score gt team.!this/_at_score)
    "/gt
  • ltxslvariable name"lost" select"count(matches
    team.this/_at_score lt team.!this/_at_score)
    "/gt
  • ltxslvariable name"tied" select"count(matches
    team.this/_at_score team.!this/_at_score)"/gt
  • ltxslvariable name"for" select"sum(matches/te
    am.current()/_at_score)"/gt
  • ltxslvariable name"against" select"sum(matche
    steamcurrent()/team/_at_score)-for"/gt
  • ltxslvariable name"points" select"3wontied
    "/gt

12
  • lttrgt
  • lttdgtltxslvalue-of select"."/gtlt/tdgt
  • lttdgtltxslvalue-of select"played"/gtlt/tdgt
  • lttdgtltxslvalue-of select"won"/gtlt/tdgt
  • lttdgtltxslvalue-of select"lost"/gtlt/tdgt
  • lttdgtltxslvalue-of select"tied"/gtlt/tdgt
  • lttdgtltxslvalue-of select"for"/gtlt/tdgt
  • lttdgtltxslvalue-of select"against"/gtlt/tdgt
  • lttdgtltxslvalue-of select"points"/gt lt/tdgt
  • lt/trgt
  • lt/xslfor-eachgt
  • lt/tablegt
  • lt/bodygt lt/htmlgt
  • lt/xsltemplategt
  • lt/xsltransformgt

13
New example
  • http//99-bottles-of-beer.ls-la.net/
  • A web site with programs in over 300 different
    programming languages to display all verses to
  • This is my version in xml/xslt
  • They have another version that is xslt
    stand-alone. Check it out.

14
Example
  • lt?xml version"1.0" ?gt
  • lt?xml-stylesheet href"lyrics.xsl"
    type"text/xsl"?gt
  • lt!DOCTYPE lyrics
  • lt!ELEMENT lyrics (line1, line2, line3)gt
  • lt!ATTLIST lyrics start CDATA REQUIREDgt
  • lt!ELEMENT line1 (PCDATA)gt
  • lt!ELEMENT line2 (PCDATA)gt
  • lt!ELEMENT line3 (PCDATA)gt
  • gt
  • ltlyrics start"3"gt
  • ltline1gt bottles of beer on the walllt/line1gt
  • ltline2gt bottles of beerlt/line2gt
  • ltline3gt take one down and pass it
    aroundlt/line3gt
  • lt/lyricsgt

could be 99
15
Document Type Definition
  • defines what is a valid XML document
  • Validation can be done with external validator
  • http//www.stg.brown.edu/service/xmlvalid/xmlvalid
    .var
  • Alternative to DTD is XML Schema
  • XML Schemas are XML trees.
  • less advanced with respect to being official
    standard

16
Demonstration
  • Go to
  • http//www.stg.brown.edu/service/xmlvalid/xmlvalid
    .var
  • (Since it is short), copy and paste lyrics.xml
    into text area
  • Click on validate
  • returns ok
  • Now, change xml to NOT match DTD
  • remove start attribute
  • add element
  • Click on validate
  • indicates problems

17
What do we want to do?
  • Transformation
  • produce well-formed HTML
  • start with the 'start' attribute and, using it as
    a string, output it as start of first line.
  • output as HTML the line.
  • using start as number, subtract one to get new
    value. Using this value as a string, output with
    line1.
  • repeat process
  • Implementation
  • The 'repeat' will be done as a recursive call,
    that is, a template will call itself.
  • The template will be a named template, with
    parameter the value, starting with the value of
    the start attribute.

18
Outline of the xsl file
  • header/instructional stuff
  • template that matches the main node (lyrics)
  • the so-called named template to be called by the
    main template AND also called by itself

19
Technical note
  • ltxslcopygt and ltxslcopy-ofgt copies information
    from the source document to the result.
  • ltxslcopygt copies only the node whereas
    ltxslcopy-ofgt copies the node and any descendants
    (called a deep copy)
  • In this example, either could be used.

20
  • lt?xml version"1.0" encoding"UTF-8" ?gt
  • ltxsltransform xmlnsxsl"http//www.w3.org/1999/
    XSL/Transform" version"1.0"gt
  • ltxsloutput method"html"/gt
  • ltxsltemplate match"/lyrics"gt
  • lthtmlgtltheadgtlttitlegtSinging lt/titlegtlt/headgt
  • ltbodygt
  • ltxslcall-template name"singverse"gt
  • ltxslwith-param name"counter"gt
  • ltxslvalue-of select"_at_start"/gt
  • lt/xslwith-paramgt
  • lt/xslcall-templategt
  • lt/bodygt lt/htmlgt
  • lt/xsltemplategt

templates can have parameters. Here one parameter
is set with value of start attribute.
21
  • ltxsltemplate name"singverse"gt
  • ltxslparam name"counter" /gt ltbr/gt
  • ltxslcopy-of select"counter"/gt ltxslvalue-of
    select"line1" /gt
  • ltbr/gt
  • ltxslcopy-of select"counter"/gtltxslvalue-of
    select"line2" /gt
  • ltbr/gt
  • ltxslvalue-of select"line3" /gt ltbr/gt
  • ltxslvariable name"next" select"counter - 1"
    /gt
  • ltxslcopy-of select"next"/gt ltxslvalue-of
    select"line1" /gt
  • ltbr/gt ltbr/gt
  • ltxslif test"next gt1" gt
  • ltxslcall-template name"singverse"gt
  • ltxslwith-param name"counter" select"next"
    /gt
  • lt/xslcall-templategt
  • lt/xslifgt lt/xsltemplategt lt/xsltransformgt

22
User centered design
  • Build the interface/application for the person
    using it! This is generally not you.
  • (Sometimes), it is important to distinguish
    between the system owner and system users.
  • If possible, use a more descriptive name client,
    customer, patient, player, museum visitor,
    tourist, for users.
  • Determine for the user(s), what is best
  • organization
  • vocabulary
  • Determine for the user(s), what are the
    important/all
  • platform, access, etc.

23
Challenges
  • More than one 'user' category
  • first time (novice) versus repeat (expert)
  • System owners (the paying client) may want system
    to serve different audiences
  • intranet, employees at client locations,
    employees at hotels and on planes, perhaps using
    cell phones.
  • Web sites visitors may enter site in different
    ways.
  • Search engines may make it important for what you
    think of as inner pages to be stand-alone.

24
Data presentation
  • Edward Tufte (and others) promote presentation of
    data that features the data as opposed to (what
    he calls) chartjunk.
  • You need datacontent.
  • Compare amount of space devoted to data versus
    everything else, including
  • descriptions, annotation, labels
  • illustration without content
  • Also, make sure space for navigation is not
    overdone.

25
Tufte Challenges of display
  • 'life' is multi-dimensional, multi-variety but
    paper and screens are two-dimensional.
  • How do you escape flatland?
  • Your content may require more resolution than you
    have, especially if limited by computer screens
  • How do you manage data density?
  • Solution thoughtful, inventive, creative design!
  • Design is clear thinking made visible.

26
Tufte advice
  • What's the problem? Who cares? (why care)? What
    is solution?
  • Particular general particular
  • Teaching by examplestudy books
  • Minard march
  • Connecticut radar
  • Challenger disaster
  • (Columbia disaster)

27
(No Transcript)
28
Connecticut auto deaths
  • Traffic deaths following (intervention) of radar
  • no context
  • Is it normal fluctuation, with 'normal'
    regression to the mean after an extreme (outlier)
    year or the effects of policy?
  • Need to look at context (in space and time)

29
Challenge Disaster
  • Failure of---technical presentation
  • The Morton Thiokol engineers did not want to
    approve the launch because they thought that the
    O-rings would not work in cold weather.
  • They made a presentation, which did not succeed.
  • The launch went. Their prediction was correct!

30
(No Transcript)
31
Tufte's proposal
32
Principles
  • Show visual comparisons. Try to make comparisons
    in space and not 'stacked in time'
  • Show causality.
  • Show multi-variables/dimensions.
  • Integrate word, number and image.
  • Document where did data come from? Annotate.
  • Everything depends on quality, relevance and
    integrity of content.

33
Screen
  • Term screen real estate used to indicate the
    value of each part of the screen.
  • You (system owners) may need to share screen with
    other organizations, for example, ad space.
  • White space, that is, space with nothing on it,
    is valuable for clarity.

34
Data dimension
  • The data that is worth presenting in graphics
    form (as opposed to clear text) is generally
    complex multi-dimensional. more on this next
    class.
  • Tufte (and others) don't give data dimensions it
    doesn't have.
  • recall 3D bar graph
  • recall army marching in and out of Russia.
  • New York Times interactives on 9/11 focused on
    time, location in the towers, Fire Companies from
    different places in NYC. Audio was often real
    police calls, calls on cell phones.

35
As with 3D bar charts when you only have points,
avoid rainbow, when the data is
one-dimensional(Note shades of blue chart
better for color-blind visitors.)
36
My defense
  • Tufte recommends no PowerPoint (no charts with
    bullets)
  • I try for whole sentences.
  • I avoid decorations.
  • Charts are my notes (which I share with you).

37
Homework
  • Find and report via CourseInfo on one of these or
    related topics Tufte, visual presentation,
    good/bad use of graphs, user-centered design.
  • Continue taking on-line XML/XSLT tutorials.
  • Do your own versions of XML/XSLT exercises
  • (Try writing (simple) DTD and doing validation.)
Write a Comment
User Comments (0)
About PowerShow.com