chelvis
03-12-2003, 09:40 PM
I have 3 files (xml, xsl and a .css). I have pasted the codes below for these. When I go to the browser and view the hamlet.xml file, I see every thing as one paragraph. It seems like the .css file is not being used by the xsl or xml. How can I make this look like the way I want (specified in the .css)?
Hamlet.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Hamlet.xsl"?>
<EXTRACT>
<ACT><TITLE>ACT I</TITLE>
<SCENE><TITLE>SCENE I. Elsinore. A platform before the castle.</TITLE>
<STAGEDIR>FRANSICO at his post. Enter to him BERNARDO</STAGEDIR>
<SPEECH>
<SPEAKER>BERNARDO</SPEAKER>
<LINE>Who's there?</LINE>
</SPEECH>
<SPEECH>
<SPEAKER>FRANSICO</SPEAKER>
<LINE>Nay, answer me: stand, and unfold yourself.</LINE>
</SPEECH>
<SPEECH>
<SPEAKER>BERNARDO</SPEAKER>
<LINE>Long live the king!</LINE>
</SPEECH>
</SCENE>
</ACT>
</EXTRACT>
Hamlet.css
ACT TITLE {
display:block;
font-size:10pt;
color:red;
font-weight:bold;
margin-bottom:12pt;
}
SCENE TITLE {
display:block;
font-size:12pt;
color:green;
margin-bottom:6pt;
}
STAGEDIR {
display:block;
font-style:italic;
margin-top:6pt;
margin-bottom:6pt;
}
SPEAKER {
display:block;
}
LINE {
display:block;
margin-left:2em;
}
Hamlet.xsl
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*|/"><xsl:apply-templates/>
</xsl:template>
<xsl:template match="EXTRACT">
<HTML>
<HEAD>
<TITLE>Hamlet</TITLE>
<LINK REL="StyleSheet" type="text/css" HREF="Hamlet.css" />
</HEAD>
<BODY>
<xsl:apply-templates/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="ACT/TITLE">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="SCENE/TITLE">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="STAGEDIR">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="SPEAKER">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="LINE">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
Hamlet.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Hamlet.xsl"?>
<EXTRACT>
<ACT><TITLE>ACT I</TITLE>
<SCENE><TITLE>SCENE I. Elsinore. A platform before the castle.</TITLE>
<STAGEDIR>FRANSICO at his post. Enter to him BERNARDO</STAGEDIR>
<SPEECH>
<SPEAKER>BERNARDO</SPEAKER>
<LINE>Who's there?</LINE>
</SPEECH>
<SPEECH>
<SPEAKER>FRANSICO</SPEAKER>
<LINE>Nay, answer me: stand, and unfold yourself.</LINE>
</SPEECH>
<SPEECH>
<SPEAKER>BERNARDO</SPEAKER>
<LINE>Long live the king!</LINE>
</SPEECH>
</SCENE>
</ACT>
</EXTRACT>
Hamlet.css
ACT TITLE {
display:block;
font-size:10pt;
color:red;
font-weight:bold;
margin-bottom:12pt;
}
SCENE TITLE {
display:block;
font-size:12pt;
color:green;
margin-bottom:6pt;
}
STAGEDIR {
display:block;
font-style:italic;
margin-top:6pt;
margin-bottom:6pt;
}
SPEAKER {
display:block;
}
LINE {
display:block;
margin-left:2em;
}
Hamlet.xsl
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*|/"><xsl:apply-templates/>
</xsl:template>
<xsl:template match="EXTRACT">
<HTML>
<HEAD>
<TITLE>Hamlet</TITLE>
<LINK REL="StyleSheet" type="text/css" HREF="Hamlet.css" />
</HEAD>
<BODY>
<xsl:apply-templates/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="ACT/TITLE">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="SCENE/TITLE">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="STAGEDIR">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="SPEAKER">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="LINE">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>