Forum Moderators: open

Message Too Old, No Replies

XSL, XML and style within an iframe

         

nightqueen

12:45 pm on Feb 20, 2005 (gmt 0)

10+ Year Member



I have an HTML <iframe> that links to a XML file that has a XSL stylesheet attached.

I have a class "heading" described in the CSS stylsheet for the main HTML page (works fine with other parts of the HTML page) but when I try to use class="heading" within the HTML in the XSL file, it doesn't show up the formatting in the <iframe>.

Does anyone know how I can get this to work? Or do I need to use the style attribute within the HTML in the XSL file?

choster

7:52 am on Feb 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I read your post correctly, the behavior is correct. The content loaded inside an <iframe> is a separate document, and as such it should not inherit styles from the page which contains it.

I've never done what you describe-- it seems like you are depending on the user's browser having an XSL engine installed, which can be tricky since older versions of MSXML are designed for XML/SL specs which did not become part of the standard. However, to start you should import the stylesheet into the output document (the one appearing in the <iframe>), which should be a trivial matter:

<xsl:stylesheet>
<xsl:template match="/">
<html>
<head>
<title>Output document to be loaded in iframe</title>
<!-- css for formatting the output -->
<link rel="stylesheet" href="/site.css" />
</head>
<body>
<p>Your document</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

nightqueen

8:22 pm on Feb 22, 2005 (gmt 0)

10+ Year Member



Ah right. I get you.

Yes, I think I was assuming the data that was inside the iframe was part of the main page. In effect though there are 2 seperate pages that are viewed within one browser window.

Thanks for that :)