-
Display XML element attributes in CSS or XSL
Hello expert,
I am using CSS and XSL to display the elements
of an XML files in a browser. I would like to
display the attributes of one of the elements.
Is there a way of doing this?
Thanks.
Allen Pitts, Web Developer, Dallas Texas
+++++++++++++++++++++++++++
XML CSS combination
XML file
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="master_marketing_messages_style.css"?>
<NEOF_NV_MESSAGES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mkt_messages_new021021acp.xsd">
<NV_MESSAGE Alliance="UHC">
<SHORT_DESCRIPTION>Short marketing message </SHORT_DESCRIPTION>
<LONG_DESCRIPTION>This is the long marketing message. This is the long marketing
message.</LONG_DESCRIPTION>
<START_DATE>2002-10-21T08:00:00</START_DATE>
<END_DATE>2002-11-21T08:00:00</END_DATE>
</NV_MESSAGE>
</NEOF_NV_MESSAGES>
CSS File
/* This is a cascading stylesheet for
use with Marketing_Message*/
NEOF_NV_MESSAGES
{
display: block;
font-family: Arial, Helvetica, sans-serif;
}
SHORT_DESCRIPTION
{
display: block;
font-size: 14pt;
font-weight: bold;
color: blue;
border-top: 2px solid #888833;
border-bottom: 2px solid #888833;
background-color: #FFFFDD;
}
LONG_DESCRIPTION
{
display: block;
font-size: 12pt;
}
START_DATE
{
display: block;
font-size: 8pt;
}
END_DATE
{
display: block;
font-size: 8pt;
}
++++++++++++++++++++
XML XSL combination
XML file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="Marketing_Message_021031XSLacpC.xsl"?>
<!-- this is the root element-->
<NEOF_NV_MESSAGES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mkt_messages_new.xsd">
<NV_MESSAGE Alliance="UHC" Type="NEW">
<SHORT_DESCRIPTION>The Short MessageŽ
</SHORT_DESCRIPTION>
<LONG_DESCRIPTION>This the Long Message text. This the Long Message text
This the Long Message text</LONG_DESCRIPTION>
<START_DATE>2002-10-24T08:00:00</START_DATE>
<END_DATE>2002-11-24T08:00:00</END_DATE>
</NV_MESSAGE>
</NEOF_NV_MESSAGES>
XSL file
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<!-- XML style sheet for Marketing_ Message_021031XSLacpC.xml -->
<HTML>
<BODY>
<xsl:for-each select="NEOF_NV_MESSAGES/NV_MESSAGE">
<TABLE border="1">
<TR> <TD bgcolor="#637aac">
<font face="arial, helvetica, san-serif" size="2" color="FFFFFF">
This is the Short Message:
</font>
</TD>
<TD>
<font face="arial, helvetica, san-serif" color="red" size="5">
<xsl:value-of select="SHORT_DESCRIPTION"/>
</font>
</TD> </TR>
<TR> <TD bgcolor="#637aac">
<font face="arial, helvetica, san-serif" size="2" color="FFFFFF">
This is the Long Message:
</font>
</TD>
<TD>
<font face="arial, helvetica, san-serif" size="3">
<xsl:value-of select="LONG_DESCRIPTION"/>
</font>
</TD> </TR>
<TR> <TD bgcolor="#637aac">
<font face="arial, helvetica, san-serif" size="2" color="FFFFFF">
This is the Start Date:
</font>
</TD>
<TD>
<font face="arial, helvetica, san-serif" size="2">
<xsl:value-of select="START_DATE"/>
</font>
</TD> </TR>
<TR> <TD bgcolor="#637aac">
<font face="arial, helvetica, san-serif" size="2" color="FFFFFF">
This is the End Date:
</font>
</TD>
<TD>
<font face="arial, helvetica, san-serif" size="2">
<xsl:value-of select="END_DATE"/>
</font>
</TD> </TR>
</TABLE>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks