dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: xml / xsl - what am i doing wrong!?!

  1. #1
    Join Date
    Apr 2010
    Posts
    6

    Exclamation xml / xsl - what am i doing wrong!?!

    Ok, I really need help . I am writing an XML document and an XSL document. I know my xml is correct... but i do not know how to get it going with the xsl part. I am extremely confused and hope maybe someone can point out what I am doing wrong... thank you for reading!

    xml code:

    <?xml version = "1.0"?>
    <?xml-stylesheet type="text/xsl" href="schools.xsl">

    <Universities>
    <college public = "Montclair State University">
    <Established>1908</Established>
    <Owner>Public</Owner>
    <Location>Montclair, New Jersery</Location>
    <OriginalSize>25 Acres</OriginalSize>
    <OriginalName>New Jersey State Normal School at Montclair</OriginalName>
    <Population>18,171</Population>
    <Colleges>5</Colleges>
    </college>

    <college public = "NJIT">
    <Established>1881</Established>
    <Owner>Public</Owner>
    <Location>Newark, New Jersey</Location>
    <OriginalSize>~ 18 Acres</OriginalSize>
    <OriginalName>Newark Technical School</OriginalName>
    <Population>10,000+</Population>
    <Colleges>6</Colleges>
    </college>

    <college private = "Princeton">
    <Established>1746</Established>
    <Owner>Private</Owner>
    <Location>Princeton, New Jersey</Location>
    <OriginalSize></OriginalSize>
    <OriginalName>College of New Jersey</OriginalName>
    <Population>7,567</Population>
    <Colleges>6</Colleges>
    </college>

    <college public = "Rutgers">
    <Established>1766</Established>
    <Owner>Public</Owner>
    <Location>New Brunswick, Piscataway Twp, Camden and Newark, New Jersey</Location>
    <OriginalSize>7 Acres</OriginalSize>
    <OriginalName>Queens College</OriginalName>
    <Population>52,471</Population>
    <Colleges>27</Colleges>
    </college>

    <college public = "UMD">
    <Established>1970</Established>
    <Owner>Public</Owner>
    <Location>Newark, New Jersey</Location>
    <OriginalSize></OriginalSize>
    <OriginalName>New jersey College of Medicine and Dentistry</OriginalName>
    <Population>5,764</Population>
    <Colleges>8</Colleges>
    </college>
    </Universities>

    xsl code:

    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xslutput method="html"/>
    <xsl:template match="/">
    <html><head><title>Universities of New Jersey</title></head>
    <body>
    <h1>Universities of New Jersey</h1>
    <table border="1"><tr>
    <th>University</th>
    <th>Established</th>
    <th>Owner</th>
    <th>Location</th>
    <th>OriginalSize</th>
    <th>OriginalName</th>
    <th>Population</th>
    <th>Colleges</th></tr>

    <!-- ** XML2e ** -->
    <xsl:for-each select="Colleges/College public">
    <tr><td><strong><xsl:value-of select="name[@language='English']"/></strong><br/>(<em><xsl:value-of select="name[@language!='English']"/></em>)</td>
    <td><xsl:value-of select="location"/></td>
    <td><xsl:value-of select="height"/></td>
    </tr>
    </xsl:for-each>

    </table>
    </body></html>
    </xsl:template>
    </xsl:stylesheet>

    I have been working on this all week and have tried everything.

  2. #2
    Join Date
    Apr 2010
    Posts
    6
    **also if it matters - i wrote the xml in notepad and xsl in wordpad**

  3. #3
    Join Date
    Apr 2010
    Posts
    6
    i think im getting much closer but still no luck really. XSL:

    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xslutput method="html"/>
    <xsl:template match="/">
    <html>
    <head>
    <title>Universities of New Jersey</title>
    </head>
    <body>
    <xsl:apply-templates/>
    </body>
    </html>
    </xsl:template>
    <xsl:template match = "Universities">
    <table width="400" border="1" align ="center" >
    <tr bgcolor ="598744">
    <th>Established</th>
    <th>Owner</th>
    <th>Location</th>
    <th>OriginalSize</th>
    <th>OriginalName</th>
    <th>Population</th>
    <th>Colleges</th>
    </tr>
    <xsl:for-each select="Universities/college public" >
    <tr>
    <td><xsl:value-of select="Established" /></td>
    <td><xsl:value-of select="Owner" /></td>
    <td><xsl:value-of select="Location" /></td>
    <td><xsl:value-of select="OriginalSize" /></td>
    <td><xsl:value-of select="OriginalName" /></td>
    <td><xsl:value-of select="Population" /></td>
    <td><xsl:value-of select="Colleges" /></td>
    </tr>
    </xsl:for-each>
    <xsl:for-each select="Universities/college private" >
    <tr>
    <td><xsl:value-of select="Established" /></td>
    <td><xsl:value-of select="Owner" /></td>
    <td><xsl:value-of select="Location" /></td>
    <td><xsl:value-of select="OriginalSize" /></td>
    <td><xsl:value-of select="OriginalName" /></td>
    <td><xsl:value-of select="Population" /></td>
    <td><xsl:value-of select="Colleges" /></td>
    </tr>
    </xsl:for-each>
    </table>
    </xsl:template>
    </xsl:stylesheet>

    can anyone see anything wrong? pleeease!
    Last edited by Code Noob; 09-24-2010 at 04:08 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles