Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Linking to a separate CSS in XSL

Reply
Thread Tools

Linking to a separate CSS in XSL

 
 
Jyrki Keisala
Guest
Posts: n/a
 
      12-15-2003
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>(E-Mail Removed)</email>
</element>

<element>
<name>Jeff</name>
<email>(E-Mail Removed)</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 xmlnssl="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?
 
Reply With Quote
 
 
 
 
Maarten Wiltink
Guest
Posts: n/a
 
      12-15-2003
"Jyrki Keisala" <(E-Mail Removed)> wrote in message
news:Xns9452838F4E0ECzoltanjippiifi@131.228.6.99.. .
[...]
> 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 xmlnssl="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.


> </head>


<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


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

Groetjes,
Maarten Wiltink


 
Reply With Quote
 
 
 
 
Jyrki Keisala
Guest
Posts: n/a
 
      12-15-2003
"Maarten Wiltink" <(E-Mail Removed)> wrote in
news:3fdd99fa$0$211$(E-Mail Removed)4all.nl:

> "Jyrki Keisala" <(E-Mail Removed)> wrote in message
> news:Xns9452838F4E0ECzoltanjippiifi@131.228.6.99.. .
> [...]
>> 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 xmlnssl="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.
>
>
>> </head>

>
> <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

>
> 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.
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      12-15-2003


Jyrki Keisala wrote:

> I am a newbie in using XSL to transform my XML documents into HTML.


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


Are you sure you want that namespace http://www.w3.org/TR/WD-xsl?
The correct namespace for XSLT 1.0 is http://www.w3.org/1999/XSL/Transform.
Only older IE versions should support http://www.w3.org/TR/WD-xsl but
the language defined by that namespace is different from XSLT 1.0.



--

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      12-15-2003


Jyrki Keisala wrote:

> "Maarten Wiltink" <(E-Mail Removed)> wrote in
> news:3fdd99fa$0$211$(E-Mail Removed)4all.nl:
>
>
>>"Jyrki Keisala" <(E-Mail Removed)> wrote in message
>>news:Xns9452838F4E0ECzoltanjippiifi@131.228.6.99 ...
>>[...]
>>
>>>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 xmlnssl="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.
>>
>>
>>
>>></head>

>>
>><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

>>
>>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?
--

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Separate Tabs, Separate Sessions BigAndy Firefox 0 05-09-2007 09:27 AM
Separate Tabs, Separate Sessions BigAndy Firefox 0 05-09-2007 09:26 AM
Using separate classpaths for separate classes? Frank Fredstone Java 1 06-27-2006 06:46 AM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
How to use several separate classes (separate files) to be executed in one class (another file) EvgueniB Java 1 12-15-2003 01:18 AM



Advertisments