Linking to a separate CSS in XSL

Jyrki Keisala

Usenet Archive
Joined
Dec 15, 2003
Messages
12
Reaction score
0
I am a newbie in using XSL to transform my XML documents into HTML. Let's say I have an XML like this:

foo.xml:

<?xml version="1.0" ?>
<?xml:stylesheet type="text/xsl" href="foo.xsl"?>

<root>

<element>
<name>Brian</name>
<email></email>
</element>

<element>
<name>Jeff</name>
<email></email>
</element>
..
..
</root>

Now I'd like to convert my XML data into a HTML table, by using the XSL.
The basic trick I can handle:

foo.xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/">

<html>

<head>
<title>My contacts</title>
</head>

<body>
<h1>All of my contacts in one huge table</h1>
<p>
An ordinary paragraph of text.
</p>
<table border="1">
<tr>
<td>Name</td>
<td>E-mail address</td>
</tr>
<xsl:for-each select="root/element">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="email"/></td>
</tr>
</xsl:for-each>
</table>
</body>

</html>

</xsl:template>
</xsl:stylesheet>

Question: what if I want to format the HTML table created by a separate CSS file, say "my_style.css"? That file includes the normal CSS style definitions like

my_style.css:

p,table,li,h1,h2,h3
{
font-family: verdana, arial, 'sans serif';
}

p, h1, h2, h3, table, li, hr
{
margin-left: 10pt;
}

p,li,th,td
{
font-size: 75%;
}

Where in my XSL can I put the link to a separate CSS, to take all of that style formatting into use in my XSL-generated HTML table? Or is there some other mechanism for that in XSL?
 

Maarten Wiltink

Usenet Archive
Joined
Oct 11, 2001
Messages
108
Reaction score
0
[...]
Now I'd like to convert my XML data into a HTML table, by using the XSL.
The basic trick I can handle:

foo.xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/">

<html>

<head>
<title>My contacts</title>

</head>

</html>

</xsl:template>
</xsl:stylesheet>

Question: what if I want to format the HTML table created by a separate CSS file, say "my_style.css"? That file includes the normal CSS style definitions like

See above. The idea is that the output HTML document refers to the stylesheet.

Groetjes,
Maarten Wiltink
 

Jyrki Keisala

Usenet Archive
Joined
Dec 15, 2003
Messages
12
Reaction score
0
[...]
Now I'd like to convert my XML data into a HTML table, by using the XSL. The basic trick I can handle:

foo.xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/">

<html>

<head>
<title>My contacts</title>

</head>

</html>

</xsl:template>
</xsl:stylesheet>

Question: what if I want to format the HTML table created by a separate CSS file, say "my_style.css"? That file includes the normal CSS style definitions like

See above. The idea is that the output HTML document refers to the stylesheet.

Groetjes,
Maarten Wiltink

Are you actually using that trick? I tried to do just that, but got an error message from the IE.
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Jyrki said:
[...]
Now I'd like to convert my XML data into a HTML table, by using the XSL. The basic trick I can handle:

foo.xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/">

<html>

<head>
<title>My contacts</title>

Add <link rel="stylesheet" type="text/css" href="my_style.css"/> here.


</html>

</xsl:template>
</xsl:stylesheet>

Question: what if I want to format the HTML table created by a separate CSS file, say "my_style.css"? That file includes the normal CSS style definitions like

See above. The idea is that the output HTML document refers to the stylesheet.

Groetjes,
Maarten Wiltink

Are you actually using that trick? I tried to do just that, but got an error message from the IE.

Which error message?
 

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

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top