1

my first post here. I'm a first year student and my first encounter with xml and xsl. I've been following many tutorials and haven't been able to figure out why the browser always says "This XML file does not appear to have any style information associated with it. The document tree is shown below." The problem is that this message is displayed for my xsl file. I think that browser doesn't recognize my xsl file as xsl and instead thinks of it as xml. Didn't find answer why that happens in google, so I'm asking here. Here's my xsl:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:output method="html" indent="yes"/>


<xsl:template match="/">
 <html>
  <head>
   <meta charset="utf-8" />
   <title>Spis</title>
  </head>
  <body>
  <div class="navbar">
   
   <div class="subnav">
  <button class="subnavbtn"><a href="info.html">O mnie</a><i class="fa fa-caret-down"></i></button>
  <div class="subnav-content">
    <a href="info.html#tekst">Wstęp</a>
    <a href="info.html#galeria">Galeria</a>
  </div>
   </div>
   <div class="subnav">
  <button class="subnavbtn"><a href="tabele.html">Więcej</a><i class="fa fa-caret-down"></i></button>
   </div>
   <div class="subnav">
  <button class="subnavbtn"><a href="spis.xsl">Spis</a><i class="fa fa-caret-down"></i></button>
   </div>
 </div>
  
   <xsl:for-each select="swiat">
    <h1>Typ świata: <xsl:value-of select="/swiat/typ"/></h1>
   <table>
    <xsl:for-each select="/swiat/pasywne/mob">
     <tr>
     <td><xsl:value-of select="name"/></td>
     <td><xsl:value-of select="drops"/></td>
     <td><xsl:value-of select="opis"/></td>
     <td><xsl:value-of select="wyglad"/></td>
     </tr>
     </xsl:for-each>
   </table>
   <p>-----------------------------------</p>
   </xsl:for-each>
   <xsl:apply-templates select="overworld"/>
   <xsl:apply-templates select="nether"/>
   <xsl:apply-templates select="end"/>
   <xsl:apply-templates/>
  </body>
 </html>
</xsl:template>
</xsl:stylesheet>

and here's xml:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="spis.xsl" ?>

<listaMobow title="Elementy">
 <swiat type="overworld">
  <typ>overworld</typ>
  <wyglad><img url("xml/overworld.jpg")></wyglad>
  <pasywne>
   <mob>
    <name>świnia</name>
    <drop>szynka</drop>
    <opis>Można założyć na sią siodło i na niej jeździć.</opis>
    <wyglad><image url="xml/swinia.jpg"/></wyglad>
   </mob>
   <mob>
    <name>krowa</name>
    <drop>wołowina, skóra</drop>
    <opis>Po kliknięciu na nią trzymając wiadro w dłoni, otrzymuje się wiadro mleka.</opis>
    <wyglad><image url="xml/krowa.jpg"/></wyglad>
   </mob>
   <mob>
    <name>owca</name>
    <drop>jagniecina, welna</drop>
    <opis>Można ogolić i otrzymać wełnę za pomocą nożyc, po jakimś czasie jej wełna odrasta.</opis>
    <wyglad><image url="xml/owca.jpg"/></wyglad>
   </mob>
   <mob>
    <name>kurczak</name>
    <drop>filet, pióro</drop>
    <opis>Znosi jajka, które mają małą szansę na wyklucie kurczątka, po rzuceniu nimi o ziemię.</opis>
    <wyglad><image url="xml/kurczak.png"></wyglad>
   </mob>
   
  </pasywne>
  <neutralne>
   <mob>
    <name>enderman</name>
    <drop>perła</drop>
    <opis>Duże czarne humanoitalne stwory. Atakują po spojrzeniu się im w twarz.</opis>
    <wyglad><image url="xml/enderman.png"/></wyglad>
   </mob>
   <mob>
    <name>golem</name>
    <drop>sztabka żelaza</drop>
    <opis>Często broni wioski osadników. Atakuje gracza po zaatakowaniu ich lub golema.</opis>
    <wyglad><image url="xml/golem.jpg"/></wyglad>
   </mob>
   <mob>
    <name>niedźwiedź polarny</name>
    <drop>ryba</drop>
    <opis>Pojawia się w zimnych biomach, broni młodych niedźwiadków.</opis>
    <wyglad><image url="xml/niedzwiedz.jpg"/></wyglad>
   </mob>
  </neutralne>
  <agresywne>
   <mob>
    <name>creeper</name>
    <drop>proch</drop>
    <opis>Po zbliżeniu się do gracza na wystarczającą odległość, wybucha.</opis>
    <wyglad><image url="xml/creeper.jpg"/></wyglad>
   </mob>
   <mob>
    <name>zombie</name>
    <drop>zgniłe mięso</drop>
    <opis>Atakuje gracza, po zblizeniu się na wystarczającą odległość.</opis>
    <wyglad><image url="xml/zombie.jpg"/></wyglad>
   </mob>
   <mob>
    <name>szkielet</name>
    <drop>kość, strzała, łuk</drop>
    <opis>Strzela do gracza za pomocą łuku.</opis>
    <wyglad><image url="xml/szkielet.png"/></wyglad>
   </mob>
  </agresywne>
 </swiat>
 <swiat type="nether">
  <typ>nether</typ>
  <wyglad><img url("xml/nether.jpg")></wyglad>
  <neutralne>
   <mob>
    <name>zombie pigman</name>
    <drop>złoty miecz, zgniłe mięso</drop>
    <opis>Po zaatakowaniu go, na gracza rzucają się wszystkie osobniki znajdujące się w pobliżu.</opis>
    <wyglad><image url="xml/pigman.png"/></wyglad>
   </mob>
   <mob>
    <name>enderman</name>
    <drop>perła</drop>
    <opis>Duże czarne humanoitalne stwory. Atakują po spojrzeniu się im w twarz.</opis>
    <wyglad><image url="xml/enderman.png"/></wyglad>
   </mob>
  </neutralne>
  <agresywne>
   <mob>
    <name>szkielet</name>
    <drop>kość, strzała, łuk</drop>
    <opis>Strzela do gracza za pomocą łuku.</opis>
    <wyglad><image url="xml/szkielet.png"/></wyglad>
   </mob>
   
   <mob>
    <name>witherowy szkielet</name>
    <drop>kość, węgiel, kamienny miecz</drop>
    <opis>Po zaatakowaniu nakłada efekt withera, które zzabiera pół serduszka zdrowia co sekundę.</opis>
    <wyglad><image url="xml/wither.jpg"/></wyglad>
   </mob>
   
   <mob>
    <name>blaze</name>
    <drop>pałka blazea</drop>
    <opis>Lata i strzela do gracza ognistymi pociskami.</opis>
    <wyglad><image url="xml/blaze.jpg"/></wyglad>
   </mob>
  </agresywne>
 </swiat>
 <swiat type="end">
  <typ>end</typ>
  <wyglad><imgage url="xml/end.jpg"/></wyglad>
  <neutralne>
   <mob>
    <name>enderman</name>
    <drop>perła</drop>
    <opis>Strzela do gracza za pomocą łuku.</opis>
    <wyglad><image url="xml/enderman.png"/></wyglad>
   </mob>
  </neutralne>
  <agresywne>
   <mob>
    <name>smok endu</name>
    <drop>exp</drop>
    <opis>Końcowy boss gry. Lata i pluje trującymi pociskami.</opis>
    <wyglad><image url="xml/end_dragon.jpg"/></wyglad>
   </mob>
   <mob>
    <name>shulker</name>
    <drop>pancerz shulkera</drop>
    <opis>Po trafieniu przez latające pociski shulkera, gracz lewituje przez jakiś czas w powietrzu.</opis>
    <wyglad><image url="xml/shulker.jpg"/></wyglad>
   </mob>
  </agresywne>
 </swiat>
</listaMobow>

I'm from Poland if you wonder which language is that. Whether my usage of xsl and xml is right, doesn't matter for me at the moment, since I haven't been able to even see the result of what I was doing there. I might ask for that later on tho'.

Answering kjhughes problem there was concerning the person asking using xslt version 2.0 instead of 1.0, which is definitely not a problem here, since I was using version 1.0 from the beginning. Also that person was using file located on the server, I'm only using local files. I didn't find any different solutions there and none were related to my problem. The only similarity here and there i see is that we both get the same error from browser, but cause for that is definitely different.

Piferman
  • 11
  • 2
  • this question has been associated to a different one, the answer to which is nowhere close to resolving my problem, is there any way i can unlink my questio, so that it's again visible? again i'm new here – Piferman Jan 09 '20 at 19:58
  • Which browser are you using? And which file are you opening in the browser? – michael.hor257k Jan 09 '20 at 20:42
  • 1
    It is highly likely that your problem is covered by the duplicate. If you disagree, please ***[edit] your question and explain how your case is special.*** Specifically, list how you've attended to each of the recommendations listed in the answers to that question. Do not just re-post the same question repeatedly. – kjhughes Jan 09 '20 at 20:43
  • There are lots of problems, to start with, markup like `` is not well-formed XML at all. And paths like `/swiat/pasywne/mob` make no sense in a document with a root element named `listaMobow`. So take it one step at a time, use a minimal but well-formed XML. – Martin Honnen Jan 09 '20 at 20:55
  • I'm using chrome, tho' i tried firefox, probably opera and edge as well. – Piferman Jan 09 '20 at 21:17
  • Martin Honnen do you think that using the right reference might solve that issue? I'll try making new clean xsl document, but I remember when there were any mistakes, browser output always pointed that out, and only after correcting them all, it showed my my code and the message above. – Piferman Jan 09 '20 at 21:31
  • If "I'm only using local files" is true, then I don't think you stand any chance to use client-side XSLT at all with current versions of Chrome or Firefox, Chrome for years does not allow it unless you start it with special command line options to lower its security settings, Firefox has for some exploit closed that approach some releases ago. Edge should still support it as far as I am aware but it is hard to tell where you fail, that XML sample is rather large and is not well-formed so I don't see how any browser would parse it at all successfully to use XSLT later on. – Martin Honnen Jan 09 '20 at 21:45
  • As @MartinHonnen mentions, and as the *duplicate answer clearly states* (read it again as you seemed to have missed it), **locally loaded XML/XSLT generally won't work due to security concerns of browser implementers**. As a beginner, your experience learning XML and XSLT will be greatly enhanced if you avoid browser-based XSLT; browsers haven't been an ideal XSLT development platform for more than a decade now. – kjhughes Jan 09 '20 at 22:01

0 Answers0