3

I am coding in XML with an XSL attached.

When I open this in browsers (IE + Google Chrome) it displays a white screen. However when I open the same files in XML Notepad 2007 it displays the XML data with the correct styling from the XSL.

Am I missing something about displaying it browsers?

I have the standard declarations at the top and I can't see anything odd about my code; it's a very simple file I'm testing on to try and get it working.

XML Document

<?xml version = "1.0" encoding ="ISO-8859-1"?>

<?xml-stylesheet type ="text/xsl" href="menu.xslt"?>

<menu>
    <food>
        <name>Afternoon Tea</name>
        <description>Afternoon tea at Cuisine De Paris features a range of handmade mini sandwiches and delicate pastieries served with a selection of world tea</description>
        <price>£40</price>
    </food>

    <food>
        <name>Shrimp with sun rippened tomato and salad</name>
        <description>A medittearan inspired chef favourite bringing together the intense taste of tomatos with the subtle bite of the shrimp</description> 
        <price>£20</price>
    </food>

    <food> 
        <name>Gold encrusted egg yolk, chicken sand, rye and parmesan</name>
        <description>Ipsum</description>
        <price>£30</price>
    </food>

    <food>
        <name>Poached egg with couscous and salmon</name>
        <description>A delicated poached egg lavished with finiest French sourced cous cous</description> 
        <price>£25</price>
    </food>

    <food>
        <name>Slow roasted crab with a selection of the restaurant's finest vegetables</name>
        <description>Our crab is handmade and rested for two months before it's cooked in a slow cooker in a rich oil</description>
        <price>£30</price>
    </food>

    <food> 
        <name>Salmon wrapped parcel with white aspargus decorated with peas and a specalist sauce</name> 
        <description>A slowly smoked salmon sourced ethincally with a punchy English grown white aspargus, topped off with a beautifully cooked trademark sauce</description>
        <price>£27</price>
    </food>

    <food> 
        <name>Roasted crab with lime</name>
        <description>Our signature roasted crab with candied lime is the perfect dinner for a cold winter night</description>
        <price>£35</price>
    </food>

    <food> 
        <name>Fried cod with roasted sun blushed tomatoes and a green leaf sauce</name>
        <description>Our cod is fried in extra virgin oil, looking in all of the richest of the cod with the oil, occampanied by fresh roasted parsnips and authentic mediterrean sun blushed tomatoes.</description>
        <price>£40</price>
    </food>

    <food>
        <name>Green pea sauce with pork</name>
        <description>Our tender pork has been left to rest for 2 months before being served at Cuisine De Paris, making the succlent flavours shine in this dish. The green pea sauce is the perfect occampy to this tender pork dish.</description> 
        <price>£33</price>
    </food>

    <food>
        <name>Rabbit with creamy sauce</name>
        <description>Slow cooked rabbit in a warm vegetable stock topped with a creamy bread sauce and garnish</description>
        <price>£40</price>
    </food>

    <food>
        <name>Beef in a creamy garlic sauce wrapped in a tendor pork shell </name>
        <description>Locally sourced beef joints are used to create this infusion of flavours, dressed with a range of heart warmly cooked vegetables</description>
        <price>£40</price>
    </food>

    <food>
        <name>Noodles with carrot soup</name>
        <description>Authentic Japense transulcent noodles in a freshly made carrot soup infused with giner and cinnamon</description>
        <price>£30</price>
    </food>

    <food>
        <name>Salmon served with a pea sauce and vegetables</name>
        <description>Our salmon is slowly cooked to look in the richest and flavours with are brought our with the pea sauce and accompaning vegetables</description>
        <price>£38</price>
    </food>

    <food> 
        <name>Oatmeal caramel stack topped with caramel</name>
        <description>Handmade oatcakes layered between a creamy caramel sauce topped with an interuicty designed caramel decoration</description>
        <price>£20</price>
    </food>

    <food>
        <name>Vanillia icecream wrapped in shoe pastry encompassed in a vanilla chocolate decoration</name>
        <description>Vanilla ice cream handmade to a Cuisine De Paris own recipe with poppy seeds, wrapped in a rich shoe pastry and beautiful decoration</description>
        <price>£25</price>
    </food>

    <food>
        <name>A strawberry ice cream swirl with mango icecream</name>
        <description>Our delicate strawberry ice cream swirl is a treat for both adults and children a like with an additional handmade mango ice cream for complementary flavours</description>
        <price>£25</price>
    </food>

    <food>
        <name>Chocolate sponge in a hot fudge sauce</name> 
        <description>A light sponge filled with a creamy chocolate mousse bathed in a rich hot fudge sauce</description>
        <price>£20</price>
    </food>

    <food> 
        <name>A light after dinner pate</name>
        <description>A liver and thyme pate is a wonderful option for a savoy dessert with us. With ethically sourced pork to combination of flavours really hits the spot</description>
        <price>£23</price>
    </food>

    <food>
        <name>A vanillia mousse wrapped in chocolate shoe pastry on top of an oatmeal biscuit and coffee chocolate ice cream</name>
        <description>Our handmade vanillia mousse is the perfect finish to a meal at Cuisine De Paris and with an extragant chocolate dome to complete the dessert the rich flavours will leave you wanting more</description>
        <price>£30</price>
    </food>
</menu>

XSLT Stylesheet

<?xml version = "1.0"?>
<xsl:stylesheet version ="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "/">
    <html>
    <body style="font-family:Arial, helvetica, sans-serif; font-size: 12pt; background-color:#EEEEEE">
        <xsl:for-each select="menu/food">
            <div style = "background-color:#009134; color:white; padding: 4px">
                <span style = "font-weight: bold; color: white">
                    <xsl:value-of select ="name"/>
                </span>
            - <xsl:value-of select="price"/>
        </div>
        <div style = "margin-left: 20px; margin-bottom: 1em; font-size: 10pt">
            <xsl:value-of select="description"/>
            <span style ="font-style:italic">
                (<xsl:value-of select = "price"/> Price per serving)
            </span>
        </div>
        </xsl:for-each>
    </body>
    </html>
</xsl:template>
</xsl:stylesheet>

Opening in IE shows the xml code in a long line (no formatting but not in tree form) and Google Chrome displays a blank page

Daisy Ward
  • 87
  • 1
  • 1
  • 7
  • Are you fetching the XSL from a WebServer, or from the [FileSystem](http://stackoverflow.com/a/6251757/314291)? – StuartLC Dec 31 '14 at 10:55
  • 2
    Please show the XML and XSLT stylesheet so that we can reproduce your problem. Thanks! – Mathias Müller Dec 31 '14 at 10:59
  • There's nothing wrong with your XML/XSLT code. I believe StuartLC gave you the answer regarding Chrome. I don't know about IE - perhaps check in yet another browser, e.g. Firefox. Also make sure the XSLT file's name and path matches exactly the link in your XMl. – michael.hor257k Dec 31 '14 at 11:42
  • Chrome is known not to support XSLT referenced in an XML document loaded from the file system, you would need to load the XML and XSLT from an HTTP server or you would need to start Chrome with special security settings. As for IE, what does its error console (F12) say? – Martin Honnen Dec 31 '14 at 11:43
  • Your XML document is well-formed and the XSLT is correct. What versions are you using exactly? Can you try Firefox, too? – Mathias Müller Dec 31 '14 at 11:43

1 Answers1

0

Try this,

Change symbol '£' to respective unicode value &#163; in u r XML file, then I got the result.

enter image description here

Rudramuni TP
  • 1,268
  • 2
  • 16
  • 26
  • Please stop adding useless answers. This does not answer the question at all. You're not even saying what browser or XSLT processor you have used. – Mathias Müller Dec 31 '14 at 12:15
  • 1
    Thank you! That solved my problem! I am getting it displayed the same as you in IE. – Daisy Ward Dec 31 '14 at 12:17
  • @MathiasMüller, just I suggested to change the input XML file content, not in the XSLT (any version), or any browser, again asking sorry. – Rudramuni TP Dec 31 '14 at 12:20
  • @DWard I would be surprised to learn that the introduction of a character entity solved this problem. With my version of IE (11) the pound symbol is shown correctly, as is, without converting the character to an entity. – Mathias Müller Dec 31 '14 at 12:33
  • @MathiasMüller Whilst it did seem like a simple solution it did work. I am also using IE 11 and when I did view the document in XML Notepad it did show the wrong symbol (the A with accent) so it might have been because there was an error on the page possibly – Daisy Ward Jan 01 '15 at 20:02
  • @DWard Simple solutions should always be encouraged, so that's not why I keep commenting here. But it's a solution to an encoding problem - unrelated to the problem you have described above - namely, that the _browser displays a "white screen"_. Questions and answers should match on Stackoverflow, one of its very basic principles. – Mathias Müller Jan 01 '15 at 20:31
  • @MathiasMüller, I assume that up to finding the right answer thru ENCODING, I hope this is right answer, User got the required result and accepted also. There may be many ways to answer THE question. I am welcoming the other ANSWERs also. – Rudramuni TP Jan 02 '15 at 09:38