23
ACG 6415 XSLT Presenting XML and XBRL

ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

Embed Size (px)

Citation preview

Page 1: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

ACG 6415

XSLT

Presenting XML and XBRL

Page 2: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

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

Page 3: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

XSLT

Extensible Hey it’s based on XML

Stylesheet What the data will look like

Language Scripting

Transformations Reuse, Repurpose, calculate, sort, etc.

Page 4: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

XSLT Parts

XSL Transform Instance Document to different

Form HTML, XHTML, XML (new), PDF

XSLFO For formatting data

Page 5: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

Transformation Requires xml code in Two Documents

Instance Document 2nd Prolog line linking to xslt document

XSLT Document Contains script for selecting elements to be

displayed

Page 6: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

XSLTXSLT

• eXtensible Stylesheet Language – eXtensible Stylesheet Language – TransformationTransformation– Native XML language for processing Native XML language for processing

XML documents into other formsXML documents into other forms

XML Processor

XMLInstance

document

XSLTInstructions

XMLResult

document

Page 7: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

Transforming your Instance Document

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 format the data in the .xml document

href= Points to location of .xsl document.

Page 8: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

XSLT (the XML code)

Root Element namespace declaration <xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform

version="1.0"> All other namespaces used in the instance document (THEY MUST

MATCH) Default namespaces (e.g. without the prefix) are not allowed in XSLT v 1.0

Need to make up a prefix

Page 9: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

XSLT Scripting Code

Elements used: templates for-each value-of Formulas

Sum +, -, *, div

Formatting Format-number

Page 10: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

Templates

Line 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

Page 11: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method
Page 12: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

A UBL Catalogue Node Tree

Catalogue

ID NameIssueDate

+Provider

Party

+Receiver

Party

+Catalogue

Line

Leaf NodesBranch Nodes

Party PartyName Name

Page 13: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

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

Page 14: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

<?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>

Page 15: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

value-of 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” “//elementname”

Used when one and only one element has the name Start at root and look for element name.

<xsl:value-of select=“Name”/> Value-of select can use a function.....

Page 16: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

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>

Page 17: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

Functions

Numeric ceiling() floor() number() round() sum()

String concat() contains() normalize-space() starts-with() string() string-length() substring() substring-after() substring-before() translate()

Page 18: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

format() function

format-number attribute has two arguments Number Pattern (see formatting patterns)

<xsl:value-of select =“format-number(sum(Inventory/InventoryItem/Cost),’$#.00’)”/>

Number pattern

Page 19: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

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.

Page 20: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

Accessing Remote Instance Docs

document() function

<xsl:value-of select=“document(‘URI.xml’)”/>

Page 21: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

Output (HTML)

<HTML> Transformation will be to an HTML doc.

<Center> <TABLE BORDER = ‘1’>

Defines the border width for the table <TH>

Table Heading <TR>

Starts a new row in the table <TD>

Starts a new cell in the row colspan=“#”

How many columns should this cell span align=“right, left or center”

All tags must be closed!

Page 22: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

Defining Tables in HTML

<Table Border=“n”> Tells browser to begin making a table

<TH> Tells browser to use text as heading (1st row)

<TR> Tells browser to insert a new row

<TD> Tells browser to insert a new column in the

new row Close all tags

</TD>, </TR>, </Table>

Page 23: ACG 6415 XSLT Presenting XML and XBRL. Re-Purpose  The main benefit of XML / XBRL Reusability of Data contained in Instance Document We need a method

Table with 2 rows and 3 columns

<TABLE BORDER=“1”>

<TR>

<TD>r1c1</TD>

<TD>r1c2</TD>

<TD>r1c3</TD></TR>

<TR>

<TD>r2c1</TD>

<TD>r2c2</TD>

<TD>r2c3</TD></TR>