Precedente :: Successivo |
Autore |
Messaggio |
Typhoon90 Dio maturo


Registrato: 01/06/06 16:17 Messaggi: 1019 Residenza: Vivere per niente o morire per qualcosa. Scegli tu.
|
Inviato: 27 Feb 2008 16:43 Oggetto: inserire xml convertito in html in pagina html |
|
|
Ciao!
E' possibile avendo:
1. una pagina in xhtml con un piccolo div definito in dimensioni
2. un file xml che contiene testo
riuscire utilizzando xsl a cacciare il testo dentro al div del file xhtml???
che strategia devo usare? |
|
Top |
|
 |
Typhoon90 Dio maturo


Registrato: 01/06/06 16:17 Messaggi: 1019 Residenza: Vivere per niente o morire per qualcosa. Scegli tu.
|
Inviato: 27 Feb 2008 19:51 Oggetto: |
|
|
ho trovato da me la soluzione, non avevo minimamente pensato ai frame
quindi ho risolto inserendo un tag iframe con collegamento al file xml |
|
Top |
|
 |
kluster Dio maturo

Registrato: 15/04/06 13:14 Messaggi: 2898
|
Inviato: 27 Feb 2008 20:59 Oggetto: |
|
|
ciao,
puoi creare un file .xml che abbia un foglio di stile associato xls che riformatti i dati secondo puro html e regole interne della sintassi xls.
esempio prendi il file xml.
Citazione: |
<?xml version="1.0" encoding="iso-8859-1"?>
<forum name="linguaggi per il web">
<thread>
<topic>inserire xml convertito in html in pagina html</topic>
<user>Typhoon</user>
</thread>
<thread>
<topic>secondo 3d di esempio</topic>
<user>kluster</user>
</thread>
</forum>
|
e ci associ un file xsl
Es. test.xml
Citazione: |
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="formattatest.xsl"?>
<forum name="linguaggi per il web">
<thread>
<topic>inserire xml convertito in html in pagina html</topic>
<user>Typhoon</user>
</thread>
<thread>
<topic>secondo 3d di esempio</topic>
<user>hobisognodiferie</user>
</thread>
</forum>
|
e poi con la sintassi xsl crei i template che ti pare con i dati
es. formattatest.xsl
Citazione: |
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<style type="text/css">
#contenuto
{
height:90px;
font-family:Verdana, Arial, Helvetica, sans-serif;
border:1px solid black;
overflow:auto;
}
#contenuto .prova
{
padding:5px;
}
#contenuto .prova strong
{
color:red;
}
</style>
</head>
<body>
<h1>Esempio con discussioni forum</h1>
<div id="contenuto">
<xsl:for-each select="forum/thread">
<p class="prova">
<strong><xsl:value-of select="topic"/></strong>
<br />
by <em><xsl:value-of select="user"/></em>
</p>
</xsl:for-each>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
|
Richiamando text.xml su un qualsiasi browser l'output è il seguente:
per la sintassi dell'XSL vedi qui
per richiamare i nodi dell'xml devi conoscere come vengono rappresentati i percorsi tramite XPATH (nell'ultimo esempio li ho marcati in rosso) |
|
Top |
|
 |
Typhoon90 Dio maturo


Registrato: 01/06/06 16:17 Messaggi: 1019 Residenza: Vivere per niente o morire per qualcosa. Scegli tu.
|
Inviato: 27 Feb 2008 23:48 Oggetto: |
|
|
ti ringrazio, il linguaggio XSL e annessi e connessi lo conosco già, e infatti l'ho usato.
Il mio problema infatti non era quello di trasformare un xml in html, ma di inserire l'html prodotto in una piccola porzione di un'altra pagina in xhtml.
Per questo ho usato un iframe che si collega al'xml (che ovviamente con xsl si vizualizza in html)
Grazie comunque, ho risolto. |
|
Top |
|
 |
Typhoon90 Dio maturo


Registrato: 01/06/06 16:17 Messaggi: 1019 Residenza: Vivere per niente o morire per qualcosa. Scegli tu.
|
Inviato: 28 Feb 2008 20:57 Oggetto: |
|
|
eccomi, ora ho un altro problema (questa volta con iframe).
Per fare il ridimensionamento in altezza automatico del iframe mi sono affidato a uno script, ho avuto dei problemi di compatibilità quindi mi servirebbe una modifica.
Lo script si trova qui
e lo riporto:
Codice: | <script type="text/javascript">
/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/
//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]
//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}
function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}
function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}
function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}
if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller
</script> |
Codice: | <iframe id="myframe" src="externalpage.htm" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe> |
ciò che mi serve è che questo script NON funzioni con internet explorer ma solo con gli altri browser diversi.
Come devo modificarlo? |
|
Top |
|
 |
Typhoon90 Dio maturo


Registrato: 01/06/06 16:17 Messaggi: 1019 Residenza: Vivere per niente o morire per qualcosa. Scegli tu.
|
Inviato: 02 Mar 2008 13:28 Oggetto: |
|
|
nessuna idea? |
|
Top |
|
 |
Typhoon90 Dio maturo


Registrato: 01/06/06 16:17 Messaggi: 1019 Residenza: Vivere per niente o morire per qualcosa. Scegli tu.
|
Inviato: 26 Mar 2008 19:55 Oggetto: |
|
|
c'è nessunoooooooooooooooooooooooooooooooo????
non c'è un esperto di javascript da queste parti?? |
|
Top |
|
 |
horus Macchinista


Registrato: 22/03/05 10:48 Messaggi: 2554 Residenza: Sirio e dintorni
|
Inviato: 27 Mar 2008 09:05 Oggetto: |
|
|
Puoi controllare l'attributo
Codice: | navigator.appName |
e poi eseguire il tuo codice se il valore è diverso da
Codice: | Microsoft Internet Explorer |
|
|
Top |
|
 |
Typhoon90 Dio maturo


Registrato: 01/06/06 16:17 Messaggi: 1019 Residenza: Vivere per niente o morire per qualcosa. Scegli tu.
|
Inviato: 27 Mar 2008 13:16 Oggetto: |
|
|
horus ha scritto: | Puoi controllare l'attributo
Codice: | navigator.appName |
e poi eseguire il tuo codice se il valore è diverso da
Codice: | Microsoft Internet Explorer |
|
non capisco dove e come metterlo, potresti modificarmi il codice sopra per favore?  |
|
Top |
|
 |
horus Macchinista


Registrato: 22/03/05 10:48 Messaggi: 2554 Residenza: Sirio e dintorni
|
Inviato: 28 Mar 2008 09:17 Oggetto: |
|
|
Puoi semplicemente far aggiungere l'evento se non è IE
Codice: |
if (navigator.appName != 'Microsoft Internet Explorer')
{
if (window.addEventListener)
window.addEventListener("load", resizeCaller, false);
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller);
else
window.onload=resizeCaller;
} |
P.S.: non l'ho testato ma dovrebbe andare. |
|
Top |
|
 |
|