Copyright 2001, ActiveState. XSLT and Scripting Languages or…XSLT: what is everyone so hot and bothered about?

Slides:



Advertisements
Similar presentations
Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
Advertisements

Advanced XSLT. Branching in XSLT XSLT is functional programming –The program evaluates a function –The function transforms one structure into another.
Multimedia Seminar XSLT Tobias Naumann. MM Seminar - XSLT2 Structure What is XSLT? Design and Concepts Practical use Examples.
XML: Extensible Markup Language
Advanced XSL Learn how to use advanced XSLT techniques, EXSLT, and Xalan extensions to solve complicated problems Cascade Server User’s ConferenceAmy.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 12 Extensible Stylesheet Language Transformations : XSLT.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XSL XSLT and XPath 11-Apr-17.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
XSLT & XPATH. From Friday Everything in XML is machine readable Attributes describe elements, so does an element’s place in the tree (context) XML must.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Transforming XML The XSLT Language Michael H. Kay.
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
CS 898N – Advanced World Wide Web Technologies Lecture 22: Applying XML Chin-Chih Chang
Russell Taylor Lecturer in Computing & Business Studies.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
Technical Track Session XML Techie Tools Tim Bornholt.
ECA 228 Internet/Intranet Design I Intro to XSL. ECA 228 Internet/Intranet Design I XSL basics W3C standards for stylesheets – CSS – XSL: Extensible Markup.
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
XML and its applications: 4. Processing XML using PHP.
Introduction technology XSL. 04/11/2005 Script of the presentation Introduction the XSL The XSL standard Tools for edition of codes XSL Necessary resources.
XML BIS4430 – unit 10. XML Origins Extensible Markup Language (XML) 1998 Inspired by Standard Generalized Markup Language (SGML) and HTML. SGML defines.
Sheet 1XML Technology in E-Commerce 2001Lecture 7 XML Technology in E-Commerce Lecture 7 XSL Formatting Objects, Java Data Binding.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
INTERPRETING IMPERATIVE PROGRAMMING LAGUAGES IN EXTENSIBLE STYLESHEET LANGUAGE TRANSFORMATIONS (XSLT) Authors: Ruhsan Onder Assoc.
XSLT + Xpath CS High level view We are doing tree editing Changes to node properties Structural rearrangement Several mdels for this kind of task.
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Lecture 11 XSL Transformations (part 1: Introduction)
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
COSC617 Project XML Tools Mark Liu Sanjay Srivastava Junping Zhang.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Dom and XSLT Dom – document object model DOM – collection of nodes in a tree.
 XSL – Extensible Style Sheet Language  XSLT – XSL Transformations › Used to transform XML documents to other formats,like HTML or other XML documents.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
Martin Kruliš by Martin Kruliš (v1.1)1.
WHY ARE WE HERE? Nick Derrickson BA371, Winter 2016.
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Using DSDL plus annotations for Netconf (+) data modeling Rohan Mahy draft-mahy-canmod-dsdl-01.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Chapter 13 A & B Programming Languages and the.
XSLT, XML Schema, and XPath Matt McClelland. Introduction XML Schema ▫Defines the content and structure of XML data. XSLT ▫Used to transform XML documents.
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
Presented By Sushil K. Chaturvedi Assistant Professor SRCEM,Banmore 1.
1 XSLT XSLT (extensible stylesheet language – transforms ) is another language to process XML documents. Originally intended as a presentation language:
Slice & dice the Web with XmlPL, The XML Processing Language A presentation for Boise Code Camp 2007 Joseph Coffland Cauldron Development LLC.
The language focusses on ease of use
Top 8 Best Programming Languages To Learn
Unit 4 Representing Web Data: XML
PROGRAMMING LANGUAGES
XML in Web Technologies
Database Processing with XML
7 Best Programming Languages Based as per Earnings & Opportunities
Chapter 7 Representing Web Data: XML
CS 431 – February 28, 2005 Carl Lagoze – Cornell University
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Querying XML XSLT.
XML and its applications: 4. Processing XML using PHP
More XML XML schema, XPATH, XSLT
XML and Web Services (II/2546)
Presentation transcript:

Copyright 2001, ActiveState

XSLT and Scripting Languages or…XSLT: what is everyone so hot and bothered about?

Copyright 2001, ActiveState Background: ActiveState ActiveState creates tools for open source and standards-based high-level languages: –Perl –Python –PHP –XSLT –Tcl

Copyright 2001, ActiveState What is XSLT? A language for transforming between XML vocabularies. Standardized by the World Wide Web Consortium Integrated with.NET, Apache, IE, Java, Oracle, Perl, Python, …

Copyright 2001, ActiveState XSLT XSLT is a slightly new twist: –Not a scripting language –Not, strictly-speaking, open source But not radically different: –Typically interpreted –Open source implementations –Not vendor dominated

Copyright 2001, ActiveState Programming Language? –XSLT has looping constructs function calling variables parameters math functions module combination …

Copyright 2001, ActiveState Looping in XSLT xsl:for-each lets us do the same thing for many nodes The body of the xsl:for-each is a full template It is instantiated once for each match Each time a different node is the "current" node

Copyright 2001, ActiveState Example of Iterating: XML Paul Prescod Snake Charmer Gisle Aas Camel Herder

Copyright 2001, ActiveState Example of Iterating: XSLT

Copyright 2001, ActiveState

HTML Output Paul Prescod Snake Charmer Gisle Aas Camel Herder

Copyright 2001, ActiveState Calling Functions What if you wanted to do this in XSLT: func myfunction(arg1, arg2){ …do something with params… } myfunction(54, 42)

Copyright 2001, ActiveState Functions, Parameters, Variables <xsl:value-of select="$studio * $everything"/>

Copyright 2001, ActiveState Template Call

Copyright 2001, ActiveState

Bottom Line XSLT can be used to compute anything that can be computed It is Turing complete But…. –Certain coding paradigms are VERY awkward –Non-textual Input/Output is typically not possible

Copyright 2001, ActiveState Scripting Languages Scripting languages are designed to be general purpose Modern scripting languages go well beyond scripting They are general purpose multi- paradigm languages –But XSLT wins for specificity

Copyright 2001, ActiveState XSLT XML Support XSLT has deep native support for XML Built-in, highly consistent parser XPath XML navigation (query) language Special syntax for working with elements

Copyright 2001, ActiveState XML Recursion XSLT makes input-based recursion easy: –Sections within sections within … –Part descriptions within part descriptions … XSLT automatically selects the right rule to go with the right element in the input document

Copyright 2001, ActiveState Context XSLT keeps track of context: namespaces, current node, current node list etc. Relevant contexts are in both the stylesheet and the document. In most traditional programming languages, the programmer would have to be explicit.

Copyright 2001, ActiveState XSLT Example <xsl:template name= " my_template " match ="section"> …

Copyright 2001, ActiveState Explicit Code Equivalent class my_template{ XPath match = "section" method action(context){ output(" ) nodes = XPathEngine.evaluate( "paragraph", context) for(node in nodes){ template = rules.lookup(node) template.evaluate(node) } output(" ) } }rules.addrule(new my_template())

Copyright 2001, ActiveState With a little detail-hiding class my_template{ XPath match = "section method action(context){ start_tag(h1) applyTemplates(paragraph, context) end_tag(/h1) } rules.addrule(new my_template())

Copyright 2001, ActiveState Bottom line Given a good OO language, you can emulate XSLT But it requires a lot of infrastructure And it still requires you to take care of a lot of details…

Copyright 2001, ActiveState How do you choose? Spoon! Fork! Spoon! Fork!

Copyright 2001, ActiveState Connectivity XSLT is only good at talking to XML systems Scripting languages can talk to anything This is typically the deciding factor. If you need to build a GUI, you need to do it in a language with a GUI library!

Copyright 2001, ActiveState Navigation XSLT is really good at walking around the document tree. Scripting languages are typically not as concise at navigation – but very flexible. XSLT strongly encourages you to walk the tree top-down, front to back.

Copyright 2001, ActiveState Data Structures XSLT makes it very difficult to create structured data containers The idea is that the only data you need is in the input document: it already has a data structure! But some computations are much easier if you can restructure the information yourself.

Copyright 2001, ActiveState Community There are dozens of APIs for processing XML. Popular ones are not as powerful as XSLT. Powerful ones are not as popular as XSLT. Nobody gets fired for using XSLT – but you can get fired for inventing your own XML API.

Copyright 2001, ActiveState Implementations: XSLT XSLT presents a lot of opportunity for optimization Smart implementers pre-compile XPaths and some even compile templates. There are many different XSLT implementations with different tradeoffs.

Copyright 2001, ActiveState Implementations: Scripting Scripting code is hard to optimize. On the other hand, the programmer can choose algorithms and datastructures! Plus you could write a SAX application that does not use an in-memory tree at all. This is efficient but difficult.

Copyright 2001, ActiveState Standardization XSLT is installed in –browsers, –database engines, –directory engines, –programming languages, –and operating systems! –JavaScript is the only language that even comes close.

Copyright 2001, ActiveState Best of Both Worlds? The easy way to split work is to use general purpose languages to generate or consume XML used by XSLT tempfile.write(" ") run("xslttrans conv.xsl tempfile outfile") data = outfile.read()

Copyright 2001, ActiveState More Sophisticated Approach XSLT has a concept of extension functions <xsl:value-of select=myns:myfunc(.)"/> If the implementation is smart enough, functions can be defined in any scripting language

Copyright 2001, ActiveState Example Extension Functions function getdate(numdays) { var d = new Date(); var totalDays = parseInt(numdays) * multiplier; d.setDate(d.getDate() + totalDays); return d.toLocaleString(); }

Copyright 2001, ActiveState Using an Extension Function We have logged your enquiry and will respond by.

Copyright 2001, ActiveState Extension Elements in Xalan-J Xalan-Java uses the Bean Scripting Framework (BSF), an architecture for incorporating scripting into Java applications and applets. s/bsf

Copyright 2001, ActiveState BSF-compatible Languages Rhino (ECMAScript/JavaScript) Jython (Python) Jacl (TCL) NetRexx (REXX) PerlScript (Perl – from ActiveState) VBScript/Jscript through ActiveScripting

Copyright 2001, ActiveState Inline Extensions function getdate(numdays){ var d = new Date(); … return d.toLocaleString(); }

Copyright 2001, ActiveState In the Microsoft Universe Microsoft has a concept of ActiveScripting Host – used by MSXSL –VBScript –JScript –Python (ActivePython) –PerlScript (ActivePerl) –REXX –Tcl

Copyright 2001, ActiveState In the Linux/C world? Nothing yet…but maybe some day: ActiveScripting for XPCOM XPCOM is a portable variant of COM from the Mozilla project ActiveScripting for XPCOM would allow languages to be embedded in Linux/C apps like Xalan-C

Copyright 2001, ActiveState What about Standardization? XSLT 1.1 defines function f(x) {... } function g(y,z) {... }

Copyright 2001, ActiveState Supported Languages Out of the box, XSLT 1.1 has explicit support for ECMAScript (JavaScript) and Java Other languages are allowed but not predefined.

Copyright 2001, ActiveState From the spec XSLT processors are not required to support any particular language binding. xsl:script elements with language values not supported by the processor are ignored.

Copyright 2001, ActiveState ActiveState and XSLT ActiveState is the leading vendor of Visual Studio.NET plugins: –Visual Perl –Visual Python –Visual XSLT

Copyright 2001, ActiveState Visual XSLT Visual XSLT brings the features of Visual Studio to XSLT stylesheet and transformation development Improved productivity in creating XSLT transformations

Copyright 2001, ActiveState Komodo XSLT Komodo is a multi-language IDE for Windows and Linux Komodo has the same XSLT feature set as Visual XSLT. Visual XSLT is appropriate for Visual Studio shops. Komodo is best for cross-platform shops.

Copyright 2001, ActiveState Summary XSLT and scripting languages work together. XSLT engines can integrate them through extension functions (inline or out of line). Our debuggers and IDEs can bring them into a common development interface.

Copyright 2001, ActiveState Resources

Copyright 2001, ActiveState