Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using CSS with XML/XSL 1

Status
Not open for further replies.

kenrbnsn

Technical User
Jun 7, 2002
606
US
Now that I've mastered :) HTML/CSS/PHP/MySQL (-: I'm tackling XML/XSL...

How would I use an external CSS stylesheet with code generated by an XSL file? The examples that I've seen so far are a mixture of old fashioned HTML styling tags, in line styles, and tables.

Since I've gotten away from the HTML styling tags and tables, I don't want to go back to using them if I start using XSL files.

Thanks in advance.

Ken
 
What are you expecting XSL to do?

It is generally used to Transform XML into HTML...

It will generally look like this...
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:template match="/">
  <html>
    <head>
      [b]<link rel="stylesheet" type="text/css" href="mycss.css" />[/b]
    </head>
    <body>
      ...

Or, If you want the CSS to be set by the XML...
Code:
<myxml>
  <mycss>mycss.css</mycss
  ...
</myxml>

You can do this:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:template match="/">
  <html>
    <head>
      [b]<link rel="stylesheet" type="text/css" href="[COLOR=red]{mycss}[/color]" />[/b]
    </head>
    <body>
      ...

If you want to use CSS without HTML tags, you can use it directly with XML, and you won't need XSL...

See this example:

Again, if you want to use XSL to arrive at the XML + CSS then look into this:

Such as:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:template match="/">
  [b]<xsl:processing-instruction name="xml-stylesheet">
    href="[COLOR=red]<xsl:value-of select="mycss" />[/color]" type="text/css"
  </xsl:processing-instruction>[/b]
  <article>
    ...





Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Thanks, those are the pointers I've been looking for...

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top