Prologue to XSLT

0
0
1881 days ago, 756 views
PowerPoint PPT Presentation

Presentation Transcript

Slide 1

Prologue to XSLT

Slide 2

Processing the XML information Huge measure of XML data, and developing We have to " oversee " it, and after that " procedure " it Store it effectively Verify the rightness Filter, look, select, join, total Create new bits of data Clean, standardize the information Update it Take activities in light of the current information Write complex execution streams No reasonable association like for social databases (applications are excessively heterogeneous)

Slide 3

Frequent answers for XML information administration Map it to bland programming APIs (e.g. DOM, SAX, StaX) Manually delineate to non-bland APIs Automatically outline to non-non specific structures Use XML expansions of existing dialects Shredding for social stores Native XML handling through XSLT and XQuery

Slide 4

History of XSLT Much more established then XQuery XSLT 1.0 and XSLT 2.0 Was planned a re-arranging dialect for the programs Still fundamentally utilized as a part of thusly (e.g Ebay has more 10.000 XSLT templates) Most programs have an inserted XSLT processor Now has more extensive applications for XML administration XSLT 2.0 and XQuery 1.0 are composed mutually Same information display, same sort framework, same Xpath 2.0 Different programming worldview XQuery is compositional and practical, XSLT depends on recursive layouts

Slide 5

XQuery, Xpath, XSLT XQuery 1.0 XSLT 2.0 augments utilizes FLWOR expressions Node constructors Validation Xpath 2.0 2007 expands, in reverse perfect Xpath 1.0 utilizations 1999 XSLT 1.0

Slide 6

Your first XSLT template < xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/strict"> < xsl:template match="/"> <html> <head> <title>Expense Report Summary</title> </head> <body> <p>Total Amount: < xsl:value-of select="expense-report/total"/> </p> </body> </html> </xsl:template > </xsl:stylesheet >

Slide 7

The life structures of a template A XSLT program is a XML record The root component of the archive is called xsl:stylesheet and is made out of an arrangement of " formats " (I.e components called xsl:template ) The xsl namespace is bound to the "authority" XSLT URI (e.g. http://www.w3.org/1999/XSL/Transform) The XML components forming the XSLT program: a mix of " client " names and " XSLT " names (QNames in the xsl namespace) The "basic" xsl components are "deciphered" and supplanted by the aftereffect of their assessment xsl:for-each, xsl:if, xsl:choose, xsl:value-of

Slide 8

A XSLT program < xsl:stylesheet version="1.0" xmlns:xsl= http://www.w3.org/1999/XSL/Transform > < xsl:template … ..> … … </xsl:template > < xsl:template … ..> … … </xsl:template > </xsl:stylesheet > Each format govern determines how certain hubs from the information XML doc must be reformatted in the yield

Slide 9

XSLT layouts Rules that depict how certain information XML hubs must be changed in the yield hubs Represented by components in the xsl namespace called <xsl:template> Can have designs that portray to what sort of hubs is the format administer appropriate <xsl:template match="author | manager "> Can have names (later) Have a body - a XML section that depicted the yield <xsl:template match="*"> <foobar/> <xsl:template>

Slide 10

Template designs Describe to what sort of hubs is a format relevant to Represented as a discretionary match characteristic on the xsl:template components The estimation of the match property is a string speaking to an example The example dialect is a subset of the XPath dialect A hub matches an example in the event that it is an individual from the outcome rundown of hubs of the example expression (practically ordinary XQuery assessment)

Slide 11

Template designs: cases para coordinates any para component * coordinates any component chapter|appendix coordinates any part component and any index component olist/thing matches any thing component with an olist parent reference section//para coordinates any para component with a supplement precursor component/matches the root hub content() coordinates any content hub handling direction() coordinates any preparing guideline hub() coordinates any hub other than a trait hub and the root hub id("W11") matches the component with interesting ID W11 para[1] coordinates any para component that is the primary para youngster component of its parent @class coordinates any class quality ( no component that has a class property) • @* coordinates any characteristic

Slide 12

Applying a format to a solitary hub Input <foo>beam</foo> Two case layouts < xsl:template match="foo"> <bar>baz</bar> <bar>baz</bar> </xsl:template > < xsl:template match="foo"> <bar>< xsl:- estimation of select="."</xsl:value-of ></bar> <bar>beam</bar> </xsl:template > Applying a format to a solitary hub Return the body of the layout All the xsl components in the body are "translated" and supplanted by their outcome alternate components stay unaltered The present hub is set to the information hub while assessing Xpath expressions (recollect "."?)

Slide 13

Recursive use of layouts The formats are not (ordinarily) summoned by hand (see later) XSLT semantics depends on an inherent, recursive utilization of layouts Apply-layouts( rundown of XML hubs) - > rundown of XML hubs For every info hub (all together, see later) Find the "best" format that applies (see clashing formats later… ) Note: decision of layout is on a hub premise Apply the layout, returns back an arrangement of hubs Concatenate every single fractional result, give back The assessment of the XSLT principle program begins by conjuring this recursive methodology on the info archive hub

Slide 14

Invoking the recursive use of formats Why is this strategy "recursive" ? While assessing a format one can trigger the re-assessment of this methodology <xsl:apply-template> Example: Input This is a <emph>important</emph> point. Layout <xsl:template match="emph"> <fo:inline-succession textual style weight="bold"> <xsl:apply-formats select="./text()"/> </fo:inline-sequence> </xsl:template>

Slide 15

xsl:apply-layouts Re-enter the inherent recursive utilization of formats Has a select property that indicates on what set of hubs to apply the system (utilizing Xpath) <xsl:apply-layouts select="author"/> <xsl:apply-formats select="author/name"/> <xsl:apply-formats select=".//heading"/> <xsl:apply-formats select="ancestors::department/bunch"/> <xsl:apply-layouts select="."/> The request of those hubs can be changed utilizing a xsl:sort (see later); default is record arrange If no select trait, then verifiably trigger the recursive use of formats on the rundown of offspring of the present hub

Slide 16

Default layouts What happens if there is no layout that matches a hub ? Default layouts.. Components and report hubs <xsl:template match="*|/"> <xsl:apply-layouts/> </xsl:template> Attributes and content hubs <xsl:template match="text()|@*"> <xsl:value-of select="."/></xsl:template> alternate hubs <xsl:template match="processing-instruction()|comment()"/>

Slide 17

Named formats Sometimes one can summon a specific format - by name <xsl:template name="authorsTemplate"> Instead of <xsl:apply-templates> <xsl:call-format name=" authorsTemplate"> Semantics is a similar Small semantic distinction xsl:call-layouts does not change the present hub xsl:apply-layouts does

Slide 18

xsl:value-of You have seen it as of now <xsl:value-of select="path expression"/> Evaluates the way expression => hubs Apply the fn:string(..) capacity to every hub (recollect that it ?) Concatenate the strings Create (and give back) another content hub with this esteem

Slide 19

xsl:for-each <xsl:for-each select = hub set-expression> <!- - Content: (xsl:sort*, layout body) - > </xsl:for-each> The hub set expression assesses to a rundown of hubs For every one of them give back the format body, assessed typically Each application gives back a rundown of hubs, link them all The information rundown is handled in archive arrange if there should arise an occurrence of no sort, generally in the sorting determined by the xsl:for-each

Slide 20

Xsl:for-every case Program < xsl:template match="/"> <html> <head> <title>Customers</title> </head> <body> <table> <tbody> < xsl:for-every select="customers/customer"> <tr> <th> < xsl:apply-layouts select="name"/> </th> < xsl:for-each select="order"> <td> < xsl:apply-formats/> </td> </xsl:for-each> </tr> </xsl:for-each> </tbody> </table> </body> </html> </xsl:template> Data <customers> <customer> <name>...</name> <order>...</order> <order>...</order> </customer> <customer> <name>...</name> <order>...</order> <order>...</order> </client

SPONSORS