Yet more on XSLT. Regular expression handling in EXSLT We saw that the EXSLT extensions are divided into a group of modules, each of which has its own.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

Advanced XSLT II. Iteration in XSLT we sometimes wish to apply the same transform to a set of nodes we iterate through a node set the node set is defined.
Advanced XSLT. Branching in XSLT XSLT is functional programming –The program evaluates a function –The function transforms one structure into another.
Advanced XSLT II. Iteration in XSLT we sometimes wish to apply the same transform to a set of nodes we iterate through a node set the node set is defined.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
Lecture 10. Back to the table example We can now return to considering in detail the first XSLT style-sheet we saw –The one which, when applied to the.
Rendering XML documents with XSL The most powerful approaches to rendering XML documents involve using XSL (eXtensible Stylesheet Language) XSL enables.
Lecture 17. Side remark: for-each equivalence again Second-hand cars Item Model Engine Size Price
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET (Using XSLT style sheet to calculate values based.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
XSL Transformations Transforming XML document into other (XML) documents 1XSL Transformations.
17 Apr 2002 XML Stylesheets Andy Clark. What Is It? Extensible Stylesheet Language (XSL) Language for document transformation – Transformation (XSLT)
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
1 Copyright (c) [2002]. Roger L. Costello. All Rights Reserved. Using Extension Elements and Extension Functions with XSLT and XPath Roger L. Costello.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
More on XSLT. More on XSLT variables Earlier we saw two ways to associate a value with a variable  A variable whose value is the empty string, for example.
. If the PHP server is an server or is aware of which server is the server, then one can write code that s information. –For example,
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
PHP: Hypertext Processor Fred Durao
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
MORE APPLICATIONS OF REGULAR EXPRESSION By Venkata Sai Pundamalli id:
1 Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COT 6930 Advanced Internet Programming Dr. Roy Levow Day 2.
CSE3201/CSE4500 Information Retrieval Systems
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
WORKING WITH XSLT AND XPATH
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
Loading methods in PHP DOMDocument class DOMDocument extends DOMNode {... mixed load ( string $filename.
Set 8.5: XSLT Continued IT452 Advanced Web and Internet Systems.
ECA 228 Internet/Intranet Design I XSLT Example. ECA 228 Internet/Intranet Design I 2 CSS Limitations cannot modify content cannot insert additional text.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
Extending XML Schemas XML Schemas: Best Practices A set of guidelines for designing XML Schemas Created by discussions on xml-dev.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Lecture 11 XSL Transformations (part 1: Introduction)
Programming in Perl regular expressions and m,s operators Peter Verhás January 2002.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Applying eXtensible Style Sheets (XSL) Ellen Pearlman Eileen Mullin Programming.
XML – Part III. The Element … This type of element either has the element content or the mixed content (child element and data) The attributes of the.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
CS346 Regular Expressions1 Pattern Matching Regular Expression.
1 cs XSL XSL is a standard that consists of three parts: XPath (navigation in documents) XPath was taught in the DB course, so it will not be.
PHP’s Regular Expression Functions (Perl Compatible) Examples taken from: Beginning PHP 5 and MySQL 5 From Novice to Professional.
XSLT. XSLT stands for Extensible Stylesheet Language Transformations XSLT is used to transform XML documents into other kinds of documents. XSLT can produce.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
LING 408/508: Programming for Linguists Lecture 14 October 19 th.
XML Extensible Markup Language. Introduction to XML Text based format As JSON it’s mainly intended for data interchange (transport & store) Also widely.
 XSL – Extensible Style Sheet Language  XSLT – XSL Transformations › Used to transform XML documents to other formats,like HTML or other XML documents.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
Validation using Regular Expressions. Regular Expression Instead of asking if user input has some particular value, sometimes you want to know if it follows.
XP 1 XSLT II Robin Burke ECT 360. XP 2 Outline Conditionals Numbering Functions and operators Variables and parameters Named and recursive templates.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML Schema – XSLT Week 8 Web site:
1 XSL Transformations (XSLT). 2 XSLT XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XSLT uses XPath.
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
FGDC  ISO MTX (Metadata Transformation XSLT) Bruce Westcott – Geospatial Metadata Consultant.
Session IV Chapter 14 – Chapter 14 – XSLThttp://
Unit 4 Representing Web Data: XML
Using Extension Elements and Extension Functions with XSLT and XPath
ACG 4401 XSLT Extensible Stylesheet Language for Transformations
Chapter 7 Representing Web Data: XML
Applying eXtensible Style Sheets (XSL)
PHP.
Validation using Regular Expressions
Presentation transcript:

Yet more on XSLT

Regular expression handling in EXSLT We saw that the EXSLT extensions are divided into a group of modules, each of which has its own namespace We saw that there is a module providing access to regular expressions: –Regular Expressions EXSLT, The module provides three functions: –boolean test(…) Tests to see whether a string matches a specified regular expression –object match(…) performs regular expression matching on a string, returning the submatches found –string replace(…) replaces the portions of a string that match a given regular expression with the contents of another string

test() in EXSLT regular expression module Syntax boolean somePrefix:test(target, regexp, flags) Semantics –The function returns true if the string given as the first argument matches the regular expression given as the second argument. Arguments –The first argument is the string to be analysed –The second argument is a regular expression that follows the Javascript regular expression syntax. –The third argument is a string consisting of flags to be used by the test. If a character is present then that flag is true. The flags are: i: case insensitive – if present, the regular expression is treated as case insensitive; if absent, the regular expression is case sensitive. g: global test - no effect on this function, but is retained for consistency with the match() and replace() functions

Example usage of test() Testing addresses This address appears fine Error: this address lacks a 2nd level domain

Support for the regular expression module, part 1 The EXSLT regular-expression module is supported in Firefox However, it appears not to be supported in other browsers

Support for the regular expression module, part 2 The EXSLT regular- expression module also appears not to be supported in PHP5

Can we use regular expressions on the server-side? Yes, we can use regular expressions in server-side XSLT processing Because we can call PHP functions from inside XSLT

Using regular expressions on the server-side The PHP program allows the stylesheet below to use the power of regular expressions to process the XML document Therefore, the result is available in all main browsers

How this works, part 1 We have already seen that the XSLT Processor implemented in PHP5 supports certain external namespaces For example, we have seen it supports We can access PHP functions from inside XSLT because  the processor also supports this namespace  which includes a function, called function, that allows us to access any PHP function

How this works, part 2 We can use function() inside XSL if we make the stylesheet refer to this namespace: <xsl:transform version="1.0" xmlns:xsl=" xmlns:fred=“ > … … …

How this works, part 3 We can use any prefix we like for the namespace But it’s probably better to use something meaningful, such as php <xsl:transform version="1.0" xmlns:xsl=" xmlns:php=“ > … … …

How this works, part 4 Let’s assume we have implemented, in PHP, a boolean function called isCorrect Address() We can now use that in our stylesheet: <xsl:transform xmlns:xsl=" version="1.0" xmlns:php=" > … This address appears fine Error: this address lacks a 2nd level domain

How this works, part 5 Our address-checking function in PHP: function isCorrect Address($string) { if ( { return true; } else { return false; } } We must include this function in our PHP program, but we must also …

How this works, part 6 We must also ensure that our PHP program tells the XSLT processor to “register” PHP functions: <?php //header('Content-type: text/xml'); function isCorrect Address($string) { if ( { return true; } else { return false; } } $xmldoc = new DOMDocument(); $xmldoc->load("demo301.xml"); $xsldoc = new DOMDocument(); $xsldoc->load("demo301.xsl"); $xsl = new XsltProcessor(); $xsl->registerPHPFunctions(); $xsl->importStyleSheet($xsldoc); echo $xsl->transformToXML($xmldoc); ?>