xml, xsl, css ... in netscape

M

mali djuro

Hi, all.
i try to use xsl to show xml in IE6+ and NN7+

i got:

index.htm

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link rel="stylesheet" href="./css/style.css">

<script language="JavaScript">
function init(){

//here is checking of browser -> type is IE or
NN
var docXML = initXML(type);
var docXSL = initXML(type);

if (type == "NN"){
var count = 0;
docXML.onload = transform;
docXML.load(test.xml);
docXSL.onload = transform;
docXSL.load(test.xsl);

}
else if (type == "IE"){
docXML.async = false;
docXML.load(test.xml);
docXSL.async = false;
docXSL.load(test.xsl);
document.write(docXML.transformNode(docXSL));
}

function transform(){
count++;
if (count == 2){
var xsltProcessor = new XSLTProcessor();
var outdoc = initXML(type);
xsltProcessor.transformDocument(docXML,
docXSL, outdoc, null);


document.write(outdoc.documentElement.innerHTML);
}
}
}

</script>
</head>
<body bgcolor="#EFEFEF">
<script language="JavaScript"> init(); </script>
</body>
</html>

test.xsl:

<?xml version="1.0" encoding="ISO-8859-2"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="root">
<html>
<head />
<body bgcolor="#EFEFEF">

<table bordercolor="#ffffff" cellspacing="0" width="98%"
bordercolorlight="#6b5c35" border="1" cellpadding="0">
<tr>
<td align="center" class="captionXSL"> TEST </td>
</tr>
</table>
...
</body>
</html>
</xsl:template>
</xsl:transform>

style.css

..captionXSL {
font: 12px Arial;
font-weight: bold;
}

in IE it all works OK.
styles define in style.css are used in transformation of XML with XSL in
HTML

but in NN
there is no styles. It shows all needed data but it didn't read and apply
styles.

i hope you will help me.

thanks
 
O

Oleg Tkachenko

mali said:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link rel="stylesheet" href="./css/style.css">

<script language="JavaScript">
function init(){

//here is checking of browser -> type is IE or
NN
var docXML = initXML(type);
var docXSL = initXML(type);

if (type == "NN"){
var count = 0;
docXML.onload = transform;
docXML.load(test.xml);
docXSL.onload = transform;
docXSL.load(test.xsl);

}
else if (type == "IE"){
docXML.async = false;
docXML.load(test.xml);
docXSL.async = false;
docXSL.load(test.xsl);
document.write(docXML.transformNode(docXSL));
}

function transform(){
count++;
if (count == 2){
var xsltProcessor = new XSLTProcessor();
var outdoc = initXML(type);
xsltProcessor.transformDocument(docXML,
docXSL, outdoc, null);


document.write(outdoc.documentElement.innerHTML);

But should it work at all? You are replacing current page's content with
completely different one, which doesn't have link to css.
PS. Why not using <?xml-stylesheet PI?
 
M

mali djuro

Oleg Tkachenko said:
But should it work at all? You are replacing current page's content with
completely different one, which doesn't have link to css.

It works, under IE6, and in NN7 it doesn't shows styles.
but when i remove <html>,<head> and <body> tags from test.xsl
in NN7 there is no data, it is just blank page with word undefined in upper
left corner.
PS. Why not using <?xml-stylesheet PI?

i try to avoid it, because i made xml generator with no possibility to set
PI.
and now i would like to use it here if it is possible.
thanks
 
M

mali djuro

What if you insert <link rel="stylesheet" href="./css/style.css"> into
test.xsl? I mean if you new generated HTML doesn't contain a link to CSS, so
why styles should work?

i am confused too. only reasonbly explanation is that with transformation i
got
just element, not a whole document. and it pass in IE.

 
O

Oleg Tkachenko

mali said:
It works, under IE6, and in NN7 it doesn't shows styles.
but when i remove <html>,<head> and <body> tags from test.xsl
in NN7 there is no data, it is just blank page with word undefined in upper
left corner.
What if you insert <link rel="stylesheet" href="./css/style.css"> into
test.xsl? I mean if you new generated HTML doesn't contain a link to CSS, so
why styles should work?
 
O

Oleg Tkachenko

mali said:
i am confused too. only reasonbly explanation is that with transformation i
got
just element, not a whole document. and it pass in IE.

Well, actually I wanted to say that generated HTML document doesn't have any
link to CSS, right? So this looks to me like your problem. Have you tried to
add link to XSL:

<xsl:template match="root">
<html>
<head>
<link rel="stylesheet" href="./css/style.css">
</head>
<body bgcolor="#EFEFEF">
 
M

mali djuro

Oleg Tkachenko said:
Well, actually I wanted to say that generated HTML document doesn't have any
link to CSS, right? So this looks to me like your problem. Have you tried to
add link to XSL:

<xsl:template match="root">
<html>
<head>
<link rel="stylesheet" href="./css/style.css">
</head>
<body bgcolor="#EFEFEF">

yes, i tried it,
but in this case, even in IE,
styles are not applied

 
M

mali djuro

Oleg Tkachenko said:
Hmmm, chances are that ./css/style.css is not resolved properly in that case -
can you try with absolute URL like <link rel="stylesheet"
href="http://foo.com/css/style.css"> ?

hi,
i found out how to applied styles in NN. i used a little bit of everithing
and mixed and now it works. but i still have problems.
it is not problem that stops program or breaks it, but it borders me.
when i make transformations, and if i call some javascript functions inside
it, for example i have function to generate navigation menu in pages, and
when i call it, menu is written but NN never stops loading page. when i stop
loading and view sourcd page, i found out that code of menu is written
behind </html> tag.
if you have some experience in this or now how to solve it, plesae help.

thanks.

here is xsl file with that function

test.xsl:

....
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<link rel="stylesheet" href="./css/menu.css" />

<script language="JavaScript"
src="./menu/menu.js"></script>
</head>

<body bgcolor="#EFEFEF">

<script language="JavaScript">
make_menu();
</script>

.....


page source is:

...
</table>
</body>
</html>
<a id="e0_0o" class="oout" href="main.htm" style="position:
absolute; top: 11px; left: 10px; width: 149px; height: 24px; visibility:
hidden; z-index: 0;" onclick="return A_MENUS[0].onclick(0);"
onmouseout="A_MENUS[0].onmouseout(0);"
onmouseover="A_MENUS[0].onmouseover(0);"
onmousedown="A_MENUS[0].onmousedown(0);"><div id="e0_0i"
class="iout">main</div></a>
<a id="e0_1o" class="oout" href="" style="position: absolute; top:
11px; left: 159p
.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top