SlideShare uma empresa Scribd logo
1 de 23
Q5M1 - XML Dudy Fathan Ali S.Kom
Rendering XML Document
Q5M1 - XML
Dudy Fathan Ali, S.Kom (DFA)
2015
CEP - CCIT
Fakultas Teknik Universitas Indonesia
Objectives
Q5M1 - XML Dudy Fathan Ali S.Kom
In this session, you will learn to:
Transform an XML document through a Cascading Style Sheet
Transform an XML document through Extensible Style Sheet
Language
Introducing Cascading Style Sheet
Q5M1 - XML Dudy Fathan Ali S.Kom
A CSS is a text file containing one or more rules or definitions for
the style characteristics of a particular element.
It controls how tags are formatted in XML and HTML documents.
The CSS file can be included in XML documents with the same
data structure.
Creating CSS
Q5M1 - XML Dudy Fathan Ali S.Kom
The syntax for coding a CSS is:
elementname {
property1: value;
property2: value;
}
elementname specifies
the name of the element.
Creating CSS
Q5M1 - XML Dudy Fathan Ali S.Kom
The syntax for coding a CSS is:
elementname {
property1: value;
property2: value;
}
property1 and property2
specify the property names, such
as font-family, font-size, and color
Creating CSS
Q5M1 - XML Dudy Fathan Ali S.Kom
The syntax for coding a CSS is:
elementname {
property1: value;
property2: value;
}
value specifies the property
values for a property name.
For example, to display the film title in red, you can type
the following code in a CSS file:
FILM {COLOR: RED}
Applying CSS
Q5M1 - XML Dudy Fathan Ali S.Kom
A CSS can be applied to an XML document using the following
syntax:
<?xml:stylesheet type="text/css" href="path-name"?>
Instructs the browser that the XML
document uses a stylesheet.
Applying CSS
Q5M1 - XML Dudy Fathan Ali S.Kom
A CSS can be applied to an XML document using the following
syntax:
<?xml:stylesheet type="text/css" href="path-name"?>
Specifies the type of
formatting that is being used.
Applying CSS
Q5M1 - XML Dudy Fathan Ali S.Kom
A CSS can be applied to an XML document using the following
syntax:
<?xml:stylesheet type="text/css" href="path-name"?>
Specifies the name of the CSS
file used to format the XML
document.
Demo: Creating a CSS
Q5M1 - XML Dudy Fathan Ali S.Kom
Problem Statement:
Jim, the XML developer at CyberShoppe, has been asked to display
the product details for Cybershoppe in a browser in the following
format:
The price per unit, description, and quantity on hand for each product
should be displayed in teal, with a font size of 10 pts.
The product name should be displayed in red, with a font size of 20 pts.
It should be displayed in bold.
All details should be displayed in the Arial font.
Introducing XSL
Q5M1 - XML Dudy Fathan Ali S.Kom
CSS does not support the reorder, sort, and display of
elements based on a condition.
For such advanced formatting, XML supports Extensible Style
Sheet Language (XSL).
XSL has two parts:
XSL Transformations (XSLT)
XML Path (XPath)
XSL:
Contains instructions on how an XML document should be
transformed into an HTML or an XHTML document.
Uses XPath expressions to extract specific data from an XML
document.
The XSLT processor transforms the XML document into an
HTML or XHTML or into another XML document.
Analyzing the Working of the XSLT Processor
Q5M1 - XML Dudy Fathan Ali S.Kom
The XSLT processor applies the transformation information to
the source document and builds the result tree as shown in the
following figure.
MSXML Parser
XSLT tree
XSLT
processor
Source tree
Result tree
XSLT style sheet
XML document
Formatting Data Using XSLT
Q5M1 - XML Dudy Fathan Ali S.Kom
XSLT provides the following elements to select and format
data:
stylesheet
value-of
for-each
sort
text
Formatting Data Using XSLT
Q5M1 - XML Dudy Fathan Ali S.Kom
XSLT provides the following elements to select and format
data:
stylesheet
value-of
for-each
sort
text
Instructs the browser that the document is a style
sheet file.
Is the root element for all XSLT style sheets.
Is written as:
<xsl:stylesheet
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
version="1.0">
Formatting Data Using XSLT
Q5M1 - XML Dudy Fathan Ali S.Kom
XSLT provides the following elements to select and format
data:
stylesheet
value-of
for-each
sort
text
Displays the value of the specified element or
attribute.
Follows the syntax:
<xsl:value-of
select="elementname/attributename“
/>
Formatting Data Using XSLT
Q5M1 - XML Dudy Fathan Ali S.Kom
XSLT provides the following elements to select and format
data:
stylesheet
value-of
for-each
sort
text
Instructs the XSLT processor to process the
information for each instance of the specified pattern.
Follows the syntax:
<xsl:for-each select="pattern">
[action to be performed]
</xsl:for-each>
Formatting Data Using XSLT
Q5M1 - XML Dudy Fathan Ali S.Kom
XSLT provides the following elements to select and format
data:
stylesheet
value-of
for-each
sort
text
Sorts data based on the values assigned to elements and
attributes.
Follows the syntax:
<xsl:sort select="expression"
order="ascending | descending"
case-order="upper-first | lower-first“
data-type="text | number | qname"/>
Formatting Data Using XSLT
Q5M1 - XML Dudy Fathan Ali S.Kom
XSLT provides the following elements to select and format
data:
stylesheet
value-of
for-each
sort
text Generates constant text in the output and displays
labels.
Follows the syntax:
<xsl:text>
Text to be displayed as label
</xsl:text>
Creating XSLT Template Rules
Q5M1 - XML Dudy Fathan Ali S.Kom
A template rule:
Describes how an XML element and its contents are converted into
a specific format for displaying in the browser.
Consists of two parts:
A pattern that identifies an XML element in an XML document.
An action or processing code that details the transformation and
rendering of the resulting element.
XSLT uses two main elements for creating template rules:
template
apply-templates
Creating XSLT Template Rules
Q5M1 - XML Dudy Fathan Ali S.Kom
A template rule:
Describes how an XML element and its contents are converted into
a specific format for displaying in the browser.
Consists of two parts:
A pattern that identifies an XML element in an XML document.
An action or processing code that details the transformation and
rendering of the resulting element.
XSLT uses two main elements for creating template rules:
template
apply-templates
Defines a template for the desired
output.
Follows the syntax:
<xsl:template match="pattern">
[action to be taken]
</xsl:template>
Creating XSLT Template Rules
Q5M1 - XML Dudy Fathan Ali S.Kom
A template rule:
Describes how an XML element and its contents are converted into
a specific format for displaying in the browser.
Consists of two parts:
A pattern that identifies an XML element in an XML document.
An action or processing code that details the transformation and
rendering of the resulting element.
XSLT uses two main elements for creating template rules:
template
apply-templates Instructs the XSLT processor to find an
appropriate template and perform the
specified tasks on selected elements.
Follows the syntax:
<xsl:apply-templates
[select="pattern"]>
Demo: Creating an XSLT Style Sheet to Format Data
Q5M1 - XML Dudy Fathan Ali S.Kom
Problem Statement:
CyberShoppe needs to display product details, such as product ID,
name, and price per unit. The following figure depicts a sample
output.
The details about the products should be displayed in red.
Q5M1 - XML Dudy Fathan Ali S.Kom
Thank You!
Dudy Fathan Ali S.Kom
dudy.fathan@eng.ui.ac.id

Mais conteúdo relacionado

Mais procurados

XML Presentation-2
XML Presentation-2XML Presentation-2
XML Presentation-2
Sudharsan S
 
Xml Presentation-3
Xml Presentation-3Xml Presentation-3
Xml Presentation-3
Sudharsan S
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
Sudharsan S
 

Mais procurados (19)

Xml theory 2005_[ngohaianh.info]_1_introduction-to-xml
Xml theory 2005_[ngohaianh.info]_1_introduction-to-xmlXml theory 2005_[ngohaianh.info]_1_introduction-to-xml
Xml theory 2005_[ngohaianh.info]_1_introduction-to-xml
 
XML
XMLXML
XML
 
03 namespace
03 namespace03 namespace
03 namespace
 
Xml basics
Xml basicsXml basics
Xml basics
 
Basics of XML
Basics of XMLBasics of XML
Basics of XML
 
Dtd
DtdDtd
Dtd
 
00 introduction
00 introduction00 introduction
00 introduction
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
XML
XMLXML
XML
 
XML Presentation-2
XML Presentation-2XML Presentation-2
XML Presentation-2
 
Xml presentation
Xml presentationXml presentation
Xml presentation
 
transforming xml using xsl and xslt
transforming xml using xsl and xslttransforming xml using xsl and xslt
transforming xml using xsl and xslt
 
Xml schema
Xml schemaXml schema
Xml schema
 
02 well formed and valid documents
02 well formed and valid documents02 well formed and valid documents
02 well formed and valid documents
 
Xml Presentation-3
Xml Presentation-3Xml Presentation-3
Xml Presentation-3
 
Xml Presentation-1
Xml Presentation-1Xml Presentation-1
Xml Presentation-1
 
Xml schema
Xml schemaXml schema
Xml schema
 
XML
XMLXML
XML
 
Introduction to XML and Databases
Introduction to XML and DatabasesIntroduction to XML and Databases
Introduction to XML and Databases
 

Destaque

To try use XSL for display group XML file movies
To try use XSL for display group XML file moviesTo try use XSL for display group XML file movies
To try use XSL for display group XML file movies
Aey Unthika
 
Doxygen - Source Code Documentation Generator Tool
Doxygen -  Source Code Documentation Generator ToolDoxygen -  Source Code Documentation Generator Tool
Doxygen - Source Code Documentation Generator Tool
Guo Albert
 

Destaque (20)

To try use XSL for display group XML file movies
To try use XSL for display group XML file moviesTo try use XSL for display group XML file movies
To try use XSL for display group XML file movies
 
Building Collaborative Applications with Wikis
Building Collaborative Applications with WikisBuilding Collaborative Applications with Wikis
Building Collaborative Applications with Wikis
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
 
Wikis 2008
Wikis 2008Wikis 2008
Wikis 2008
 
MSc dissertation np
MSc dissertation npMSc dissertation np
MSc dissertation np
 
code documentation
code documentationcode documentation
code documentation
 
Chapter 04 part 2 Tech. Writing 2014-2015
Chapter 04 part 2 Tech. Writing  2014-2015Chapter 04 part 2 Tech. Writing  2014-2015
Chapter 04 part 2 Tech. Writing 2014-2015
 
E-books and App::Pod2Epub
E-books and App::Pod2EpubE-books and App::Pod2Epub
E-books and App::Pod2Epub
 
Project Documentation | Common Room Networks Foundation | 2003 - 2008
Project Documentation | Common Room Networks Foundation | 2003 - 2008Project Documentation | Common Room Networks Foundation | 2003 - 2008
Project Documentation | Common Room Networks Foundation | 2003 - 2008
 
How developers write documentation
How developers write documentationHow developers write documentation
How developers write documentation
 
Chapter 04 2014-15 Technical Writing
Chapter 04 2014-15  Technical WritingChapter 04 2014-15  Technical Writing
Chapter 04 2014-15 Technical Writing
 
Wonderful World of Wikis
Wonderful World of WikisWonderful World of Wikis
Wonderful World of Wikis
 
Code documentation
Code documentationCode documentation
Code documentation
 
Doxygen - Source Code Documentation Generator Tool
Doxygen -  Source Code Documentation Generator ToolDoxygen -  Source Code Documentation Generator Tool
Doxygen - Source Code Documentation Generator Tool
 
XSLT. Basic.
XSLT. Basic.XSLT. Basic.
XSLT. Basic.
 
Thinking of Documentation as Code [YUIConf 2013]
Thinking of Documentation as Code [YUIConf 2013]Thinking of Documentation as Code [YUIConf 2013]
Thinking of Documentation as Code [YUIConf 2013]
 
Introducción a la gestión de sistemas de información en la empresa. Universit...
Introducción a la gestión de sistemas de información en la empresa. Universit...Introducción a la gestión de sistemas de información en la empresa. Universit...
Introducción a la gestión de sistemas de información en la empresa. Universit...
 
Docs as-code-missing.-manual
Docs as-code-missing.-manualDocs as-code-missing.-manual
Docs as-code-missing.-manual
 
Session 4
Session 4Session 4
Session 4
 
XSLT 2010-03-03
XSLT 2010-03-03XSLT 2010-03-03
XSLT 2010-03-03
 

Semelhante a Rendering XML Document

Semelhante a Rendering XML Document (20)

Rendering XML Documents
Rendering XML DocumentsRendering XML Documents
Rendering XML Documents
 
Rendering XML Document
Rendering XML DocumentRendering XML Document
Rendering XML Document
 
Xml Session No 1
Xml Session No 1Xml Session No 1
Xml Session No 1
 
03 sm3 xml_xp_05
03 sm3 xml_xp_0503 sm3 xml_xp_05
03 sm3 xml_xp_05
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
5 xsl (formatting xml documents)
5   xsl (formatting xml documents)5   xsl (formatting xml documents)
5 xsl (formatting xml documents)
 
Xslt
XsltXslt
Xslt
 
Xml part5
Xml part5Xml part5
Xml part5
 
Xml transformation language
Xml transformation languageXml transformation language
Xml transformation language
 
"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides"Getting Started with XSLT" presentation slides
"Getting Started with XSLT" presentation slides
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
 
Xslt
XsltXslt
Xslt
 
Xslt
XsltXslt
Xslt
 
Unit2_XML_S_SS_US Data_CS19414.pptx
Unit2_XML_S_SS_US Data_CS19414.pptxUnit2_XML_S_SS_US Data_CS19414.pptx
Unit2_XML_S_SS_US Data_CS19414.pptx
 
Xml PPT
Xml PPTXml PPT
Xml PPT
 
Unit 5 xml (1)
Unit 5   xml (1)Unit 5   xml (1)
Unit 5 xml (1)
 
XML/XSLT
XML/XSLTXML/XSLT
XML/XSLT
 
Rancangan Jaringan Komputer
Rancangan Jaringan KomputerRancangan Jaringan Komputer
Rancangan Jaringan Komputer
 
Xsd
XsdXsd
Xsd
 
Xsd
XsdXsd
Xsd
 

Mais de Dudy Ali

Algorithm & Data Structure - Pengantar
Algorithm & Data Structure - PengantarAlgorithm & Data Structure - Pengantar
Algorithm & Data Structure - Pengantar
Dudy Ali
 
Object Oriented Programming - Inheritance
Object Oriented Programming - InheritanceObject Oriented Programming - Inheritance
Object Oriented Programming - Inheritance
Dudy Ali
 
Object Oriented Programming - File Input & Output
Object Oriented Programming - File Input & OutputObject Oriented Programming - File Input & Output
Object Oriented Programming - File Input & Output
Dudy Ali
 
Web Programming Syaria - PHP
Web Programming Syaria - PHPWeb Programming Syaria - PHP
Web Programming Syaria - PHP
Dudy Ali
 

Mais de Dudy Ali (20)

Understanding COM+
Understanding COM+Understanding COM+
Understanding COM+
 
Distributed Application Development (Introduction)
Distributed Application Development (Introduction)Distributed Application Development (Introduction)
Distributed Application Development (Introduction)
 
Java CRUD Mechanism with SQL Server Database
Java CRUD Mechanism with SQL Server DatabaseJava CRUD Mechanism with SQL Server Database
Java CRUD Mechanism with SQL Server Database
 
Network Socket Programming with JAVA
Network Socket Programming with JAVANetwork Socket Programming with JAVA
Network Socket Programming with JAVA
 
Review Materi ASP.NET
Review Materi ASP.NETReview Materi ASP.NET
Review Materi ASP.NET
 
Pengantar XML
Pengantar XMLPengantar XML
Pengantar XML
 
Pengantar XML DOM
Pengantar XML DOMPengantar XML DOM
Pengantar XML DOM
 
Pengantar ADO.NET
Pengantar ADO.NETPengantar ADO.NET
Pengantar ADO.NET
 
Database Connectivity with JDBC
Database Connectivity with JDBCDatabase Connectivity with JDBC
Database Connectivity with JDBC
 
Algorithm & Data Structure - Algoritma Pengurutan
Algorithm & Data Structure - Algoritma PengurutanAlgorithm & Data Structure - Algoritma Pengurutan
Algorithm & Data Structure - Algoritma Pengurutan
 
Algorithm & Data Structure - Pengantar
Algorithm & Data Structure - PengantarAlgorithm & Data Structure - Pengantar
Algorithm & Data Structure - Pengantar
 
Object Oriented Programming - Value Types & Reference Types
Object Oriented Programming - Value Types & Reference TypesObject Oriented Programming - Value Types & Reference Types
Object Oriented Programming - Value Types & Reference Types
 
Object Oriented Programming - Inheritance
Object Oriented Programming - InheritanceObject Oriented Programming - Inheritance
Object Oriented Programming - Inheritance
 
Object Oriented Programming - File Input & Output
Object Oriented Programming - File Input & OutputObject Oriented Programming - File Input & Output
Object Oriented Programming - File Input & Output
 
Object Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & DestructorsObject Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & Destructors
 
Object Oriented Programming - Abstraction & Encapsulation
Object Oriented Programming - Abstraction & EncapsulationObject Oriented Programming - Abstraction & Encapsulation
Object Oriented Programming - Abstraction & Encapsulation
 
Web Programming Syaria - Pengenalan Halaman Web
Web Programming Syaria - Pengenalan Halaman WebWeb Programming Syaria - Pengenalan Halaman Web
Web Programming Syaria - Pengenalan Halaman Web
 
Web Programming Syaria - PHP
Web Programming Syaria - PHPWeb Programming Syaria - PHP
Web Programming Syaria - PHP
 
Software Project Management - Project Management Knowledge
Software Project Management - Project Management KnowledgeSoftware Project Management - Project Management Knowledge
Software Project Management - Project Management Knowledge
 
Software Project Management - Proses Manajemen Proyek
Software Project Management - Proses Manajemen ProyekSoftware Project Management - Proses Manajemen Proyek
Software Project Management - Proses Manajemen Proyek
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Rendering XML Document

  • 1. Q5M1 - XML Dudy Fathan Ali S.Kom Rendering XML Document Q5M1 - XML Dudy Fathan Ali, S.Kom (DFA) 2015 CEP - CCIT Fakultas Teknik Universitas Indonesia
  • 2. Objectives Q5M1 - XML Dudy Fathan Ali S.Kom In this session, you will learn to: Transform an XML document through a Cascading Style Sheet Transform an XML document through Extensible Style Sheet Language
  • 3. Introducing Cascading Style Sheet Q5M1 - XML Dudy Fathan Ali S.Kom A CSS is a text file containing one or more rules or definitions for the style characteristics of a particular element. It controls how tags are formatted in XML and HTML documents. The CSS file can be included in XML documents with the same data structure.
  • 4. Creating CSS Q5M1 - XML Dudy Fathan Ali S.Kom The syntax for coding a CSS is: elementname { property1: value; property2: value; } elementname specifies the name of the element.
  • 5. Creating CSS Q5M1 - XML Dudy Fathan Ali S.Kom The syntax for coding a CSS is: elementname { property1: value; property2: value; } property1 and property2 specify the property names, such as font-family, font-size, and color
  • 6. Creating CSS Q5M1 - XML Dudy Fathan Ali S.Kom The syntax for coding a CSS is: elementname { property1: value; property2: value; } value specifies the property values for a property name. For example, to display the film title in red, you can type the following code in a CSS file: FILM {COLOR: RED}
  • 7. Applying CSS Q5M1 - XML Dudy Fathan Ali S.Kom A CSS can be applied to an XML document using the following syntax: <?xml:stylesheet type="text/css" href="path-name"?> Instructs the browser that the XML document uses a stylesheet.
  • 8. Applying CSS Q5M1 - XML Dudy Fathan Ali S.Kom A CSS can be applied to an XML document using the following syntax: <?xml:stylesheet type="text/css" href="path-name"?> Specifies the type of formatting that is being used.
  • 9. Applying CSS Q5M1 - XML Dudy Fathan Ali S.Kom A CSS can be applied to an XML document using the following syntax: <?xml:stylesheet type="text/css" href="path-name"?> Specifies the name of the CSS file used to format the XML document.
  • 10. Demo: Creating a CSS Q5M1 - XML Dudy Fathan Ali S.Kom Problem Statement: Jim, the XML developer at CyberShoppe, has been asked to display the product details for Cybershoppe in a browser in the following format: The price per unit, description, and quantity on hand for each product should be displayed in teal, with a font size of 10 pts. The product name should be displayed in red, with a font size of 20 pts. It should be displayed in bold. All details should be displayed in the Arial font.
  • 11. Introducing XSL Q5M1 - XML Dudy Fathan Ali S.Kom CSS does not support the reorder, sort, and display of elements based on a condition. For such advanced formatting, XML supports Extensible Style Sheet Language (XSL). XSL has two parts: XSL Transformations (XSLT) XML Path (XPath) XSL: Contains instructions on how an XML document should be transformed into an HTML or an XHTML document. Uses XPath expressions to extract specific data from an XML document. The XSLT processor transforms the XML document into an HTML or XHTML or into another XML document.
  • 12. Analyzing the Working of the XSLT Processor Q5M1 - XML Dudy Fathan Ali S.Kom The XSLT processor applies the transformation information to the source document and builds the result tree as shown in the following figure. MSXML Parser XSLT tree XSLT processor Source tree Result tree XSLT style sheet XML document
  • 13. Formatting Data Using XSLT Q5M1 - XML Dudy Fathan Ali S.Kom XSLT provides the following elements to select and format data: stylesheet value-of for-each sort text
  • 14. Formatting Data Using XSLT Q5M1 - XML Dudy Fathan Ali S.Kom XSLT provides the following elements to select and format data: stylesheet value-of for-each sort text Instructs the browser that the document is a style sheet file. Is the root element for all XSLT style sheets. Is written as: <xsl:stylesheet xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" version="1.0">
  • 15. Formatting Data Using XSLT Q5M1 - XML Dudy Fathan Ali S.Kom XSLT provides the following elements to select and format data: stylesheet value-of for-each sort text Displays the value of the specified element or attribute. Follows the syntax: <xsl:value-of select="elementname/attributename“ />
  • 16. Formatting Data Using XSLT Q5M1 - XML Dudy Fathan Ali S.Kom XSLT provides the following elements to select and format data: stylesheet value-of for-each sort text Instructs the XSLT processor to process the information for each instance of the specified pattern. Follows the syntax: <xsl:for-each select="pattern"> [action to be performed] </xsl:for-each>
  • 17. Formatting Data Using XSLT Q5M1 - XML Dudy Fathan Ali S.Kom XSLT provides the following elements to select and format data: stylesheet value-of for-each sort text Sorts data based on the values assigned to elements and attributes. Follows the syntax: <xsl:sort select="expression" order="ascending | descending" case-order="upper-first | lower-first“ data-type="text | number | qname"/>
  • 18. Formatting Data Using XSLT Q5M1 - XML Dudy Fathan Ali S.Kom XSLT provides the following elements to select and format data: stylesheet value-of for-each sort text Generates constant text in the output and displays labels. Follows the syntax: <xsl:text> Text to be displayed as label </xsl:text>
  • 19. Creating XSLT Template Rules Q5M1 - XML Dudy Fathan Ali S.Kom A template rule: Describes how an XML element and its contents are converted into a specific format for displaying in the browser. Consists of two parts: A pattern that identifies an XML element in an XML document. An action or processing code that details the transformation and rendering of the resulting element. XSLT uses two main elements for creating template rules: template apply-templates
  • 20. Creating XSLT Template Rules Q5M1 - XML Dudy Fathan Ali S.Kom A template rule: Describes how an XML element and its contents are converted into a specific format for displaying in the browser. Consists of two parts: A pattern that identifies an XML element in an XML document. An action or processing code that details the transformation and rendering of the resulting element. XSLT uses two main elements for creating template rules: template apply-templates Defines a template for the desired output. Follows the syntax: <xsl:template match="pattern"> [action to be taken] </xsl:template>
  • 21. Creating XSLT Template Rules Q5M1 - XML Dudy Fathan Ali S.Kom A template rule: Describes how an XML element and its contents are converted into a specific format for displaying in the browser. Consists of two parts: A pattern that identifies an XML element in an XML document. An action or processing code that details the transformation and rendering of the resulting element. XSLT uses two main elements for creating template rules: template apply-templates Instructs the XSLT processor to find an appropriate template and perform the specified tasks on selected elements. Follows the syntax: <xsl:apply-templates [select="pattern"]>
  • 22. Demo: Creating an XSLT Style Sheet to Format Data Q5M1 - XML Dudy Fathan Ali S.Kom Problem Statement: CyberShoppe needs to display product details, such as product ID, name, and price per unit. The following figure depicts a sample output. The details about the products should be displayed in red.
  • 23. Q5M1 - XML Dudy Fathan Ali S.Kom Thank You! Dudy Fathan Ali S.Kom dudy.fathan@eng.ui.ac.id