Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Simple transformation (VB .Net) not working

Posted on 2005-04-24
3
Medium Priority
?
244 Views
Last Modified: 2006-11-18
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</DIV></font>
                    </TD>
                    <TD width="80">
                         <font color="purple"><DIV align="center">Post-MVS</DIV></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</DIV></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

 
0
Comment
Question by:Richard Kreidl
  • 2
3 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 13854033
Change:
<xsl:value-of select="name"/>
Into:
<xsl:value-of select="@name"/>

name is an attribute of <server> not a childnode.

-r-

0
 
LVL 2

Author Comment

by:Richard Kreidl
ID: 13854041
Thanks, that worked...the second part of my question was how would sort @name alphabetically???
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 2000 total points
ID: 13854107
Sorry, I misted than. From heart, I though you'd have to change:
<xsl:for-each select="Server">
into the line below, to enable sorting:
<xsl:for-each select="Server"><xsl:sort order="ascending" select="@name" />

-r-
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Loops Section Overview
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

577 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