xslt, xml and tables .. how to do it

W

Wredniak

i have data in xml

i want them to display in html (<table>). i can do it, but i don't
know how to change <tr bgcolor="...">

i use

<xsl:template match="spolka">

<tr>
<td><xsl:value-of select="nazwa"/></td>
<td align="right"><xsl:value-of select="kapital"/></td>
<td align="right"><xsl:value-of select="udzial"/></td>
<td align="right">
<xsl:if test=" www='' ">
brak www
</xsl:if>
<xsl:if test=" www!='' ">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of
select="www"/></xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
<xsl:value-of select="www"/>
</xsl:element>
</xsl:if>
</td>
</tr>

</xsl:template>


<xsl:template match="podgrupa">
<tr><td colspan="4" align="center"><strong><xsl:value-of
select="rodzaj"/></strong></td></tr>
<xsl:apply-templates select="spolka"/>
</xsl:template>

the other thing is how to make a working <a href=""..
i make it with element and attributes .. but is there any easier
method?

(sorry for my bad english)
 
G

Gadrin77

(e-mail address removed) (Wredniak) wrote in message
the other thing is how to make a working <a href=""..
i make it with element and attributes .. but is there any easier
method?

try using parameters or variables

this works for me and creates an <A HREF=""> with an HREF that works.
It wouldn't let me make the <A> element like the <TABLE> but it's
still fairly
short.

I use MSXML 4.0 SP2.


<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:template match="/">
<xsl:param name="PCLevel">7</xsl:param>
<xsl:param name="HTHType">Basic</xsl:param>
<xsl:param name="url">C:\Program Files\RPC\hold.html</xsl:param>

<HEAD>
<LINK href="c:\program files\rpc\program\RPC.css" type="text/css"
rel="stylesheet"/>
</HEAD>
<HTML>
<BODY>
<TABLE width="65%" style="border-collapse: collapse" class="blue
frame" border="1" cellspacing="0" cellpadding="2">
<CAPTION class="bigblue"><xsl:value-of select="$HTHType"/></CAPTION>
<TH>Level</TH><TH>Information</TH>
<xsl:for-each select="document('C:\Program
Files\RPC\Data\File.Details')//HTH">
<xsl:comment>Here's Document 1!</xsl:comment>
<xsl:if test="(@Name = $HTHType)">
<TR bgcolor="whitesmoke"> <-- this works fine too!
<TD align="middle"><a><xsl:attribute name="href"><xsl:value-of
select="$url"/></xsl:attribute></a>
<xsl:value-of select="@Level"/></TD>
<TD>
<xsl:if test="@Text = ''">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:value-of select="@Text"/>
</TD>
</TR>
</xsl:if>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>


</xsl:stylesheet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,170
Latest member
Andrew1609
Top