Dal titolo non potete capire molto ma il mio problema è questo: io sto facendo un sito in html,ci sono quattro div dove in uno c'è un menu, cliccando sul menu il div principale dovrebbe caricare un file xml formattato in xslt.
Il mio problema è che quando carico il file xml, compare solo il suo contenuto e non viene formattato come è fatto nel file xslt.
Io ho provato a visualizzare solamente il file xml e viene formattato, perchè quando lo carico no?
Allego il codice javascript del caricamento del file nel div
codice xmlcodice:var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no) var loadedobjects="" var rootdomain="http://"+window.location.hostname var bustcacheparameter="" function ajaxpage(url, containerid){ var page_request = false //creo l' oggetto httpRequest if (window.XMLHttpRequest) // per tutti i browser page_request = new XMLHttpRequest() else if (window.ActiveXObject){ // per IE try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else return false page_request.onreadystatechange=function(){ //creo una funzione loadpage(page_request, containerid) } if (bustcachevar) //if bust caching of external page bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.send(null) } function loadpage(page_request, containerid){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){ document.getElementById(containerid).innerHTML=page_request.responseText } } function loadobjs(){ if (!document.getElementById) return for (i=0; i<arguments.length; i++){ var file=arguments[i] var fileref="" if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding if (file.indexOf(".js")!=-1){ //If object is a js file fileref=document.createElement('script') fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", file); } else if (file.indexOf(".css")!=-1){ //If object is a css file fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", file); } } if (fileref!=""){ document.getElementsByTagName("head").item(0).appendChild(fileref) loadedobjects+=file+" " //Remember this object as being already added to page } } }
codice:<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="listacd_es1.xslt"?> <listacd> <artista> <nome>Stanley Jordan</nome> <albums> <album> <titolo>Magic Touch</titolo> <anno>1985</anno> <etichetta>Blue Note</etichetta> </album> <album> <titolo>Stolen Moments</titolo> <anno>1991</anno> <etichetta>Blue Note</etichetta> </album> </albums> </artista> <artista> <nome>Nick Drake</nome> <albums> <album> <titolo>Pink Moon</titolo> <anno>1972</anno> <etichetta>Island</etichetta> </album> <album> <titolo>Bryter Layter</titolo> <anno>1970</anno> <etichetta>Island</etichetta> </album> <album> <titolo>Five leaves left</titolo> <anno>1970</anno> <etichetta>Island</etichetta> </album> </albums> </artista> <artista> <nome>Jeff Buckley</nome> <albums> <album> <titolo>Grace</titolo> <anno>1994</anno> <etichetta>Columbia</etichetta> </album> <album> <titolo>Mistery white boy</titolo> <anno>2000</anno> <etichetta>Columbia</etichetta> </album> </albums> </artista> <artista> <nome>Joe Satriani</nome> <albums> <album> <titolo>Surfing with the alien</titolo> <anno>1987</anno> <etichetta>Epic</etichetta> </album> <album> <titolo>Not of this earth</titolo> <anno>1988</anno> <etichetta>Relativity</etichetta> </album> </albums> </artista> </listacd>
ed il codice xsl
codice:<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <xsl:apply-templates> </xsl:apply-templates> </html> </xsl:template> <xsl:template match="artista"> <xsl:value-of select="nome"> </xsl:value-of> </br> </xsl:template> </xsl:stylesheet>

Rispondi quotando
sei riuscito a risolverlo???
