- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to apply XSL transformation on an XML document?
The <x:transform> tag applies an XSL transformation on an XML document.
Attribute
The <x:transform> tag has the following attributes −
Attribute | Description | Required | Default |
---|---|---|---|
doc | Source XML document for the XSLT transformation | No | Body |
docSystemId | URI of the original XML document | No | None |
xslt | XSLT stylesheet providing transformation instructions | Yes | None |
xsltSystemId | URI of the original XSLT document | No | None |
result | Result object to accept the transformation's result | No | Print to page |
var | Variable that is set to the transformed XML document | No | Print to page |
scope | Scope of the variable to expose the transformation's result | No | None |
Example
Consider the following XSLT stylesheet style.xsl −
<?xml version = "1.0"?> <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0"> <xsl:output method = "html" indent = "yes"/> <xsl:template match = "/"> <html> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match = "books"> <table border = "1" width = "100%"> <xsl:for-each select = "book"> <tr> <td> <i><xsl:value-of select = "name"/></i> </td> <td> <xsl:value-of select = "author"/> </td> <td> <xsl:value-of select = "price"/> </td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet>
Now consider the following JSP file −
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix = "x" uri = "http://java.sun.com/jsp/jstl/xml" %> <html> <head> <title>JSTL x:transform Tags</title> </head> <body> <h3>Books Info:</h3> <c:set var = "xmltext"> <books> <book> <name>Padam History</name> <author>ZARA</author> <price>100</price> </book> <book> <name>Great Mistry</name> <author>NUHA</author> <price>2000</price> </book> </books> </c:set> <c:import url = "http://localhost:8080/style.xsl" var = "xslt"/> <x:transform xml = "${xmltext}" xslt = "${xslt}"/> </body> </html>
You will receive the following result −
Books Info
Padam History ZARA | 100 |
Great Mistry NUHA | 2000 |
- Related Articles
- How to apply Affine Transformation on an image in OpenCV Python?
- How to extract Key XML Elements from an XML Document in Oracle?
- How to apply a 2D or 3D transformation to an element with CSS
- How to apply linear transformation to the input data in PyTorch?
- How to create Python objects based on an XML file?
- Error in XML document while processing SOAP response
- How to apply Perspective Transformations on an image using OpenCV Python?
- How to parse an XML in JSP?
- How to Apply Different Headers or Footers on Each Page on an Excel Spreadsheet?
- Apply the Group Accumulator Operator $first on the system variable $$ROOT to return reference to the root document?
- How to apply t test on each row of an R data frame?
- How to create an HTML Document?
- PyTorch – How to perform random affine transformation of an image?
- How can I apply an offset on the current time in Python?
- How to add an attribute to the XML file using Powershell?

Advertisements