Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Firefox error

  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Firefox error

    Error in Firefox:
    Error loading stylesheet: Parsing an XSLT stylesheet failed.
    IE reads the page fine.

    xml file
    Code:
    <?xml-stylesheet type="text/xsl" href="manager1.xsl"?>
    <company>
    	<name>Acme Rocket Company</name>
    	<manager>
    		<name>Phil Schwarts</name>
    		<title>Chief Executive Officer</title>
    		<canHire>yes</canHire>
    		<vested/>
    	</manager>
    	<division>
    		<name>Finance</name>
    		<manager>
    			<name>James Galway</name>
    			<title>Chief Financial Officer</title>
    			<canHire>yes</canHire>
    			<vested/>
    		</manager>
    	</division>
    	<division>
    		<name>Research</name>
    		<manager>
    			<name>Benny Jocum</name>
    			<title>Chief Technical Officer</title>
    			<canHire>yes</canHire>
    		</manager>
    		<manager>
    			<name>Allison Hart</name>
    			<title>Vice President, Year 2000 Issues</title>
    			<canHire>no</canHire>
    		<vested/>
    		</manager>
    		<section>
    		<name>COBOL Programming</name>
    		<manager>
    			<name>Jerry Garcia</name>
    			<title>Director, COBOL Systems</title>
    		</manager>
    		</section>
    	</division>
    </company>
    xsl file
    Code:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    <!-- Match the XML #document node -->
    <xsl:template match="/">
    	<ul>
    		<xsl:apply-templates select="company"/>
    	</ul>
    </xsl:template>
    
    <xsl:template match="company">
    	<li>
    			<span><b><xsl:value-of select="name"/></b></span>
    			<xsl:apply-templates select="manager"/>
    		<!-- Calls following listed items to appear under Company, Name and position title -->
    		<ul>
    			<xsl:apply-templates select="division"/>
    		</ul>
    	</li>
    </xsl:template>
    
    <xsl:template match="division">
    	<li>
    			<span><b><xsl:value-of select="name"/></b></span>
    			<xsl:apply-templates select="manager"/>
    		<!-- Calls following listed items to appear under Division, Name and position title -->
    		<ul>
    			<xsl:apply-templates select="section"/>
    		</ul>
    	</li>
    </xsl:template>
    
    <xsl:template match="section">
    	<li>
    		<span><b><xsl:value-of select="name"/></b></span>
    		<xsl:apply-templates select="manager"/>
    	</li>
    </xsl:template>
    
    	<xsl:template match="manager">
    		<!-- format and output the result -->
    		<span><xsl:value-of select="name"/>
    		<i><xsl:value-of select="title"/></i></span>,
    	</xsl:template>
    </xsl:stylesheet>

  • #2
    Regular Coder
    Join Date
    Jan 2006
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Solution found

    Javascript is needed to initiate the XML Parsar.

    EXAMPLE:
    Code:
    <html><head>
    <script type="text/javascript">
    var xmlDoc
    function loadXML()
    {
    //load xml file
    // code for IE
    if (window.ActiveXObject)
      {
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async=false;
      xmlDoc.load("simpleXML.xml");
      getmessage()
      }
    // code for Mozilla, etc.
    else if (document.implementation &&
    document.implementation.createDocument)
      {
      xmlDoc= document.implementation.createDocument("","",null);
      xmlDoc.load("simpleXML.xml");
      xmlDoc.onload=getmessage
      }
    else
      {
      alert('Your browser cannot handle this script');
      }
    }
    function getmessage()
    {
    document.getElementById("to").innerHTML=
    xmlDoc.getElementsByTagName("to")[0].firstChild.nodeValue
    document.getElementById("from").innerHTML=
    xmlDoc.getElementsByTagName("from")[0].firstChild.nodeValue
    document.getElementById("message").innerHTML=
    xmlDoc.getElementsByTagName("body")[0].firstChild.nodeValue
    }
    </script>
    </head>
    <body onload="loadXML()" bgcolor="white">
    <h1>W3Schools XML Internal Note</h1>
    <p><b>To:</b> <span id="to"></span><br />
    <b>From:</b> <span id="from"></span>
    <hr/>
    <b>Message:</b> <span id="message"></span>
    </body></html>
    Called page:
    Code:
    <?xml version="1.0"?>
    <script type="text/javascript">
    var txt="<note>"
    txt=txt+"<to>Tove</to><from>Jani</from>"
    txt=txt+"<heading>Reminder</heading>"
    txt=txt+"<body>Don't forget me this weekend!</body>"
    txt=txt+"</note>"
    
    var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
    xmlDoc.async="false"
    xmlDoc.loadXML(txt)
    </script>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •