1

I need to create xml and xsl files, but it seems that the xml file does not recognize the xsl file.

xml file:

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

<ProgrammingLanguages>
  
<ProgrammingLanguage type="webApp" name="csharp">
  <name type="official" lang="en">C#</name>
  <commonName type="common" lang="en">sharp</commonName>
  <createdBy type="company">Microsoft</createdBy>
  <yearOfAppearance type="year">2000</yearOfAppearance>
  <users type="users">Microsoft, Apple, Google</users>
  <img src="csharpLogo.png"></img>
</ProgrammingLanguage>

<ProgrammingLanguage type="webApp" name="javascript">
  <name type="official" lang="en">JavaScript</name>
  <commonName type="common" lang="en">js</commonName>
  <createdBy type="company">Netscape</createdBy>
  <yearOfAppearance type="year">1995</yearOfAppearance>
  <users type="users">Microsoft, Netscape, Oracle</users>
  <img src="javascriptLogo.png"></img>
</ProgrammingLanguage>

<ProgrammingLanguage type="webApp" name="java">
  <name type="official" lang="en">Java</name>
  <commonName type="common" lang="en">J</commonName>
  <createdBy type="company">Sun Microsystems</createdBy>
  <yearOfAppearance type="year">1995</yearOfAppearance>
  <users type="users">Apple, Oracle, Google</users>
  <img src="javaLogo.jpg"></img>
</ProgrammingLanguage>

</ProgrammingLanguages>

xsl file:

<?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>
        <body>
            <h2>Programming Languages</h2>
            <table border="1">
                <tr>
                    <th>Official name: </th>
                    <th>Common name: </th>
                    <th>Created by: </th>
                    <th>Year of appearance: </th>
                    <th>Users: </th>
                    
                </tr>
                <xsl:for-each select="ProgrammingLanguages/ProgrammingLanguage">
                    <tr>
                        <td><xsl:value-of select="name"/></td>
                        <td><xsl:value-of select="commonName"/></td>
                        <td><xsl:value-of select="createdBy"/></td>
                        <td><xsl:value-of select="yearOfAppearance"/></td>
                        <td><xsl:value-of select="users"/></td>
                    </tr>
                </xsl:for-each>
            </table>
        </body>   
    </html>
</xsl:template>
</xsl:stylesheet>

Output: enter image description here

I used xml validator and everything is alright. I tried Firefox, then I tried Chrome and Edge, but everytime the xml is displayed just like a text document without any tables and structures from xsl.

I tried other people's code also, but it doesn't work on my computer while it works on their computers.

I need to show xml file properly in browser and add some css. For example I need to put all the data in a table that you can see in xsl file.

JakubCzura
  • 91
  • 8

0 Answers0