www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > XML

    XML Discussion and technical support for using and deploying XML applications and websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 04-11-2006, 06:30 AM
    Etimm Etimm is offline
    Registered User
     
    Join Date: Apr 2006
    Posts: 4
    resolved [Resolved] Problem with weird XML and XSL

    I need some help getting the data from the xml into html table.

    this is a sample of the XML:
    Code:
    <UniFact>
    <Producten>
    <Product Type="EEK 260 VA" Merk="Etna" ProductgroepNummer="4.13.5" Hoofdgroep="Witgoed" HoofdgroepID="ab4a9d79-5176-4662-8476-0d76a0a2c2c9" Subgroep="Inbouw koelkast" SubgroepID="de969381-d040-493a-bf14-6d3b220a0499" Subsubgroep="170 cm en hoger" SubsubgroepID="bda7e292-de68-42f0-810e-6ee5b763a5b0" Goingprijs="999.00" Brutoprijs="999.00" Verkoopprijs="487.00" Nettoprijs="270.84" Leverancier="Atag Etna Pelgrim HomeProducts B.V." EAN="" Verwijderingsbijdrage="14.29">
    <Kenmerk Naam="Energieklasse" Eenheid="">A</Kenmerk> 
    <Kenmerk Naam="Netto Inhoud koelgedeelte" Eenheid="liter">176</Kenmerk> 
    <Kenmerk Naam="Nismaat Hoogte" Eenheid="cm">177.5</Kenmerk> 
    <Kenmerk Naam="Nismaat Breedte" Eenheid="cm">57</Kenmerk> 
    <Kenmerk Naam="Nismaat Diepte" Eenheid="cm">56</Kenmerk> 
    </Product>
    Now I want a html table like this:
    Code:
    -------------------------------------------------------------------
    | Type       | Merk | Hoofdgroep | Energieklasse | Nismaat Hoogte |
    -------------------------------------------------------------------
    | EEK 260 VA | Etna | Witgoed    | A             | 177.5 cm       |
    -------------------------------------------------------------------
    The only things I can get out of the xml are:
    A 176 177.5 57 56

    I've used <xsl:value-of select="producten"/>


    Can anyone help me?

    Last edited by Etimm; 04-12-2006 at 03:30 PM.
    Reply With Quote
      #2  
    Old 04-11-2006, 10:54 AM
    NogDog's Avatar
    NogDog NogDog is offline
    High Energy Magic Dept.
     
    Join Date: Aug 2004
    Location: Ankh-Morpork
    Posts: 14,007
    Here's what I came up with:

    test.xsl:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" 
      doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" 
      doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/>
    <xsl:template match="/">
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <head>
      <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />
      <title>Page Title</title>
      <style type="text/css">
        table {
          border-collapse: collapse;
          border: solid 1px black;
        }
        th, td {
          border: solid 1px black;
          padding: 0.2em 0.5em;
        }
      </style>
      </head>
      <body>
        <table>
          <tr>
            <th>Type</th>
            <th>Merk</th>
            <th>Hoofdgroep</th>
            <th>Energieklasse</th>
            <th>Nismaat Hoogte</th>
          </tr>
        <xsl:for-each select="Unifact/Producten/Product">
          <tr>
            <td><xsl:value-of select="@Type"/></td>
            <td><xsl:value-of select="@Merk"/></td>
            <td><xsl:value-of select="@Hoofdgroep"/></td>
            <td><xsl:value-of select="Kenmerk[@Naam='Energieklasse']"/></td>
            <td>
              <xsl:value-of select="Kenmerk[@Naam='Nismaat Hoogte']"/>
              <xsl:value-of select="Kenmerk[@Naam='Nismaat Hoogte']/@Eenheid"/>
            </td>
          </tr>
        </xsl:for-each>
        </table>
      </body>
      </html>
    </xsl:template>
    </xsl:stylesheet>
    test.xml:
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="test.xsl"?>
    <Unifact>
      <Producten>
        <Product Type="EEK 260 VA" Merk="Etna" ProductgroepNummer="4.13.5" Hoofdgroep="Witgoed" HoofdgroepID="ab4a9d79-5176-4662-8476-0d76a0a2c2c9" Subgroep="Inbouw koelkast" SubgroepID="de969381-d040-493a-bf14-6d3b220a0499" Subsubgroep="170 cm en hoger" SubsubgroepID="bda7e292-de68-42f0-810e-6ee5b763a5b0" Goingprijs="999.00" Brutoprijs="999.00" Verkoopprijs="487.00" Nettoprijs="270.84" Leverancier="Atag Etna Pelgrim HomeProducts B.V." EAN="" Verwijderingsbijdrage="14.29">
          <Kenmerk Naam="Energieklasse" Eenheid="">A</Kenmerk> 
          <Kenmerk Naam="Netto Inhoud koelgedeelte" Eenheid="liter">176</Kenmerk> 
          <Kenmerk Naam="Nismaat Hoogte" Eenheid="cm">177.5</Kenmerk> 
          <Kenmerk Naam="Nismaat Breedte" Eenheid="cm">57</Kenmerk> 
          <Kenmerk Naam="Nismaat Diepte" Eenheid="cm">56</Kenmerk> 
        </Product>
        <Product Type="EEK 260 VA" Merk="Etna" ProductgroepNummer="4.13.5" Hoofdgroep="Witgoed" HoofdgroepID="ab4a9d79-5176-4662-8476-0d76a0a2c2c9" Subgroep="Inbouw koelkast" SubgroepID="de969381-d040-493a-bf14-6d3b220a0499" Subsubgroep="170 cm en hoger" SubsubgroepID="bda7e292-de68-42f0-810e-6ee5b763a5b0" Goingprijs="999.00" Brutoprijs="999.00" Verkoopprijs="487.00" Nettoprijs="270.84" Leverancier="Atag Etna Pelgrim HomeProducts B.V." EAN="" Verwijderingsbijdrage="14.29">
          <Kenmerk Naam="Energieklasse" Eenheid="">A</Kenmerk> 
          <Kenmerk Naam="Netto Inhoud koelgedeelte" Eenheid="liter">176</Kenmerk> 
          <Kenmerk Naam="Nismaat Hoogte" Eenheid="cm">177.5</Kenmerk> 
          <Kenmerk Naam="Nismaat Breedte" Eenheid="cm">57</Kenmerk> 
          <Kenmerk Naam="Nismaat Diepte" Eenheid="cm">56</Kenmerk> 
        </Product>
      </Producten>
    </Unifact>
    __________________
    "That's what the gods are! An answer that will do! Because there's food to be caught and babies to be born and life to be lived and so there is not time for big, complicated, and worrying answers! Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." -- from Nation, by Terry Pratchett
    freelancer.internet.com
    Email me
    Reply With Quote
      #3  
    Old 04-11-2006, 05:29 PM
    Etimm Etimm is offline
    Registered User
     
    Join Date: Apr 2006
    Posts: 4
    Thank you! This is perfect!
    However the XML I must work with is far from perfect
    Somehow I'll have to correct the XML file (wich contain 20.000 products)
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:05 AM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.