Posted on 2006-06-06
Last Modified: 2013-11-18
We want to include CSS information (.css) in XSLT for presentation in (X)HTML.
How to?
Question by:go4java
    1 Comment
    LVL 60

    Accepted Solution

    Hi go4java,

    You can just stuff your CSS in your result document as you would do with a static HTML file

    here is an example

    test XML
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet href="mystyle.xsl" type="text/xsl"?>
        <elemA>This should be blue</elemA>
        <elemB>This should be green</elemB>

    <xsl:stylesheet xmlns:xsl="" version="1.0">
    <xsl:template match="/">
                    .blue {background-color: blue;}
                    .green {background-color: green;}
        <xsl:template match="elemA">
            <p class="blue"><xsl:value-of select="."/></p>
        <xsl:template match="elemB">
            <p class="green"><xsl:value-of select="."/></p>

    <link> is as easy


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
    Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now