Xml Xls ed Excel per la produzione espressa di Html - Chiara Bettaglio

1,392 views
1,306 views

Published on

Presentazione alla Girl Geek Dinner #12 di Milano, una serata dedicata all'How to in formato Ignite

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,392
On SlideShare
0
From Embeds
0
Number of Embeds
84
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Xml Xls ed Excel per la produzione espressa di Html - Chiara Bettaglio

  1. 1. di Chiara Bettaglio RS Component GGD #12 – 14 maggio 2010 Xml Xls ed Excel per la produzione espressa di Html
  2. 2. PRIMA CONTENUTI DESIGN Produzione REVIEW CORREZIONI PUBLISH
  3. 3. ORA DESIGN CONTENUTI E CORREZIONE PUBLISH
  4. 4. I miei files! Uno script DOS Un file Excel Una cartella con Fogli di stile XSL e database Dei contenuti XML
  5. 5. I miei files! Un motore per processare l’XSLT I fogli di stile XSLT I miei contenuti in XML Un file per le istruzioni
  6. 6. XML <ul><li>Mini database di informazioni </li></ul>XSLT Foglio di stile per XML
  7. 7. XSLT processor <ul><li>Xalan/Xerces (Java, open source) </li></ul><ul><li>Saxon (Java, open source) </li></ul><ul><li>Altova XSLT Engine (C++, gratis) </li></ul><ul><li>MS XML (C++, gratis) </li></ul><XML> <XSLT> XALAN <HTML>
  8. 8. xHTML <ul><li>I tag devono essere sempre chiusi </li></ul><ul><li>Nomi degli attributi in minuscolo </li></ul><ul><li>Valori degli attributi tra virgolette </li></ul><ul><li>Minimizzare gli attributi è proibito </li></ul><ul><li>Si usa l’ ID invece che l’attributo name </li></ul><ul><li>Il DTD XHTML definisce alcuni elementi obbligatori </li></ul><td WIDTH=100% nowrap><br> <td width=&quot;100%&quot; nowrap=“nowrap&quot;> <br/> <image src =“img.gif“ alt=“ola!“/>
  9. 9. Individuo il mio contenuto Testi links Valuta! Path immagini! anche quello nascosto!!
  10. 10. Creo un master XML con il mio contenuto <ul><li><?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> </li></ul><ul><li><page> </li></ul><ul><li><store></store> </li></ul><ul><li><campaignID></campaignID> </li></ul><ul><li><spare1></spare1> </li></ul><ul><li><spare2></spare2> </li></ul><ul><li><title></title> </li></ul><ul><li><container> </li></ul><ul><li><box> </li></ul><ul><li><image1></image1> </li></ul><ul><li><image2></image2> </li></ul><ul><li><linkText></linkText> </li></ul><ul><li><linkTextURL></linkTextURL> </li></ul><ul><li><text></text> </li></ul><ul><li></box> </li></ul><ul><li><box> </li></ul><ul><li><image1></image1> </li></ul><ul><li><image2></image2> </li></ul><ul><li><linkText></linkText> </li></ul><ul><li><linkTextURL></linkTextURL> </li></ul><ul><li><text></text> </li></ul><ul><li></box> </li></ul><ul><li></container> </li></ul><ul><li></page> </li></ul>Elementi ricorrenti } Parametri come valuta, Nome campagna e il mercato di vendita Eventuali testi, immagini, valori per attributi css
  11. 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. 12. Mappo l’XML in Excel
  13. 13. Tasto export + macro Private Sub Pulsante_Clic() ActiveWorkbook.XmlMaps(&quot;page_mapping&quot;).Export URL:= ThisWorkbook.Path & &quot;in emplate.xml&quot;, Overwrite:=True End Sub
  14. 14. xHTML to XSL <ul><li><table width=&quot;100%&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;> </li></ul><ul><li><tr><td class=&quot;header&quot;> <xsl:value-of select=&quot;page/homePage/LEDSlamp&quot;/> </td></tr> </li></ul><ul><li><tr><td class=&quot;content&quot; style=&quot;padding:6px;&quot;> </li></ul><ul><li><img src=&quot;/ {$store} /img/site/campaigns/ {$cp} / {page/homePage/LEDSlampImg} &quot; align=&quot;right&quot;/> </li></ul><ul><li><xsl:value-of select=&quot;page/homePage/LEDSlampTxt&quot; disable-output-escaping=&quot;yes&quot;/> <br/> </li></ul><ul><li><a href=&quot;{page/homePage/LEDSlampLink}&quot;> </li></ul><ul><li><strong><xsl:value-of select=&quot;page/homePage/LEDSlampLinkTXT&quot;/></strong></a> </td></tr></table> </li></ul>
  15. 15. xHTML to XSL <ul><li><xsl:for-each select=&quot;page/homePage/featuredProds/box&quot;> </li></ul><ul><li>…………………………………… . </li></ul><ul><li></xsl:for-each> </li></ul><ul><li><xsl:if test=&quot;CurrencyPosition = 'after'&quot;> </li></ul><ul><li>&nbsp;<xsl:value-of select=&quot;$currency&quot; disable-output-escaping=&quot;no&quot;/> </li></ul><ul><li></xsl:if> </li></ul>
  16. 16. Anche file di testo semplici! <ul><li>title= <xsl:value-of select=&quot;page/homePage/campaignTitle&quot; />&cr; </li></ul><ul><li>description= <xsl:value-of select=&quot;page/homePage/blurb&quot; /> &cr; </li></ul><ul><li>keywords= < xsl:for-each select=&quot;page/seo/keywords &quot;> </li></ul><ul><li><xsl:value-of select=&quot;linkText&quot;/>, </li></ul><ul><li></xsl:for-each>&cr; </li></ul><ul><li>header=Y &cr; </li></ul><ul><li>footer=Y &cr; </li></ul><ul><li> file:stylesheet=style.css &cr; </li></ul>
  17. 17. Il batch… <ul><li><?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> </li></ul><ul><li><!DOCTYPE xsl:stylesheet [ </li></ul><ul><li><!ENTITY nbsp &quot; &quot;> </li></ul><ul><li><!ENTITY copy &quot;©&quot;> </li></ul><ul><li><!ENTITY reg &quot;®&quot;> </li></ul><ul><li><!ENTITY trade &quot;™&quot;> </li></ul><ul><li><!ENTITY mdash &quot;—&quot;> </li></ul><ul><li><!ENTITY ldquo &quot;“&quot;> </li></ul><ul><li><!ENTITY rdquo &quot;”&quot;> </li></ul><ul><li><!ENTITY pound &quot;£&quot;> </li></ul><ul><li><!ENTITY yen &quot;¥&quot;> </li></ul><ul><li><!ENTITY cr &quot;<xsl:text> </li></ul><ul><li></xsl:text>&quot;> </li></ul><ul><li>]> </li></ul><ul><li><xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;> </li></ul><ul><li><xsl:output method=&quot;text&quot; encoding=&quot;utf-8&quot;/> </li></ul><ul><li><xsl:template match=&quot;/&quot;> </li></ul><ul><li>………………………………………………………………………………………………………………………………………………………… . </li></ul><ul><li></xsl:template> </li></ul><ul><li></xsl:stylesheet> </li></ul>
  18. 18. … con le istruzioni <ul><li>java -classpath binxalan.jar;binserialiser.jar org.apache.xalan.xslt.Process -IN bin emplate. xml -XSL binhome. xsl -OUT home.html &cr; </li></ul><ul><li>java -classpath binxalan.jar;binserialiser.jar org.apache.xalan.xslt.Process -IN bin emplate.xml -XSL bincp.xsl -OUT campaign.txt &cr; </li></ul><ul><li>java -classpath binxalan.jar;binserialiser.jar org.apache.xalan.xslt.Process -IN bin emplate.xml -XSL bin ext.xsl -OUT load.bat &cr; </li></ul>
  19. 19. Non solo html… ad esempio… il load! <ul><li>>>script.ftp ECHO USERNAME &cr; </li></ul><ul><li>>>script.ftp ECHO PASSWORD &cr; </li></ul><ul><li>>>script.ftp ECHO ascii &cr; </li></ul><ul><li>>>script.ftp ECHO CD BASE PATH DI CARICAMENTO &cr; </li></ul><ul><li>>>script.ftp ECHO mkdir <xsl:value-of select=&quot;page/campaignName&quot;/> &cr; </li></ul><ul><li>>>script.ftp ECHO CD BASE PATH DI CARICAMENTO /<xsl:value-of select=&quot;page/campaignName&quot;/>/&cr; </li></ul><ul><li>FOR %%f in (*.html, *.txt, *.css) </li></ul><ul><li>do >>script.ftp ECHO put %%f&cr; </li></ul><ul><li>>>script.ftp ECHO bye&cr; </li></ul><ul><li>FTP -v -s:script.ftp INDIRIZZO FTP SERVER &cr; </li></ul><ul><li>DEL script.ftp&cr; </li></ul><ul><li>REM DEL *.html &cr; </li></ul><ul><li>REM DEL *.txt &cr; </li></ul><ul><li>GOTO End &cr; </li></ul><ul><li>:End &cr; </li></ul><ul><li>start iexplore http://MIOSITO.COM </li></ul>
  20. 20. Il Clickme.bat <ul><li>java -classpath binxalan.jar;binserialiser.jar org.apache.xalan.xslt.Process -IN bin emplate.xml -XSL binatch.xsl -OUT doAll.bat </li></ul><ul><li>call doAll.bat </li></ul><ul><li>call load.bat </li></ul><ul><li>del doAll.bat </li></ul><ul><li>del load.bat </li></ul><ul><li>del *.html </li></ul><ul><li>del *.txt </li></ul>
  21. 21. Distribuzione alle opco Inserimento Contenuti localizzati Preview / Correzione in Excel Rerun del Template

×