SlideShare a Scribd company logo
Departamento de Informática – UFV- Brasil




XML em Aplicações e-Business
   - Módulo 5: Folhas de Estilo XSL



           Vinci Pegoretti Amorim

           vinci_amorim@yahoo.com.br
   http://www.javablogs.com.br/blogs/page/Vinci
XML + HTML + XSLT


  XML            XSL




        Parser




        HTML
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<xsl:stylesheet
  xmlns:xsl=quot;http://www.w3.org/1999/XSL/Transformquot;
  version=quot;1.0quot;>
  <xsl:output
     method=quot;htmlquot;
     encoding=quot;utf-8quot;
     indent=quot;yesquot;/>

  <xsl:template match=quot;/quot;>
  <html>
    <body>
       <xsl:for-each select=quot;/faqs/faqquot;>
            <h3>
               <xsl:value-of select=quot;perguntaquot;/>
            </h3>
               <xsl:value-of select=quot;respostaquot;/>
         </xsl:for-each>
      </body>
  </html>
  </xsl:template>
</xsl:stylesheet>
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<xsl:stylesheet
  xmlns:xsl=quot;http://www.w3.org/1999/XSL/Transformquot;
  version=quot;1.0quot;>
  <xsl:output
     method=quot;htmlquot;
     encoding=quot;utf-8quot;
     indent=quot;yesquot;/>
  <xsl:template match=quot;/quot;>
  <html>
    <body>
       <xsl:for-each   select=quot;/faqs/faqquot;>
            <h3>
               <xsl:value-of   select=quot;perguntaquot;/>
            </h3>
               <xsl:value-of   select=quot;respostaquot;/>
         </xsl:for-each>
      </body>
  </html>
  </xsl:template>
</xsl:stylesheet>
XSL :: XPath
●   Indica caminhos
●   Indica quais as partes serão tratadas
    pelas folhas de estilo
XSL :: XPath :: Exemplos



<?xml version=”1.0”?>
<faqs assunto=”xml”>
 <faq cod=”2”>
     <pergunta>O que é XML?</pergunta>
     <resposta>Uma fábrica de linguagens</resposta>
 </faq>
 <faq cod=“1”>
     <pergunta>O que significa a sigla XML?</pergunta>
     <resposta>Extensible Markup Language</resposta>
 </faq>
</faqs>
XSL :: XPath :: Exemplos
   /faqs                 Contexto: /



<?xml version=”1.0”?>
<faqs assunto=”xml”>
 <faq cod=”2”>
     <pergunta>O que é XML?</pergunta>
     <resposta>Uma fábrica de linguagens</resposta>
 </faq>
 <faq cod=“1”>
     <pergunta>O que significa a sigla XML?</pergunta>
     <resposta>Extensible Markup Language</resposta>
 </faq>
</faqs>
XSL :: XPath :: Exemplos
   /faqs@assunto                 Contexto:/



<?xml version=”1.0”?>
<faqs assunto=”xml”>
 <faq cod=”2”>
     <pergunta>O que é XML?</pergunta>
     <resposta>Uma fábrica de linguagens</resposta>
 </faq>
 <faq cod=“1”>
     <pergunta>O que significa a sigla XML?</pergunta>
     <resposta>Extensible Markup Language</resposta>
 </faq>
</faqs>
XSL :: XPath :: Exemplos
   /faqs/faq[2]                  Contexto: /



<?xml version=”1.0”?>
<faqs assunto=”xml”>
 <faq cod=”2”>
     <pergunta>O que é XML?</pergunta>
     <resposta>Uma fábrica de linguagens</resposta>
 </faq>
 <faq cod=“1”>
     <pergunta>O que significa a sigla XML?</pergunta>
     <resposta>Extensible Markup Language</resposta>
 </faq>
</faqs>
XSL :: XPath :: Exemplos
   /faqs/faq[position() < @cod] Contexto: /



<?xml version=”1.0”?>
<faqs assunto=”xml”>
 <faq cod=”2”>
     <pergunta>O que é XML?</pergunta>
     <resposta>Uma fábrica de linguagens</resposta>
 </faq>
 <faq cod=“1”>
     <pergunta>O que significa a sigla XML?</pergunta>
     <resposta>Extensible Markup Language</resposta>
 </faq>
</faqs>
XSL :: XPath :: Exemplos
   /faqs/faq/pergunta      Contexto: /



<?xml version=”1.0”?>
<faqs assunto=”xml”>
 <faq cod=”2”>
     <pergunta>O que é XML?</pergunta>
     <resposta>Uma fábrica de linguagens</resposta>
 </faq>
 <faq cod=“1”>
     <pergunta>O que significa a sigla XML?</pergunta>
     <resposta>Extensible Markup Language</resposta>
 </faq>
</faqs>
XSL :: XPath :: Exemplos
   .          Contexto: /faqs/faq[1]/pergunta



<?xml version=”1.0”?>
<faqs assunto=”xml”>
 <faq cod=”2”>
     <pergunta>O que é XML?</pergunta>
     <resposta>Uma fábrica de linguagens</resposta>
 </faq>
 <faq cod=“1”>
     <pergunta>O que significa a sigla XML?</pergunta>
     <resposta>Extensible Markup Language</resposta>
 </faq>
</faqs>
XSL :: XPath :: Exemplos
   ..            Contexto: /faqs/faq[1]/pergunta



<?xml version=”1.0”?>
<faqs assunto=”xml”>
 <faq cod=”2”>
     <pergunta>O que é XML?</pergunta>
     <resposta>Uma fábrica de linguagens</resposta>
 </faq>
 <faq cod=“1”>
     <pergunta>O que significa a sigla XML?</pergunta>
     <resposta>Extensible Markup Language</resposta>
 </faq>
</faqs>
XSL :: XPath :: Exemplos
   ../resposta Contexto: /faqs/faq[1]/pergunta



<?xml version=”1.0”?>
<faqs assunto=”xml”>
 <faq cod=”2”>
     <pergunta>O que é XML?</pergunta>
     <resposta>Uma fábrica de linguagens</resposta>
 </faq>
 <faq cod=“1”>
     <pergunta>O que significa a sigla XML?</pergunta>
     <resposta>Extensible Markup Language</resposta>
 </faq>
</faqs>
XSL :: XPath :: Exemplos
   faq[2]/pergunta | faq[1]/resposta
                               Contexto: /faqs

<?xml version=”1.0”?>
<faqs assunto=”xml”>
 <faq cod=”2”>
     <pergunta>O que é XML?</pergunta>
     <resposta>Uma fábrica de linguagens</resposta>
 </faq>
 <faq cod=“1”>
     <pergunta>O que significa a sigla XML?</pergunta>
     <resposta>Extensible Markup Language</resposta>
 </faq>
</faqs>
XSL :: XPath :: Sintaxe
●   Indentifica os nodos na forma
/nodo_raiz/filhos/filhos_dos_filhos_da_raiz
●   O início com / indica caminho absoluto
●   O . indica o nodo atual, .. indica o nodo pai
    do atual
●   elemento@nome_do_atributo
●
    elemento[n]
●   elemento[@atributo = valor]
●   position()
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<xsl:stylesheet
  xmlns:xsl=quot;http://www.w3.org/1999/XSL/Transformquot;
  version=quot;1.0quot;>
  <xsl:output
     method=quot;htmlquot;
     encoding=quot;utf-8quot;
     indent=quot;yesquot;/>

  <xsl:template match=quot;/quot;>
  <html>
    <body>
       <xsl:for-each select=quot;/faqs/faqquot;>
            <h3>
               <xsl:value-of select=quot;perguntaquot;/>
            </h3>
               <xsl:value-of select=quot;respostaquot;/>
         </xsl:for-each>
      </body>
  </html>
  </xsl:template>
</xsl:stylesheet>
XSL :: XSLT
<xsl:stylesheet xmlns:xsl=quot;http:// ...quot;
 version=quot;1.0quot;>
<xsl:output method=quot;xml | html | txtquot;>
<xsl:template match=quot;/xpathquot;>
<xsl:for-each select=quot;/xpathquot;>
<xsl:value-of select=quot;/xpathquot;/>
<xsl:if test=quot;expressãoquot;>
<xsl:include href=quot;filequot;/>
<xsl:apply-templates/>
<xsl:element>
<xsl:attribute>
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<xsl:stylesheet
  xmlns:xsl=quot;http://www.w3.org/1999/XSL/Transformquot;
  version=quot;1.0quot;>
  <xsl:output
     method=quot;htmlquot;
     encoding=quot;utf-8quot;
     indent=quot;yesquot;/>
   <xsl:include href=quot;link.xslquot;/>
  <xsl:template match=quot;/quot;>
  <html>
    <body>
        <xsl:apply-templates/>
      </body>
  </html>
  </xsl:template>
</xsl:stylesheet>
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?>
<xsl:stylesheet
  xmlns:xsl=quot;http://www.w3.org/1999/XSL/Transformquot;
  version=quot;1.0quot;>

  <xsl:template match=quot;/faqs/faqquot;>
       <xsl:element name=quot;aquot;>

          <xsl:attribute name=quot;hrefquot;>
               http://www.xml.com
          </xsl:attribute>
          <xsl:value-of select=quot;pergunta[1]quot;/>

        </xsl:element>
  </xsl:template>

</xsl:stylesheet>
Saxon


java -jar saxon8.jar -o a.html a.xml a.xsl
<html>
   <body>
     <a href=”http://www.xml.com“>
       O que é XML?
     </a>
   </body>
</html>
XSL :: Importância
●
    Agregação
●
    Desagregação
●   Filtragem
●   Reordenação e restruturação
●   Uma fonte, várias apresentações
●   Várias fontes, uma apresentação
●   Formatação para cada dispositivo
    específico

More Related Content

Viewers also liked

Python, RaspberryPi, Arduinoで作る消費電力モニタリングシステム
Python, RaspberryPi, Arduinoで作る消費電力モニタリングシステムPython, RaspberryPi, Arduinoで作る消費電力モニタリングシステム
Python, RaspberryPi, Arduinoで作る消費電力モニタリングシステム
Junichi Kakisako
 
XML Metadata Interchange (XMI)
XML Metadata Interchange (XMI)XML Metadata Interchange (XMI)
XML Metadata Interchange (XMI)
elliando dias
 
RMI Fundamentals
RMI FundamentalsRMI Fundamentals
RMI Fundamentals
elliando dias
 
Administração de Sistema Unix
Administração de Sistema UnixAdministração de Sistema Unix
Administração de Sistema Unix
elliando dias
 
The Future of CSS
The Future of CSSThe Future of CSS
The Future of CSS
elliando dias
 
RMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolsRMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable tools
elliando dias
 
Micro-python
Micro-python Micro-python
Micro-python
Samuel de Ancos
 
Learn Working of Accelerometer using Micro Python
Learn Working of Accelerometer using Micro PythonLearn Working of Accelerometer using Micro Python
Learn Working of Accelerometer using Micro Python
Rengaraj D
 
Build Your Own Multi-Touch Interface with Java and JavaFX Technology
Build Your Own Multi-Touch Interface with Java and JavaFX TechnologyBuild Your Own Multi-Touch Interface with Java and JavaFX Technology
Build Your Own Multi-Touch Interface with Java and JavaFX Technology
elliando dias
 
組み込みスクリプト言語Mrubyを利用したwebサーバの機能拡張支援機構
組み込みスクリプト言語Mrubyを利用したwebサーバの機能拡張支援機構組み込みスクリプト言語Mrubyを利用したwebサーバの機能拡張支援機構
組み込みスクリプト言語Mrubyを利用したwebサーバの機能拡張支援機構
Ryosuke MATSUMOTO
 
軽量Ruby『mruby』について
軽量Ruby『mruby』について軽量Ruby『mruby』について
軽量Ruby『mruby』について
Ryosuke MATSUMOTO
 
L'homme heureux (les bonnes manières)
L'homme heureux (les bonnes manières)L'homme heureux (les bonnes manières)
L'homme heureux (les bonnes manières)123francese
 
Damien George - Micro Python - CIUUK14
Damien George - Micro Python - CIUUK14Damien George - Micro Python - CIUUK14
Damien George - Micro Python - CIUUK14
Daniel Lewis
 
Distributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMIDistributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMI
elliando dias
 
「mruby/c」の利用期待分野~M2Mでの利用~160726
「mruby/c」の利用期待分野~M2Mでの利用~160726「mruby/c」の利用期待分野~M2Mでの利用~160726
「mruby/c」の利用期待分野~M2Mでの利用~160726
shimane-itoc
 
M2M製品開発におけるmrubyの効果160726
M2M製品開発におけるmrubyの効果160726M2M製品開発におけるmrubyの効果160726
M2M製品開発におけるmrubyの効果160726
shimane-itoc
 
Xerrada CRP Garraf -presentació 1
Xerrada CRP Garraf -presentació 1Xerrada CRP Garraf -presentació 1
Xerrada CRP Garraf -presentació 1
martap
 
Xerrada tertúlia sobre blogs
Xerrada tertúlia sobre blogsXerrada tertúlia sobre blogs
Xerrada tertúlia sobre blogs
Xerraires .net
 
X Gripe A Grp9
X Gripe A Grp9X Gripe A Grp9
X Gripe A Grp9
ac8cgrp9
 

Viewers also liked (20)

Python, RaspberryPi, Arduinoで作る消費電力モニタリングシステム
Python, RaspberryPi, Arduinoで作る消費電力モニタリングシステムPython, RaspberryPi, Arduinoで作る消費電力モニタリングシステム
Python, RaspberryPi, Arduinoで作る消費電力モニタリングシステム
 
XML Metadata Interchange (XMI)
XML Metadata Interchange (XMI)XML Metadata Interchange (XMI)
XML Metadata Interchange (XMI)
 
RMI Fundamentals
RMI FundamentalsRMI Fundamentals
RMI Fundamentals
 
Administração de Sistema Unix
Administração de Sistema UnixAdministração de Sistema Unix
Administração de Sistema Unix
 
The Future of CSS
The Future of CSSThe Future of CSS
The Future of CSS
 
RMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolsRMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable tools
 
Micro-python
Micro-python Micro-python
Micro-python
 
Learn Working of Accelerometer using Micro Python
Learn Working of Accelerometer using Micro PythonLearn Working of Accelerometer using Micro Python
Learn Working of Accelerometer using Micro Python
 
Build Your Own Multi-Touch Interface with Java and JavaFX Technology
Build Your Own Multi-Touch Interface with Java and JavaFX TechnologyBuild Your Own Multi-Touch Interface with Java and JavaFX Technology
Build Your Own Multi-Touch Interface with Java and JavaFX Technology
 
組み込みスクリプト言語Mrubyを利用したwebサーバの機能拡張支援機構
組み込みスクリプト言語Mrubyを利用したwebサーバの機能拡張支援機構組み込みスクリプト言語Mrubyを利用したwebサーバの機能拡張支援機構
組み込みスクリプト言語Mrubyを利用したwebサーバの機能拡張支援機構
 
軽量Ruby『mruby』について
軽量Ruby『mruby』について軽量Ruby『mruby』について
軽量Ruby『mruby』について
 
L'homme heureux (les bonnes manières)
L'homme heureux (les bonnes manières)L'homme heureux (les bonnes manières)
L'homme heureux (les bonnes manières)
 
Damien George - Micro Python - CIUUK14
Damien George - Micro Python - CIUUK14Damien George - Micro Python - CIUUK14
Damien George - Micro Python - CIUUK14
 
Distributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMIDistributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMI
 
「mruby/c」の利用期待分野~M2Mでの利用~160726
「mruby/c」の利用期待分野~M2Mでの利用~160726「mruby/c」の利用期待分野~M2Mでの利用~160726
「mruby/c」の利用期待分野~M2Mでの利用~160726
 
M2M製品開発におけるmrubyの効果160726
M2M製品開発におけるmrubyの効果160726M2M製品開発におけるmrubyの効果160726
M2M製品開発におけるmrubyの効果160726
 
Xerrada CRP Garraf -presentació 1
Xerrada CRP Garraf -presentació 1Xerrada CRP Garraf -presentació 1
Xerrada CRP Garraf -presentació 1
 
Xerrada tertúlia sobre blogs
Xerrada tertúlia sobre blogsXerrada tertúlia sobre blogs
Xerrada tertúlia sobre blogs
 
Xkt presentation 2012 en
Xkt presentation 2012   enXkt presentation 2012   en
Xkt presentation 2012 en
 
X Gripe A Grp9
X Gripe A Grp9X Gripe A Grp9
X Gripe A Grp9
 

More from elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
elliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
elliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
elliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
elliando dias
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
elliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
elliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
elliando dias
 
Ragel talk
Ragel talkRagel talk
Ragel talk
elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
elliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
elliando dias
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
elliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
elliando dias
 
Rango
RangoRango
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
elliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
elliando dias
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
elliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
elliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
elliando dias
 

More from elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

XML em Aplicações e-Business

  • 1. Departamento de Informática – UFV- Brasil XML em Aplicações e-Business - Módulo 5: Folhas de Estilo XSL Vinci Pegoretti Amorim vinci_amorim@yahoo.com.br http://www.javablogs.com.br/blogs/page/Vinci
  • 2. XML + HTML + XSLT XML XSL Parser HTML
  • 3. <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <xsl:stylesheet xmlns:xsl=quot;http://www.w3.org/1999/XSL/Transformquot; version=quot;1.0quot;> <xsl:output method=quot;htmlquot; encoding=quot;utf-8quot; indent=quot;yesquot;/> <xsl:template match=quot;/quot;> <html> <body> <xsl:for-each select=quot;/faqs/faqquot;> <h3> <xsl:value-of select=quot;perguntaquot;/> </h3> <xsl:value-of select=quot;respostaquot;/> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
  • 4. <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <xsl:stylesheet xmlns:xsl=quot;http://www.w3.org/1999/XSL/Transformquot; version=quot;1.0quot;> <xsl:output method=quot;htmlquot; encoding=quot;utf-8quot; indent=quot;yesquot;/> <xsl:template match=quot;/quot;> <html> <body> <xsl:for-each select=quot;/faqs/faqquot;> <h3> <xsl:value-of select=quot;perguntaquot;/> </h3> <xsl:value-of select=quot;respostaquot;/> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
  • 5. XSL :: XPath ● Indica caminhos ● Indica quais as partes serão tratadas pelas folhas de estilo
  • 6. XSL :: XPath :: Exemplos <?xml version=”1.0”?> <faqs assunto=”xml”> <faq cod=”2”> <pergunta>O que é XML?</pergunta> <resposta>Uma fábrica de linguagens</resposta> </faq> <faq cod=“1”> <pergunta>O que significa a sigla XML?</pergunta> <resposta>Extensible Markup Language</resposta> </faq> </faqs>
  • 7. XSL :: XPath :: Exemplos /faqs Contexto: / <?xml version=”1.0”?> <faqs assunto=”xml”> <faq cod=”2”> <pergunta>O que é XML?</pergunta> <resposta>Uma fábrica de linguagens</resposta> </faq> <faq cod=“1”> <pergunta>O que significa a sigla XML?</pergunta> <resposta>Extensible Markup Language</resposta> </faq> </faqs>
  • 8. XSL :: XPath :: Exemplos /faqs@assunto Contexto:/ <?xml version=”1.0”?> <faqs assunto=”xml”> <faq cod=”2”> <pergunta>O que é XML?</pergunta> <resposta>Uma fábrica de linguagens</resposta> </faq> <faq cod=“1”> <pergunta>O que significa a sigla XML?</pergunta> <resposta>Extensible Markup Language</resposta> </faq> </faqs>
  • 9. XSL :: XPath :: Exemplos /faqs/faq[2] Contexto: / <?xml version=”1.0”?> <faqs assunto=”xml”> <faq cod=”2”> <pergunta>O que é XML?</pergunta> <resposta>Uma fábrica de linguagens</resposta> </faq> <faq cod=“1”> <pergunta>O que significa a sigla XML?</pergunta> <resposta>Extensible Markup Language</resposta> </faq> </faqs>
  • 10. XSL :: XPath :: Exemplos /faqs/faq[position() < @cod] Contexto: / <?xml version=”1.0”?> <faqs assunto=”xml”> <faq cod=”2”> <pergunta>O que é XML?</pergunta> <resposta>Uma fábrica de linguagens</resposta> </faq> <faq cod=“1”> <pergunta>O que significa a sigla XML?</pergunta> <resposta>Extensible Markup Language</resposta> </faq> </faqs>
  • 11. XSL :: XPath :: Exemplos /faqs/faq/pergunta Contexto: / <?xml version=”1.0”?> <faqs assunto=”xml”> <faq cod=”2”> <pergunta>O que é XML?</pergunta> <resposta>Uma fábrica de linguagens</resposta> </faq> <faq cod=“1”> <pergunta>O que significa a sigla XML?</pergunta> <resposta>Extensible Markup Language</resposta> </faq> </faqs>
  • 12. XSL :: XPath :: Exemplos . Contexto: /faqs/faq[1]/pergunta <?xml version=”1.0”?> <faqs assunto=”xml”> <faq cod=”2”> <pergunta>O que é XML?</pergunta> <resposta>Uma fábrica de linguagens</resposta> </faq> <faq cod=“1”> <pergunta>O que significa a sigla XML?</pergunta> <resposta>Extensible Markup Language</resposta> </faq> </faqs>
  • 13. XSL :: XPath :: Exemplos .. Contexto: /faqs/faq[1]/pergunta <?xml version=”1.0”?> <faqs assunto=”xml”> <faq cod=”2”> <pergunta>O que é XML?</pergunta> <resposta>Uma fábrica de linguagens</resposta> </faq> <faq cod=“1”> <pergunta>O que significa a sigla XML?</pergunta> <resposta>Extensible Markup Language</resposta> </faq> </faqs>
  • 14. XSL :: XPath :: Exemplos ../resposta Contexto: /faqs/faq[1]/pergunta <?xml version=”1.0”?> <faqs assunto=”xml”> <faq cod=”2”> <pergunta>O que é XML?</pergunta> <resposta>Uma fábrica de linguagens</resposta> </faq> <faq cod=“1”> <pergunta>O que significa a sigla XML?</pergunta> <resposta>Extensible Markup Language</resposta> </faq> </faqs>
  • 15. XSL :: XPath :: Exemplos faq[2]/pergunta | faq[1]/resposta Contexto: /faqs <?xml version=”1.0”?> <faqs assunto=”xml”> <faq cod=”2”> <pergunta>O que é XML?</pergunta> <resposta>Uma fábrica de linguagens</resposta> </faq> <faq cod=“1”> <pergunta>O que significa a sigla XML?</pergunta> <resposta>Extensible Markup Language</resposta> </faq> </faqs>
  • 16. XSL :: XPath :: Sintaxe ● Indentifica os nodos na forma /nodo_raiz/filhos/filhos_dos_filhos_da_raiz ● O início com / indica caminho absoluto ● O . indica o nodo atual, .. indica o nodo pai do atual ● elemento@nome_do_atributo ● elemento[n] ● elemento[@atributo = valor] ● position()
  • 17. <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <xsl:stylesheet xmlns:xsl=quot;http://www.w3.org/1999/XSL/Transformquot; version=quot;1.0quot;> <xsl:output method=quot;htmlquot; encoding=quot;utf-8quot; indent=quot;yesquot;/> <xsl:template match=quot;/quot;> <html> <body> <xsl:for-each select=quot;/faqs/faqquot;> <h3> <xsl:value-of select=quot;perguntaquot;/> </h3> <xsl:value-of select=quot;respostaquot;/> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
  • 18. XSL :: XSLT <xsl:stylesheet xmlns:xsl=quot;http:// ...quot; version=quot;1.0quot;> <xsl:output method=quot;xml | html | txtquot;> <xsl:template match=quot;/xpathquot;> <xsl:for-each select=quot;/xpathquot;> <xsl:value-of select=quot;/xpathquot;/> <xsl:if test=quot;expressãoquot;> <xsl:include href=quot;filequot;/> <xsl:apply-templates/> <xsl:element> <xsl:attribute>
  • 19. <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <xsl:stylesheet xmlns:xsl=quot;http://www.w3.org/1999/XSL/Transformquot; version=quot;1.0quot;> <xsl:output method=quot;htmlquot; encoding=quot;utf-8quot; indent=quot;yesquot;/> <xsl:include href=quot;link.xslquot;/> <xsl:template match=quot;/quot;> <html> <body> <xsl:apply-templates/> </body> </html> </xsl:template> </xsl:stylesheet>
  • 20. <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <xsl:stylesheet xmlns:xsl=quot;http://www.w3.org/1999/XSL/Transformquot; version=quot;1.0quot;> <xsl:template match=quot;/faqs/faqquot;> <xsl:element name=quot;aquot;> <xsl:attribute name=quot;hrefquot;> http://www.xml.com </xsl:attribute> <xsl:value-of select=quot;pergunta[1]quot;/> </xsl:element> </xsl:template> </xsl:stylesheet>
  • 21. Saxon java -jar saxon8.jar -o a.html a.xml a.xsl
  • 22. <html> <body> <a href=”http://www.xml.com“> O que é XML? </a> </body> </html>
  • 23. XSL :: Importância ● Agregação ● Desagregação ● Filtragem ● Reordenação e restruturação ● Uma fonte, várias apresentações ● Várias fontes, uma apresentação ● Formatação para cada dispositivo específico