Presentation is loading. Please wait.

Presentation is loading. Please wait.

ACG 4401 XSLT Extensible Stylesheet Language for Transformations

Similar presentations


Presentation on theme: "ACG 4401 XSLT Extensible Stylesheet Language for Transformations"— Presentation transcript:

1 ACG 4401 XSLT Extensible Stylesheet Language for Transformations
Presenting XML and XBRL

2 XSLT Extensible Stylesheet Language Transformations
Hey it’s based on XML Stylesheet What the data will look like Language Scripting Transformations to change the structure and markup of an XML document so that it can serve another purpose Reuse, Repurpose, calculate, sort, etc.

3 XSLT Parts XSL XSLFO Transform Instance Document to different Form
HTML, XHTML, XML (new), PDF XSLFO For formatting data

4 Re-Purpose The main benefit of XML / XBRL
Reusability of Data contained in Instance Document We need a method of presenting the data Presentation Linkbase XSLT

5

6 A UBL Catalogue Node Tree
Name PartyName Party + Provider Party + Receiver Party + Catalogue Line ID Name IssueDate Leaf Nodes Branch Nodes Catalogue

7 Transformation Requires xml code in Two Documents
Instance Document 2nd Prolog line linking instance document to XSLT document XSLT Document Contains script for selecting elements to be displayed

8 XSLT Must have 2nd prolog linking to .xsl XML Instance document XML
Processor XML Result document XSLT Instructions 2 Inputs: Instance (source) & XSLT (transformation script) Processing Browser Output: result document

9 Transforming your Instance Document
Contain elements and data but.. Does NOT contain formatting information Add an additional prolog statement Connects your .xml to your .xsl document <?xml-stylesheet type=“text/xsl” href=“name.xsl”?> xml-stylesheet Tells the processor to use the stylesheet file to transform the data in the .xml document href= Points to location of .xsl document.

10 XSLT (the XML code) Root Element namespace declaration
<xsl:stylesheet xmlns:xsl=“ version="1.0"> All other namespaces used in the instance document (MUST MATCH) Default namespaces (e.g. without the prefix) are not allowed in XSLT v 1.0 Need to make up a prefix Don’t forget this!

11 XSLT Scripting Code Sum Formatting Mathematical Operations
Elements used: templates for-each value-of Functions Formatting Format-number Sum Mathematical Operations +, -, *, div

12 Templates Element that follows root element
What elements from .xml are being used? Templates provide answer Processing Elements from Instance against Template created in XSLT <xsl:template match=“/”> / = Look in entire source document

13 How to transform data <HTML> container
Tells processor transformation will use html tags. Remaining code between <HTML> and </HTML> code is the data to be transformed and the formatting code for the transformation

14 Lets look at Node Paths <?xml version="1.0"?> <Inventory>
<InventoryItem> <Name>Basketball</Name> <IdNumber>12345</IdNumber> <Cost units="USD">12.50</Cost> <RetailPrice units="USD">25.00</RetailPrice> </InventoryItem> </Inventory>

15 value-of select Selects and transforms/formats
Displays the value of the selected element At the end of the node Based on select attribute You must point to the “node” you want displayed “Full node path” “Inventory/InventoryItem/IdNumber” = 12345 “//elementname” Used when one and only one element has the name Start at root and look for element name. “//IdNumber” = 12345 <xsl:value-of select=“NodeName”/> Value-of select can use a function.....

16 Functions Numeric ceiling() floor() number() round() sum() String
concat() contains() normalize-space() starts-with() string() string-length() substring() substring-after() substring-before() translate()

17 format-number() function
format-number function has two arguments Number (node path to the number) Pattern (see formatting patterns) <xsl:value-of select =“format-number(Inventory/InventoryItem/Cost,’$#.00’)”/> Number pattern

18 Formatting Numbers 0 A digit. # A digit, zero shows as absent.
$ prefix . (period) Placeholder for decimal separator. , Placeholder for grouping separator. ; Separate formats. - Default prefix for negative. % Multiply by 100 and show as a percentage. X Any other characters can be used in the prefix or suffix. ‘ Used to quote special characters in a prefix or suffix.

19 for-each loop Selects All elements contained in a node-set Node-set is declared with select attribute Additional .xsl code provide instructions for what to do with selected data What transformations to make HTML, and XSL tags combined. <xsl:for-each select=“Inventory/InventoryItem>

20 Accessing Remote Instance Docs
document() function <xsl:value-of select=“document(‘URI.xml’)/xpath”/>

21 Output (HTML) <HTML> <Center> All tags must be closed!
Transformation will be to an HTML doc. <Center> All tags must be closed!

22 Defining Tables in HTML
<Table Border=“n”> Tells browser to begin making a table <TR> (table row) Tells browser to insert a new row <TH> (table header) Tells browser to insert a new column in the new row AND use text as heading (bold) <TD> (table data) Tells browser to insert a new column in the new row Close all tags </TD>, </TR>, </Table>

23 Table with 2 rows and 3 columns
<TABLE BORDER=“1”> <TR> <TD>r1c1</TD> <TD>r1c2</TD> <TD>r1c3</TD></TR> <TD>r2c1</TD> <TD>r2c2</TD> <TD>r2c3</TD></TR>


Download ppt "ACG 4401 XSLT Extensible Stylesheet Language for Transformations"

Similar presentations


Ads by Google