1 / 19

XSL – 3 –

XSL – 3 –. <xsl:element> <xsl:attribute>. <xsl:element>: crea un nuovo elemento nell’output <xsl:attribute>: crea un nuovo attributo per un elemento dichiarato. <xsl:template match=“/”> <html> <xsl:apply-templates/> </html> </xsl:template> <xsl:template match="teiHeader">

derora
Download Presentation

XSL – 3 –

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XSL – 3 –

  2. <xsl:element> <xsl:attribute> <xsl:element>: crea un nuovo elemento nell’output <xsl:attribute>: crea un nuovo attributo per un elemento dichiarato

  3. <xsl:template match=“/”> <html> <xsl:apply-templates/> </html> </xsl:template> <xsl:template match="teiHeader"> <table border='1‘> <tr><td> <xsl:apply-templates /> </td> </tr> </table> </xsl:template> <xsl:template match=“/”> <xsl:element name=“html”> <xsl:apply-templates/> <xsl:element> </xsl:template> <xsl:template match="teiHeader"> <table> <xsl:attribute name=“border”>1</xsl:attribute> <tr><td> <xsl:apply-templates /> </td> </tr> </table> </xsl:template> Esempio

  4. Inserire le immagini in un file TEI <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="es25.xsl"?> <!DOCTYPE TEI.2 PUBLIC "-//TEI//DTD TEI Lite XML ver. 1//EN" "c:/TEI-EMACS/xml/dtds/tei/teixlite.dtd" [ <!ENTITY mummie1.jpg SYSTEM "mummie1.jpg" NDATA JPEG> <!ENTITY mummie2.jpg SYSTEM "mummie2.jpg" NDATA JPEG> <!ENTITY mummie3.jpg SYSTEM "mummie3.jpg" NDATA JPEG> <!ENTITY mummie4.jpg SYSTEM "mummie4.jpg" NDATA JPEG> <!ENTITY mummie5.jpg SYSTEM "mummie5.jpg" NDATA JPEG> ]>

  5. Elemento <figure> <head type="numerale">XIV <figure entity="mummie1.jpg"> <figDesc>Pagina 1</figDesc> </figure> </head>

  6. Visualizzazione <xsl:template match="figure"> <img> <xsl:attribute name="src"> <xsl:apply-templates select="@entity" /> </xsl:attribute> <xsl:attribute name="alt"> <xsl:apply-templates select="figDesc" /> </xsl:attribute> <xsl:attribute name="border">0</xsl:attribute> <xsl:attribute name="width">100%</xsl:attribute> <xsl:attribute name="heigth">100%</xsl:attribute> </img> </xsl:template>

  7. Risultato <img src=“mummie1.jpg” alt=“Pagina 1” border=“0” width=“100%” height=“100%”>  mummie.xml

  8. Visualizzare le note: il testo <head type="descrittivo">DIALOGO DI <name>FEDERICO RUYSCH</name> E DELLE SUE MUMMIE <note n="39" place="end">Vedi, tra gli altri, circa queste famose mummie, che in linguaggio scientifico si direbbero preparazioni anatomiche, il <bibl><author>Fontenelle</author> <title lang="fra">Eloge de <abbr expan="monsignore" type="title">mons.</abbr> <name>Ruysch</name></title></bibl>. </note> </head>

  9. HTML da ottenere <h3>DIALOGO DI FEDERICO RUYSCH E DELLE SUE MUMMIE <sup><a href=“#39”>39</a></sup></h3> <!-- qui tutto il testo --> <div> <hr> <p><a name=“39”><b>39.</b></a> Vedi, tra gli altri…</p> </div>

  10. Il rimando… <xsl:template match="note"> <sup> <a> <xsl:attribute name="href"> # <xsl:apply-templates select="@n"/> </xsl:attribute> <xsl:apply-templates select="@n"/> </a> </sup> </xsl:template>

  11. …e il testo <xsl:template match="body"> <body> <xsl:apply-templates /> <div> <hr/> <xsl:for-each select="//note"> <p> <a> <xsl:attribute name="name"> <xsl:value-of select="@n" /> </xsl:attribute> </a> <b> <xsl:value-of select="@n" />. </b> <xsl:text> </xsl:text> <xsl:value-of select="." /> </p> </xsl:for-each> </div> </body> </xsl:template>  mummie2.xml

  12. Attenzione: non usare due <body>! <xsl:template match="/"> <html> <head> <title> <xsl:apply-templates select="//titleStmt/title" /> </title> </head> <body> <xsl:apply-templates /> </body> </html> </xsl:template> <xsl:template match="body"> <body> … </body> </xsl:template>

  13. Sezioni condizionali • IF: booleano, qualora si verifichi una condizione si esegue una istruzione; se la condizione non si verifica l’istruzione non si esegue.Attributo test (sintassi XPath) obbligatorio • CHOOSE : si danno più opzioni • WHEN: booleano, qualora si verifichi una condizione si esegue una istruzione; se la condizione non si verifica l’istruzione non si esegue; ripetibile all’interno di choose; equivale a tanti ifAttributo test (sintassi XPath) obbligatorio • OTHERWISE ( else): contempla tutti i casi non definiti dai vari when

  14. Visualizzare solo poesie con titolo test non definisce un nuovo nodo contestuale. Il nodo contestuale è sempre poesia <xsl:template match="//poesia"> <xsl:if test="titolo"> <xsl:for-each select="titolo"> <b><xsl:value-of select="." /></b><br/> </xsl:for-each> <xsl:for-each select="verso"> <xsl:value-of select="." /><br/> </xsl:for-each> <br/> </xsl:if> </xsl:template>

  15. Se il titolo non c’è lo inseriamo test non definisce un nuovo nodo contestuale. Il nodo contestuale è sempre poesia <xsl:template match="poesia"> <xsl:choose> <xsl:when test="titolo"> <xsl:for-each select="titolo"> <b><xsl:value-of select="." /></b><br/> </xsl:for-each> </xsl:when> <xsl:otherwise> [<b>Poesia</b>]<br/> </xsl:otherwise> </xsl:choose> <xsl:for-each select="verso"> <xsl:value-of select="." /><br/> </xsl:for-each> <br/> </xsl:template>

  16. Un esempio complesso: table of content <xsl:template match="teiHeader“/> <xsl:template match="text"> <h1>Indice</h1> <ol> <xsl:for-each select="descendant::div1"><br/> <li> <xsl:choose> <xsl:when test="head"> <xsl:value-of select="head"/> <xsl:if test="head[position()=2]"> . <xsl:value-of select="head[position()=2]"/> </xsl:if> </xsl:when> <xsl:otherwise> <b><xsl:value-of select="@type"/></b> </xsl:otherwise> </xsl:choose> </li></xsl-for-each> </ol> </xsl:templates>

  17. Elenco con numero di occorrenze • Ceneri di Gramsci con marcatura delle parole rima: <lg><l>Teatro di dossi, ebbri, <s>calcinati</s>,</l> <l>muto, è la muta luna che ti <s>vive</s>,</l> <l>tiepida sulla Lucchesia dai <s>prati</s></l></lg> <lg><l>troppo umani, cocente sulle <s>rive</s></l> <l>della Versilia, cos&ì intera sul <s>vuoto</s></l> <l>del mare - attonita su <s>stive</s>,</l></lg>  Voglio un elenco delle parole rima per numero di occorrenze

  18. Elenco parole rima <xsl:template match="/"> <html> <body> <h3>Elenco parole rima</h3> <xsl:for-each select="//s">  Pasolini.xml <xsl:for-each select="//s[not(.=preceding::s)]"> <xsl:value-of select=“.”/> <br/> </xsl:for-each> </body> </html> </xsl:template>

  19. Elenco parole rima per numero di occorrenze <xsl:key name="rima" match="s" use="."/> <xsl:template match="/"> <html> <body> <h3>Elenco parole rima</h3> <xsl:for-each select="//s[not(.=preceding::s)]"> <xsl:sort select="count(key('rima',.))" data-type="number" order="descending" /><br /> <xsl:value-of select="concat(.,' ',count(key('rima',.)))"/> </xsl:for-each> </body> </html> </xsl:template>

More Related