• Like
  • Save
XML & XSLT
Upcoming SlideShare
Loading in...5
×

XML & XSLT

  • 175 views
Uploaded on

How to produce static content when you need it and update it easily through simple steps.

How to produce static content when you need it and update it easily through simple steps.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
175
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. XML & XSLT Per gestire siti statici multilanguage(quando non si può avere un sito dinamico…) Chiara Bettaglio
  • 2. PRIMA DESIGN Produzione CONTENUTI CORREZIONI REVIEWPUBLISH
  • 3. ORA CONTENUTI E CORREZIONEDESIGN PUBLISH
  • 4. I miei files! Un file Excel Uno script DOSUna cartella conFogli di stile XSL e databaseDei contenuti XML
  • 5. I miei files! I fogli di stile XSLT Un motore per I miei contenutiprocessare l’XSLT in XML Un file per le istruzioni
  • 6. XML Mini database di informazioni XSLT Foglio di stile per XML
  • 7. XSLT processor• Xalan/Xerces (Java, open source)• Saxon (Java, open source) <XSLT <XSLT• Altova XSLT Engine (C++, gratis) > >• MS XML (C++, gratis) <XML> <XML> <HTML> <HTML> XALAN
  • 8. xHTML• I tag devono essere sempre chiusi• Nomi degli attributi in minuscolo• Valori degli attributi tra virgolette• Minimizzare gli attributi è proibito• Si usa l’ID invece che l’attributo name• Il DTD XHTML definisce alcuni elementi obbligatori <td WIDTH=100% nowrap><br> <td width="100%" nowrap=“nowrap"> <br/> <image src=“img.gif“ alt=“ola!“/>
  • 9. Individuo il mio contenuto anche quello nascosto!! Testi links Path immagini! Valuta!
  • 10. Creo un master XML con il mio contenuto<?xml version="1.0" encoding="utf-8"?><page> <store></store> <campaignID></campaignID> Parametri come valuta, <spare1></spare1> <spare2></spare2> Nome campagna e } <title></title><container> il mercato di vendita <box> <image1></image1> <image2></image2> <linkText></linkText> <linkTextURL></linkTextURL> <text></text> </box> Elementi ricorrenti <box> <image1></image1> <image2></image2> <linkText></linkText> <linkTextURL></linkTextURL> <text></text> </box></container> Eventuali testi, immagini,</page> valori per attributi css
  • 11. Da XML a Excel Creo un file come fosse una maschera di inserimento dati per gli elementi che ho individuato in XML Comprende etichette e valori in inglese che i vari mercati dovranno tradurre localmente
  • 12. Mappo l’XML in Excel
  • 13. Tasto export + macroPrivate Sub Pulsante_Clic()ActiveWorkbook.XmlMaps("page_mapping").Export URL:=ThisWorkbook.Path & "bintemplate.xml", Overwrite:=TrueEnd Sub
  • 14. xHTML to XSL<table width="100%" cellpadding="0" cellspacing="0"><tr><td class="header"> <xsl:value-of select="page/homePage/LEDSlamp"/> </td></tr><tr><td class="content" style="padding:6px;"> <img src="/{$store}/img/site/campaigns/{$cp}/ {page/homePage/LEDSlampImg}" align="right"/><xsl:value-of select="page/homePage/LEDSlampTxt" disable-output- escaping="yes"/><br/><a href="{page/homePage/LEDSlampLink}"><strong><xsl:value-of select="page/homePage/LEDSlampLinkTXT"/></strong></a> </td></tr></table>
  • 15. xHTML to XSL <xsl:for-each select="page/homePage/featuredProds/box">…………………………………….</xsl:for-each><xsl:if test="CurrencyPosition = after">&nbsp;<xsl:value-of select="$currency" disable-output- escaping="no"/></xsl:if>
  • 16. Anche file di testo semplici!title= <xsl:value-of select="page/homePage/campaignTitle" />&cr;description= <xsl:value-of select="page/homePage/blurb" /> &cr;keywords= <xsl:for-each select="page/seo/keywords"> <xsl:value-of select="linkText"/>,</xsl:for-each>&cr;header=Y &cr;footer=Y &cr; file:stylesheet=style.css &cr;
  • 17. Il batch…<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> <!ENTITY copy "&#169;"> <!ENTITY reg "&#174;"> <!ENTITY trade "&#8482;"> <!ENTITY mdash "&#8212;"> <!ENTITY ldquo "&#8220;"> <!ENTITY rdquo "&#8221;"> <!ENTITY pound "&#163;"> <!ENTITY yen "&#165;"> <!ENTITY cr "<xsl:text></xsl:text>">]><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="text" encoding="utf-8"/><xsl:template match="/">………………………………………………………………………………………………………………………………………………………….</xsl:template></xsl:stylesheet>
  • 18. …con le istruzioni• java -classpath binxalan.jar;binserialiser.jar org.apache.xalan.xslt.Process -IN bintemplate.xml -XSL binhome.xsl -OUT home.html &cr;• java -classpath binxalan.jar;binserialiser.jar org.apache.xalan.xslt.Process -IN bintemplate.xml -XSL bincp.xsl -OUT campaign.txt &cr;• java -classpath binxalan.jar;binserialiser.jar org.apache.xalan.xslt.Process -IN bintemplate.xml -XSL bintext.xsl -OUT load.bat&cr;
  • 19. Non solo html… ad esempio… il load!&#62;&#62;script.ftp ECHO USERNAME &cr;&#62;&#62;script.ftp ECHO PASSWORD &cr;&#62;&#62;script.ftp ECHO ascii &cr;&#62;&#62;script.ftp ECHO CD BASE PATH DI CARICAMENTO &cr;&#62;&#62;script.ftp ECHO mkdir <xsl:value-of select="page/campaignName"/> &cr;&#62;&#62;script.ftp ECHO CD BASE PATH DI CARICAMENTO&#47;<xsl:value-of select="page/campaignName"/>&#47;&cr;FOR &#37;&#37;f in (&#42;.html, &#42;.txt, &#42;.css)do &#62;&#62;script.ftp ECHO put &#37;&#37;f&cr;&#62;&#62;script.ftp ECHO bye&cr;FTP -v -s:script.ftp INDIRIZZO FTP SERVER &cr;DEL script.ftp&cr;REM DEL &#42;.html &cr;REM DEL &#42;.txt &cr;GOTO End &cr;:End &cr;start iexplore http://MIOSITO.COM
  • 20. Il Clickme.batjava -classpath binxalan.jar;binserialiser.jar org.apache.xalan.xslt.Process -IN bintemplate.xml -XSL binbatch.xsl -OUT doAll.batcall doAll.batcall load.batdel doAll.batdel load.batdel *.htmldel *.txt
  • 21. Distribuzione alle opcoInserimento Contenuti localizzati Preview / Correzione in Excel Rerun del Template