XML em Aplicações e-Business
-
Upload
elliando-dias -
Category
Technology
-
view
1.204 -
download
0
description
Transcript of XML em Aplicações e-Business
![Page 1: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/1.jpg)
Departamento de Informática – UFV- Brasil
XML em Aplicações e-Business- Módulo 5: Folhas de Estilo XSL
Vinci Pegoretti Amorim
[email protected]://www.javablogs.com.br/blogs/page/Vinci
![Page 2: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/2.jpg)
XML + HTML + XSLT
XML XSL
Parser
HTML
![Page 3: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/3.jpg)
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output
method="html" encoding="utf-8" indent="yes"/>
<xsl:template match="/"> <html> <body> <xsl:for-each select="/faqs/faq"> <h3>
<xsl:value-of select="pergunta"/> </h3>
<xsl:value-of select="resposta"/> </xsl:for-each> </body> </html> </xsl:template></xsl:stylesheet>
![Page 4: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/4.jpg)
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output
method="html" encoding="utf-8" indent="yes"/>
<xsl:template match="/"> <html> <body>
<xsl:for-each select="/faqs/faq"> <h3>
<xsl:value-of select="pergunta"/> </h3>
<xsl:value-of select="resposta"/> </xsl:for-each> </body> </html> </xsl:template></xsl:stylesheet>
![Page 5: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/5.jpg)
● Indica caminhos ● Indica quais as partes serão tratadas pelas folhas de estilo
XSL :: XPath
![Page 6: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/6.jpg)
<?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
![Page 7: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/7.jpg)
<?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: /
![Page 8: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/8.jpg)
<?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:/
![Page 9: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/9.jpg)
<?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: /
![Page 10: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/10.jpg)
<?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: /
![Page 11: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/11.jpg)
<?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: /
![Page 12: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/12.jpg)
<?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
![Page 13: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/13.jpg)
<?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
![Page 14: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/14.jpg)
<?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
![Page 15: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/15.jpg)
<?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
![Page 16: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/16.jpg)
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()
![Page 17: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/17.jpg)
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output
method="html" encoding="utf-8" indent="yes"/>
<xsl:template match="/"> <html> <body> <xsl:for-each select="/faqs/faq"> <h3>
<xsl:value-of select="pergunta"/> </h3>
<xsl:value-of select="resposta"/> </xsl:for-each> </body> </html> </xsl:template></xsl:stylesheet>
![Page 18: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/18.jpg)
XSL :: XSLT<xsl:stylesheet xmlns:xsl="http:// ..."
version="1.0"><xsl:output method="xml | html | txt"><xsl:template match="/xpath"><xsl:for-each select="/xpath"><xsl:value-of select="/xpath"/><xsl:if test="expressão"><xsl:include href="file"/><xsl:apply-templates/><xsl:element><xsl:attribute>
![Page 19: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/19.jpg)
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output
method="html" encoding="utf-8" indent="yes"/>
<xsl:include href="link.xsl"/>
<xsl:template match="/"> <html> <body>
<xsl:apply-templates/> </body> </html> </xsl:template></xsl:stylesheet>
![Page 20: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/20.jpg)
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/faqs/faq"> <xsl:element name="a">
<xsl:attribute name="href">
http://www.xml.com</xsl:attribute>
<xsl:value-of select="pergunta[1]"/>
</xsl:element> </xsl:template>
</xsl:stylesheet>
![Page 21: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/21.jpg)
java -jar saxon8.jar -o a.html a.xml a.xsl
Saxon
![Page 22: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/22.jpg)
<html><body>
<a href=”http://www.xml.com“>O que é XML?
</a></body>
</html>
![Page 23: XML em Aplicações e-Business](https://reader035.fdocumentos.tips/reader035/viewer/2022081413/5481f59c5806b5e3048b45d1/html5/thumbnails/23.jpg)
● 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
XSL :: Importância