Displaying the XML document - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Displaying the XML document

Description:

Summary of last week. Coding the stylesheet - .xsl including examples ... Look for books by publishers Wrox Press and O'Reilly. DECA. J.C.Westlake_at_staffs.ac.uk ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 18
Provided by: jonathan76
Category:

less

Transcript and Presenter's Notes

Title: Displaying the XML document


1
Displaying the XML document
  • Summary of last week
  • Coding the stylesheet - .xsl including examples
    of code
  • XSL Design issues
  • E-Commerce issues
  • Summary

2
Summary of last week
  • Via XML Spy we used the Microsoft XML parser
    which includes an XSLT processor.
  • This is the MSXML 4.0 parser (which is
    pre-installed within IE6.0) but we could have
    used any external XSLT processor for this
    purpose.
  • We assigned a XML stylesheet (a .xsl file) to an
    XML document (a .xml file).
  • lt?xml-stylesheet type"text/xsl"
    href"PODstyle.xsl"?gt

MIME type
3
Summary of last week
  • The XSLT processor analyses the XML document into
    a hierarchical tree structure (starting with the
    root) made up of what are called nodes this
    is called a node tree.
  • This node tree is for internal use.

4
Part Picture of a node tree
  • Proofofdelivery

root node
element nodes
Deliverydetails
rad100
productid
text node
5
Summary of last week
  • Nodes can be
  • elements e.g. poddetail
  • attributes e.g. price
  • text e.g. 50.00
  • The XSLT processor will then use the stylesheet
    assigned to the XML document, transforming the
    element that it finds into HTML via your XSL
    templates.
  • The XSL stylesheet contains instructions on how
    to use (navigate and display) the nodes.

6
XSL coding
  • What follows is a selection of useful things
    which we think you can use for the assignment.
  • Exploring everything about XSL/XSLT coding is
    beyond the scope of this module too large!
  • For those interested there are a few professional
    books on this subject area in the library.
  • Look for books by publishers Wrox Press and
    OReilly.

7
XSL code
  • Last week we used the
  • xsltemplate match/
  • e.g.
  • lt?xml version"1.0" encoding"UTF-8"?gt
  • ltxslstylesheet version"1.0" xmlnsxsl"http//ww
    w.. "gt
  • ltxsltemplate match"/" /gt
  • What does this do?

8
XSL code
  • ltxslstylesheet version"1.0 xmlnsxsl"http//ww
    w.w3.."gt
  • This is assigned to create a default namespace
    elements declared in the .xsl stylesheet
    beginning with the prefix xsl will be recognised
    as belonging to this namespace.
  • To recap on namespaces see the www.w3schools site.

9
XSL code
  • We need namespaces in the cases where we want to
    build an XML document using element names from
    multiple schemas that might clash with each other
  • e.g. a book tag from Amazon might have a
    different structure to one from Waterstones but
    our order XML document offers us the choice of
    supplier so how does the XML document validate
    itself?

10
XSL code
  • ltxslvalue-of selectelement/gt
  • Example of use
  • lttd width"200 bgcolor"aaaaff"gt
  • ltbgtCustomer IDlt/bgt
  • ltxslvalue-of select"ProofOfDelivery/Customer/Cu
    stomerID"/gt
  • lt/tdgt
  • What does this do?

Tree location
11
XSL coding useful tips
  • static or constant information.
  • Remember that the stylesheet can incorporate
    simple text formatting
  • e.g. in our example from last week the POD header
    information for the address of Westlake Radiators
    and an associated image.
  • This is good when appropriate which is
  • do we need to send this data in the .xml file
  • or do we just need to display it?

12
XSL code useful tips
  • Dealing with iteration how are you going to
    display the lines of the POD?
  • Firstly revisit the Schema solution for the
    delivery details.
  • The schema should show that the delivery lines
    are unbounded i.e. we can have more than one line
    per POD.
  • We need to reflect this in the stylesheet how?
    See next slide

13
For-each
  • for-each and value-of tags help us process data
    effectively.
  • ltxslfor-each select"ProofOfDelivery/DeliveryDet
    ails"gt
  • ltdiv align"center"gtltxslvalue-of
    select"LineNo"/gt
  • lt/divgt
  • ltxslfor-each /gt

14
XSL code useful tips
  • Creating HTML tables.
  • Use of the HTML tags for tables.
  • lttablegt can have a border and spacing info
    specified
  • lttrgt rows can have custom styling (also see ltthgt
    tag)
  • lttdgt data cells contain displayable information
  • lt/tdgt
  • lt/trgt
  • lt/tablegt
  • Use hex values for colour (named colours work but
    are not part of the web standards.)

15
XSL code useful tips
  • Using HTML attributes
  • Incorporating gif or jpeg files
  • ltdiv align"center"gt ltimg src"title.jpg"
    width"300" height"200" /gtlt/divgt
  • Image width and height attributes are in pixels
    (naturally) and notice that the img tag has a /
    at the end of it to comply with the
    well-formedness requirements of XML.

16
E-Commerce issues
  • The how of what to display can be understood but
  • The what to display is more difficult.
  • Who decides what to display?
  • Do we replicate the existing documents or use the
    opportunity for change the XSLT Designer tool
    might be of some use in this respect in the
    design of forms.
  • There is obviously a business process
    reengineering issue (BPR) with the above the
    paperless dream!
  • Interesting XML standard for BPR see www.bpmi.org

17
Summary
  • XSL/XSLT is a programming environment which can
    be used for web publishing and as we will see in
    later weeks manipulation and querying.
  • Business to Business Commerce is all about
    business forms E-Commerce of course is the
    electronic version (or should be)
  • It follows that careful design of the viewable
    form is important.
Write a Comment
User Comments (0)
About PowerShow.com