Richard Kreidl
asked on
Simple transformation (VB .Net) not working
My XML file:
<?xml version="1.0" standalone="yes"?>
<UMZ>
<description>UMZ Knowledge Database</description>
<Server name="hoth">
<PreMVS>some data</PreMVS>
<PostMVS>some data</PostMVS>
<PreCS>some data</PreCS>
<PostCS>some data</PostCS>
<Misc>some data</Misc>
</Server>
<Server name="bob">
<PreMVS>some data</PreMVS>
<PostMVS>some data</PostMVS>
<PreCS>some data</PreCS>
<PostCS>some data</PostCS>
<Misc>some data</Misc>
</Server>
<Server name="amidala">
<PreMVS>some data</PreMVS>
<PostMVS>some data</PostMVS>
<PreCS>some data</PreCS>
<PostCS>some data</PostCS>
<Misc>some data</Misc>
</Server>
</UMZ>
My XSL file:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
<HTML>
<HEAD>
<STYLE>
BODY {margin:0; background-color="ivory"}
H1 {font:bold 18pt Verdana; width:100%; margin-top:1em; color:"#8b0000"}
DIV {font:bold 12pt}
</STYLE>
</HEAD>
<!-- Start of HTML Body -->
<BODY>
<H1 align="center">
<xsl:value-of select="UMZ/description"/>
</H1>
<p/>
<DIV id="listing">
<xsl:apply-templates select="UMZ"/>
</DIV>
</BODY>
<!-- End of HTML Body -->
</HTML>
</xsl:template>
<!-- Start of Templates -->
<xsl:template match="UMZ">
<TABLE border="2" borderColor="black" cellPadding="2" cellSpacing="1" valign="TOP" align="center">
<TR bgColor="#cccccc" borderColorDark="black" borderColorLight="black">
<TD width="100">
<font color="purple"><DIV align="center">Server Name</DIV></font>
</TD>
<TD width="80">
<font color="purple"><DIV align="center">Pre-MVS</DI V></font>
</TD>
<TD width="80">
<font color="purple"><DIV align="center">Post-MVS</D IV></font>
</TD>
<TD width="80">
<font color="purple"><DIV align="center">Pre-CS</DIV ></font>
</TD>
<TD width="80">
<font color="purple"><DIV align="center">Post-CS</DI V></font>
</TD>
<TD width="80">
<font color="purple"><DIV align="center">Misc.</DIV> </font>
</TD>
</TR>
<xsl:for-each select="Server">
<TR bgColor="#f0f0f0" borderColorDark="black" borderColorLight="black">
<TD>
<DIV align="center">
<xsl:value-of select="name"/>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:value-of select="PreMVS"/>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:value-of select="PostMVS"/>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:value-of select="PreCS"/>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:value-of select="PostCS"/>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:value-of select="Misc"/>
</DIV>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</xsl:template>
</xsl:stylesheet>
My HTML output:
UMZ Knowledge Database
Server Name Pre-MVS Post-MVS Pre-CS Post-CS Misc.
some data some data some data some data some data
some data some data some data some data some data
some data some data some data some data some data
I'm missing the 'Server Name' field and I need this field sorted.
Thanks
<?xml version="1.0" standalone="yes"?>
<UMZ>
<description>UMZ Knowledge Database</description>
<Server name="hoth">
<PreMVS>some data</PreMVS>
<PostMVS>some data</PostMVS>
<PreCS>some data</PreCS>
<PostCS>some data</PostCS>
<Misc>some data</Misc>
</Server>
<Server name="bob">
<PreMVS>some data</PreMVS>
<PostMVS>some data</PostMVS>
<PreCS>some data</PreCS>
<PostCS>some data</PostCS>
<Misc>some data</Misc>
</Server>
<Server name="amidala">
<PreMVS>some data</PreMVS>
<PostMVS>some data</PostMVS>
<PreCS>some data</PreCS>
<PostCS>some data</PostCS>
<Misc>some data</Misc>
</Server>
</UMZ>
My XSL file:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
<HTML>
<HEAD>
<STYLE>
BODY {margin:0; background-color="ivory"}
H1 {font:bold 18pt Verdana; width:100%; margin-top:1em; color:"#8b0000"}
DIV {font:bold 12pt}
</STYLE>
</HEAD>
<!-- Start of HTML Body -->
<BODY>
<H1 align="center">
<xsl:value-of select="UMZ/description"/>
</H1>
<p/>
<DIV id="listing">
<xsl:apply-templates select="UMZ"/>
</DIV>
</BODY>
<!-- End of HTML Body -->
</HTML>
</xsl:template>
<!-- Start of Templates -->
<xsl:template match="UMZ">
<TABLE border="2" borderColor="black" cellPadding="2" cellSpacing="1" valign="TOP" align="center">
<TR bgColor="#cccccc" borderColorDark="black" borderColorLight="black">
<TD width="100">
<font color="purple"><DIV align="center">Server Name</DIV></font>
</TD>
<TD width="80">
<font color="purple"><DIV align="center">Pre-MVS</DI
</TD>
<TD width="80">
<font color="purple"><DIV align="center">Post-MVS</D
</TD>
<TD width="80">
<font color="purple"><DIV align="center">Pre-CS</DIV
</TD>
<TD width="80">
<font color="purple"><DIV align="center">Post-CS</DI
</TD>
<TD width="80">
<font color="purple"><DIV align="center">Misc.</DIV>
</TD>
</TR>
<xsl:for-each select="Server">
<TR bgColor="#f0f0f0" borderColorDark="black" borderColorLight="black">
<TD>
<DIV align="center">
<xsl:value-of select="name"/>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:value-of select="PreMVS"/>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:value-of select="PostMVS"/>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:value-of select="PreCS"/>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:value-of select="PostCS"/>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:value-of select="Misc"/>
</DIV>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</xsl:template>
</xsl:stylesheet>
My HTML output:
UMZ Knowledge Database
Server Name Pre-MVS Post-MVS Pre-CS Post-CS Misc.
some data some data some data some data some data
some data some data some data some data some data
some data some data some data some data some data
I'm missing the 'Server Name' field and I need this field sorted.
Thanks
ASKER
Thanks, that worked...the second part of my question was how would sort @name alphabetically???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<xsl:value-of select="name"/>
Into:
<xsl:value-of select="@name"/>
name is an attribute of <server> not a childnode.
-r-