1

I have both these file in same local folder. XML file is 1.xml and xsl file is 1.xsl. When I open xml in Chrome it shows empty and for xsl file it gives this message "This XML file does not appear to have any style information associated with it. The document tree is shown below." and xml tree.

This is my xml

     <?xml version="1.0"?>
        <?xml-stylesheet type="text/xsl" href="1.xsl"?>

        <myBcollection>
        <businesscard>
        <organisation>V of S</organisation>
        <address>
            <no>42</no>
            <street>Foster Street</street>
            <city>Sydney</city>
            <county>sss</county>
        </address>
        <contactdetails>
            <contactNo type="landline">+94 71232312</contactNo>
            <fax>313234</fax>
            <email>er@gmail</email>
        </contactdetails>
        <website uri="http://w3.org"/>
    </businesscard>

    <businesscard>
        <organisation>Org 2</organisation>
        <address>
            <no>42</no>
            <street>Foster Street</street>
            <city>Sydney</city>
            <county>sss</county>
        </address>
        <contactdetails>
            <contactNo type="landline">1232312</contactNo>
            <fax>313234</fax>
            <email>er@gmail</email>
        </contactdetails>
        <website uri="http://w3.org"/>
    </businesscard>

    <businesscard>
        <organisation>Org 3</organisation>
        <address>
            <no>42</no>
            <street>Foster Street</street>
            <city>Sydney</city>
            <county>sss</county>
        </address>
        <contactdetails>
            <contactNo type="landline">+94 71232312</contactNo>
            <fax>313234</fax>
            <email>er@gmail</email>
        </contactdetails>
        <website uri="http://w3.org"/>
    </businesscard>
</myBcollection>

And this is my xsl

    <?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>

    <table border="1">
        <tr>
        <th>Org nm</th>
        <th>Adress Street</th>
        <th>City</th>
        <th>County</th>
        <th>Fax</th>
        </tr>

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

        <tr>

        <td><xsl:value-of select="myBcollection/businesscard/organisation"/></td>
        <td><xsl:value-of select="myBcollection/businesscard/address/street"/></td>
        <td><xsl:value-of select="myBcollection/businesscard/address/city"/></td>
        <td><xsl:value-of select="myBcollection/businesscard/address/county"/></td>
        <td><xsl:value-of select="myBcollection/businesscard/contactdetails/fax"/></td>
        </tr>
        </xsl:for-each>
    </table>

</body>
</html>
</xsl:template>
</xsl:stylesheet>
C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
Maduranga
  • 21
  • 4
  • I tested it with `firefox` and everything works as expected. May be a `chrome` security issue with client-side-XSLT-transformation. NoScript, for example, blocks this in `firefox`, too. Try disabling some security settings for `file:///...`. – zx485 Mar 08 '16 at 09:33
  • http://stackoverflow.com/questions/2981524/how-can-i-make-xslt-work-in-chrome – Joel M. Lamsen Mar 08 '16 at 09:34
  • 1
    This is Chrome's security settings. You can't use local XSL stylesheets like this; a stylesheet has to be on a web server, and the same server as your XML. – Flynn1179 Mar 08 '16 at 16:35

1 Answers1

0

you might not be able to use an XSL sheet locally with chrome, but you can use an html style element to style your xml, you just have to make sure you use the html namespace. Here is some example xml that is styled.

<?xml version="1.0" encoding="UTF-8"?>
<note>
    <style xmlns="http://www.w3.org/1999/xhtml">
        to, from, heading, body {display: block; }
    </style>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
</note>