Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13

Discussione: XSL: Testo e Immagini

  1. #1

    XSL: Testo e Immagini

    Ciao a tutti

    Ho un problema: dovrei trovare il modo di inserire delle immagini tra le righe di un testo con XSL. In XML il codice è simile al seguente:

    <text> Bla bla bla <image url="ciao.gif"/> bla bla bla <image url="giffe.gif"/> bibi bibi </text>
    <text> Oooooo <image url="bibu.gif"/> ciao </text>

    e vorrei che venisse trasformato in:

    <DIV> Bla bla bla [img]ciao.gif[/img]</IMG> bla bla bla [img]giffe.gif[/img]</IMG> bibi bibi </DIV>
    <DIV> Oooooo [img]bibu.gif[/img]</IMG> ciao </DIV>

    Per trasformare i tag non c'è problema.. ma non sono riuscito a trovare alcuna soluzione che mi permetta di inserire le immagini all'interno del testo nel modo sovraesposto. Sapreste aiutarmi? Ho
    provato diverse soluzioni (<text></text><image/><text></text>, ecc..) ma non riesco proprio ad andarne fuori. Se qualcuno di voi potesse farmi degli esempi gli sarei molto grato.

    Grazie anticipatamente a tutti.

    Marco

  2. #2
    axe2003
    Guest
    da come descrivi il documento, NON si tratta di un documento FORMALMENTE corretto e VALIDO. Cmq, anche se ciò non ti aiuterà, ti metto qua un'es. di codice XSL:


    _____________________________________
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xslutput method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="no" indent="no" media-type="text/html"/>

    <xsl:template match="datasheet">
    <html>
    <head>
    <title>
    <xsl:value-of select="manufacturer"/>
    <xsl:value-of select="productline"/>
    Product Line - Data Sheet
    </title>
    </head>
    <body>
    <p align="right">
    [img]axe_right_300.gif[/img]
    </p>
    <h1>
    <xsl:value-of select="manufacturer"/>
    <xsl:value-of select="productline"/>
    Product Line - Data Sheet
    </h1>
    <!--
    <h2>Document Information</h2>
    <table border="1" cellpadding="4">
    <tr>
    <td>ID</td>
    <td>
    <input>
    <xsl:attribute name="value"><xsl:value-of select="documentid"/></xsl:attribute>
    </input>
    </td>
    </tr>
    <tr>
    <td>Company</td>
    <td>
    <input>
    <xsl:attribute name="value"><xsl:value-of select="manufacturer"/></xsl:attribute>
    </input>
    </td>
    </tr>
    <tr>
    <td>Line</td>
    <td>
    <input>
    <xsl:attribute name="value"><xsl:value-of select="productline"/></xsl:attribute>
    </input>
    </td>
    </tr>
    <tr>
    <td>Security</td>
    <td>
    <table>
    <tr>
    <td>Classification</td>
    <td>
    <input>
    <xsl:attribute name="value"><xsl:value-of select="security/classification"/></xsl:attribute>
    </input>
    </td>
    </tr>
    <tr>
    <td>Level</td>
    <td>
    <input>
    <xsl:attribute name="value"><xsl:value-of select="security/level"/></xsl:attribute>
    </input>
    </td>
    </tr>
    <tr>
    <td>Effective</td>
    <td>
    <input>
    <xsl:attribute name="value"><xsl:value-of select="security/effective"/></xsl:attribute>
    </input>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td>Tracking</td>
    <td>
    <xsl:for-each select="tracking">
    <table>
    <tr>
    <td>Operation</td>
    <td>Date</td>
    <td>Time</td>
    <td>By</td>
    <td>Dpt.</td>
    <td>Status</td>
    <td>Changes</td>
    </tr>
    <xsl:for-each select="modification">
    <xsl:apply-templates select="."/>
    </xsl:for-each>
    </table>
    </xsl:for-each>
    </td>
    </tr>
    </table>
    <h2>Document Contents</h2>
    -->
    <table width="100%">
    <tr valign="top">
    <td>
    <xsl:for-each select="description">
    <xsl:apply-templates select="."/>
    </xsl:for-each>
    </td>
    <td>
    <table width="100%" cellspacing="10">
    <xsl:for-each select="diagrams">
    <tr>
    <xsl:apply-templates select="."/>
    </tr>
    </xsl:for-each>
    <tr>
    <td colspan="2">
    <xsl:apply-templates select="models"/>
    </td>
    </tr>
    <xsl:for-each select="copyright">
    <tr>
    <td colspan="2" align="right">




    <xsl:for-each select="para">

    <xsl:apply-templates/>



    </xsl:for-each>
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </td>
    </tr>
    </table>
    </body>
    </html>
    </xsl:template>
    <xsl:template match="modification">
    <tr>
    <td>
    <input size="8">
    <xsl:attribute name="value"><xsl:value-of select="@operation"/></xsl:attribute>
    </input>
    </td>
    <td>
    <input size="8">
    <xsl:attribute name="value"><xsl:value-of select="date"/></xsl:attribute>
    </input>
    </td>
    <td>
    <input size="8">
    <xsl:attribute name="value"><xsl:value-of select="time"/></xsl:attribute>
    </input>
    </td>
    <td>
    <input size="10">
    <xsl:attribute name="value"><xsl:value-of select="by"/></xsl:attribute>
    </input>
    </td>
    <td>
    <input size="10">
    <xsl:attribute name="value"><xsl:value-of select="department"/></xsl:attribute>
    </input>
    </td>
    <td>
    <input size="8">
    <xsl:attribute name="value"><xsl:value-of select="status"/></xsl:attribute>
    </input>
    </td>
    <td>
    <input size="30">
    <xsl:attribute name="value"><xsl:value-of select="changes"/></xsl:attribute>
    </input>
    </td>
    </tr>
    </xsl:template>
    <xsl:template match="models">
    <table width="100%">
    <tr>
    <td>Principal Characteristics</td>
    <xsl:for-each select="model">
    <td bgcolor="808080">

    <xsl:value-of select="Name"/>

    </td>
    </xsl:for-each>
    </tr>
    <tr bgcolor="C0C0C0">
    <td>Max. Takeoff Weight</td>
    <xsl:for-each select="model">
    <td>
    <xsl:value-of select="MaxTakeoffWeight"/>
    </td>
    </xsl:for-each>
    </tr>
    <tr bgcolor="C0C0C0">
    <td>Max. Landing Weight</td>
    <xsl:for-each select="model">
    <td>
    <xsl:value-of select="MaxLandingWeight"/>
    </td>
    </xsl:for-each>
    </tr>
    <tr bgcolor="C0C0C0">
    <td>Engines</td>
    <xsl:for-each select="model">
    <td>
    <xsl:value-of select="EngineOfferings"/>
    </td>
    </xsl:for-each>
    </tr>
    <tr bgcolor="C0C0C0">
    <td>Fuel Capacity</td>
    <xsl:for-each select="model">
    <td>
    <xsl:value-of select="FuelCapacity"/>
    </td>
    </xsl:for-each>
    </tr>
    <tr bgcolor="C0C0C0">
    <td>Cruise Mach</td>
    <xsl:for-each select="model">
    <td>
    <xsl:value-of select="CruiseMach"/>
    </td>
    </xsl:for-each>
    </tr>
    <tr bgcolor="C0C0C0">
    <td>Passengers</td>
    <xsl:for-each select="model">
    <td>
    <xsl:value-of select="Passengers"/>
    </td>
    </xsl:for-each>
    </tr>
    <tr bgcolor="C0C0C0">
    <td>DesignRange</td>
    <xsl:for-each select="model">
    <td>
    <xsl:value-of select="DesignRange"/>
    </td>
    </xsl:for-each>
    </tr>
    <tr bgcolor="C0C0C0">
    <td>Pallets</td>
    <xsl:for-each select="model">
    <td>
    <xsl:value-of select="Pallets"/>
    </td>
    </xsl:for-each>
    </tr>
    </table>
    </xsl:template>
    <xsl:template match="diagram">
    <td>
    <h3>
    <xsl:value-of select="title"/>
    </h3>
    <img alt="Diagram">
    <xsl:attribute name="src"><xsl:value-of select="source"/></xsl:attribute>
    </img>
    <xsl:for-each select="description">
    <xsl:for-each select="para">




    <xsl:apply-templates/>

    </p>
    </xsl:for-each>
    </xsl:for-each>
    </td>
    </xsl:template>
    <xsl:template match="description">
    <xsl:for-each select="para">



    <xsl:apply-templates/>
    </p>
    </xsl:for-each>
    </xsl:template>
    <xsl:template match="bold">

    <xsl:apply-templates/>

    </xsl:template>
    <xsl:template match="italic">

    <xsl:apply-templates/>

    </xsl:template>
    </xsl:stylesheet>


    _____________________________________

    Non ce fate caso, sono megalomane.

  3. #3
    Ti ringrazio infinitamente!

    Faccio fatica a crederci, mi hai risolto il problema! Inoltre quel sorgente che hai pubblicato mi potrà tornare utilissimo in seguito!

    Grazie ancora, Ciao


  4. #4
    axe2003
    Guest
    alla grande!

  5. #5
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    7
    Ciao Polaroid e axe,
    anche io ho difficolta' nell'inserire delle immaggini (linkate)tra un testo. dall'esempio che ha fatto axe non sono riuscito forse perche molto lungo. Riuscireste entrambi a scrivere un caso piu' semplice magari riferendosi a quello esposto da Polaroid all'inizio?

    Grazie ad entrambi
    Francesco

  6. #6
    axe2003
    Guest
    è solo per farti capire, non è il mio arg. ma mi sono cmq divertito a validare due semplici righe di cod. xml con il suo XSLT:
    in allegato hai la gif da mettere in una cartella con i due seg. files, il mini es. è ovviamente funzionante:


    1° contenuto file, che nominerai se vuoi come richiesto da es.sotto: 2.xslt :
    _________________________



    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/TR/REC-html40">
    <xsl:template match="text()" />
    <xsl:template match="libro">
    <html>
    <head><title>info sul libro</title></head>
    <body>
    <p align="center">[img]1.gif[/img]</p>
    <h1><xsl:value-of select="titolo_libro"/></h1>
    <h2><xsl:value-of select="autore"/></h2>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>
    _________________________

    2° file che nominerai come ti pare, basta che abbia estensione .xml ha il seg. contenuto:
    _________________________

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="2.xslt"?>
    <libro>
    <titolo_libro>Un libro per sognare</titolo_libro>
    <autore>axej ed.</autore>
    </libro>

    ___________________________

    E' un es. molto semplice, ma spero ti sarà utile. Ciao.

    P.s vedo che mozilla non supporta Xslt: infatti non formatta il documento tramite il foglio di stile xslt....vorrei di saperne di più...... qualcuno ha idea? Credo cmq che la risposta sia che al mom. solo Explorer lo supporta, quindi usa quello per visualizz. l'es.
    Immagini allegate Immagini allegate

  7. #7
    Ciao, penso che il problema sia esattamente lo stesso che ho esposto nel mio primo post.

    Io ho risolto usando il comando xsl:apply-templates forse in modo in proprio, forse no. So solo che riesco a ottenere qualche risultato.

    Cerco di farti un esempio.

    File xml:

    <?xml version="1.0"?>
    <?xml:stylesheet type="text/xsl" href="temp.xsl"?>
    <main>
    <text>Bla bla bla <image url="1-1.gif"/> he he he</text>
    </main>

    File xsl (che ho chiamato temp.xsl):

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/TR/REC-html40">
    <xsl:template match="main">
    <html>
    <body>
    <xsl:for-each select="text">
    <xsl:apply-templates/>
    </xsl:for-each>

    <xsl:for-each select="image">
    <xsl:apply-templates/>
    </xsl:for-each>

    </body>
    </html>
    </xsl:template>

    <xsl:template match="text">
    <xsl:value-of select="."/>
    </xsl:template>

    <xsl:template match="image">
    <img>
    <xsl:attribute name="src">
    <xsl:value-of select="@url"/>
    </xsl:attribute>
    </img>
    </xsl:template>

    </xsl:stylesheet>


    Dovrebbe funzionare, non so perché, non so come. Spero che qualcuno possa spiegare passo passo cosa dovrebbe produrre questo codice.

    Ciao!

    :adhone:

  8. #8
    axe2003
    Guest
    mi spiace, personalmente ho scelto di non rispondere più in questo forum fino a che non ne cambiano almeno il titolo in Xml.

  9. #9
    Originariamente inviato da axe2003
    mi spiace, personalmente ho scelto di non rispondere più in questo forum fino a che non ne cambiano almeno il titolo in Xml.

    una delle regole fondamentali di questo forum è il fatto che non sono ben visti "gli sboroni".... quelli che "siccome io sono bravo allora mi permetto certi atteggiamenti".

    probabilmente il titolo non verrà cambiato come vuoi tu... se la situazione non ti piace la porta è di là --->


    ciao
    w la topa

  10. #10
    Utente di HTML.it
    Registrato dal
    Dec 2002
    Messaggi
    7
    Ciao Polaroid,
    il tuo esempio funziona perfettamente anche se non ho capito la logica, ho provato diverse combinazioni ma solo la tua funziona
    Francesco

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.