Nothing Special   »   [go: up one dir, main page]

XSL, XSLT and Xpath

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

XSL, XSLT and XPATH

 is a family of standards that specifies how to define Extensible Markup


Language (XML) document transformation and presentation. The
standards are published by the World Wide Web Consortium (W3C), an
international community that develops specifications related to web
architecture, design, applications and other web technologies.

 is a style sheet language that is used for transforming and presenting


What is XSL? XML documents. XSL is formalized as a specification World Wide Web
(Enter name Consortium (W3C).

here)  In fact, the XSL standard was based in part on CSS, level 1, as well as
on the Document Style Semantics and Specification
Language standard. The W3C published the first working draft of the
XSL standard in August 1998.
 Design to send, store, receive, and display data.
What is XSL?
 Is platform and programming language independent.
(Enter name
here)
1. Creating XSL files
An XSL file is a style sheet that can be used to transform
XML documents into other document types and to format
the output.
2. Editing XSL files
You can edit XSL files manually, using content assist, and
automatically, using various XSL editor wizards. Editing
your XSL file enables you to determine what kind of
output is created when your XSL file is run.
3. Validating XSL files
The XSL validator ensures that the XSL file is well-
formed. It tries to detect any static errors, that is, an error
that can be detected in a style sheet before execution
starts.
Working with 4.Associating XSL files with XML files
You can associate an XSL file with an XML file, so that, in
XSL files certain circumstances, the XML file is automatically called
by the XSL file.
5.Working with XSL templates
When using content assist in the XSL editor, or when you
are creating a new XSL file, you can insert predefined
XSL code from a template file into your XSL file You might
find it helpful to use templates if you want to reuse XSL
code multiple times.
6.Generating compiled XSL
To increase the speed of runtime processing of XSL
stylesheets, you can precompile and integrate XSL 1.0 or
2.0 stylesheet documents into Java projects.
 XSLT: It is a language for transforming XML documents into
various other types of documents.
 XPath: It is a language for navigating in XML documents. Main parts of
 XQuery: It is a language for querying XML documents. XSL
 XSL-FO: It is a language for formatting XML documents.
Document
 Extensible Stylesheet Language Transformations, provides
the ability to transform XML data from one format to another
automatically. What is XSLT?
 One of the easiest ways to understand what is XSLT
(extensible stylesheet language transformations) is that it's
simply a template for displaying specific information from
more complex XML data sets.
 An XSLT stylesheet is used to define the
transformation rules to be applied on the target XML
document. XSLT stylesheet is written in XML format.

 XSLT Processor takes the XSLT stylesheet and applies


the transformation rules on the target XML document
How XSLT and then it generates a formatted document in the
Works? form of XML, HTML, or text format.

 This formatted document is then utilized by XSLT


formatter to generate the actual output which is to
be displayed to the end-user.
Advantages using XSLTschool

• Independent of programming. Transformations are written in a separate xsl


file which is again an XML document.

• Output can be altered by simply modifying the transformations in xsl file. No


need to change any code. So Web designers can edit the stylesheet and
can see the change in the output quickly.
DisAdvantages using XSLTschool

• Memory intensive and suffers a performance penalty


• Difficult to implement complicated business rules
• Have to learn a new language (if not already familiar)
• Can't change the value of variables (require recursions)
What is
XPATH?  is defined as XML path. It is a syntax or language for finding any element
on the web page using the XML path expression. XPath is used to find the
location of any element on a webpage using HTML DOM structure.

 stands for XML Path Language. It uses a non-XML syntax to provide a


flexible way of addressing (pointing to) different parts of an XML document.
It can also be used to test addressed nodes within a document to
determine whether they match a pattern or not.
 Path contains the path of the element situated on the web page. The
standard syntax for creating XPath is as follows:
 XPath=//tagname[@attribute='value']
 // : Select the current node.
 Tagname: Tagname of the particular node.
 @: Select attribute.
Syntax for
 Attribute: Attribute the name of the node.
XPath  Value: Value of the attribute.
XPath Locators Find different elements on a web page.

To find the element by the ID of the


ID
element.
To find the element by the class name of
Classname
the element.

Name To find the element by name of the element.

Link Text To find the element by the text of the link.


Types of
XPath XPath
XPath is required for finding the dynamic
element and traversing between various
Locators elements of the web page.

CSS path also locates elements having no


CSS path
name, class, or ID.
 Absolute XPath
 Relative XPath
two types of
XPath
Absolute Xpath

 is the direct way to find the element. But the disadvantage of the absolute
XPath is that if there are any changes made in the path of the element then
that XPath fails.
 The key characteristic of XPath is that it begins with the single forward
slash(/), which means you can select the element from the root node.
two types of Below is an example of an absolute XPath expression of the element
XPath shown in the below screen.
Relative Xpath

 A relative path, or a double slash search, begins with double slashes. The
double slashes signify a break in the absolute path. Here is how to select
two types of the same business email field using a relative path.
XPath
Relative Xpath

 A relative path, or a double slash search, begins with double slashes. The
double slashes signify a break in the absolute path. Here is how to select
the same business email field using a relative path.
 is defined as a type of XPath used to search an element node anywhere
that exist on the web page. It is specified by the double forward slash
notation (//) which starts from the middle of the DOM Structure and it is not
Syntax necessary to add a long XPath. No need to start from the root node could
start with the node that we have selected and relative path can have
children as well. And This Relative Path is preferred due to no direct
access from the root node.
Syntax

The general format used to search an element is given below:

// tagname[@ attribute=’value’]

Here

Syntax // is the current node element


Tag: is the element node like < p> , <div > etc.
@: It denotes an attribute.s
// *[@class= ‘value ‘]
ACTIVITYY

 What are the differences between XSL and CSS?


 List down the capabilities of the XSL.
 Is XSL similar to XML?
 Is XSL user friendly?

Submission thru google drive


Deadline:April 3, 2024
Thank You!

You might also like