SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru siphilp's Avatar
    Join Date
    Nov 2001
    Location
    Fife, Scotland
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML XSLT help---- please

    Hi People,
    I have an XML file
    <?xml version="1.0"?><?xml-stylesheet type='text/xsl' href="PaymentAnalysis.xsl"?>
    <PaymentAnalysis>
    <Meter Location="Edinburgh, 2 Moray Place">
    <TotalPayments>4</TotalPayments>
    <TotalAmount>3</TotalAmount>
    <AverageDuration>00:37:30</AverageDuration>
    <MaximumUtilisation>N/A</MaximumUtilisation>
    </Meter>
    <Meter Location="Edinburgh, 5 Spittal Walk">
    <TotalPayments>4</TotalPayments>
    <TotalAmount>3</TotalAmount>
    <AverageDuration>00:37:30</AverageDuration>
    <MaximumUtilisation>N/A</MaximumUtilisation>
    </Meter>
    <Total>
    <TotalMeters>2</TotalMeters>
    <TotalPayments>8</TotalPayments>
    <TotalAmount>6</TotalAmount>
    <AverageDuration>01:15:00</AverageDuration>
    <MaximumUtilisation>N/A</MaximumUtilisation>
    </Total>
    </PaymentAnalysis>

    Ok i would as you can see it has an attribute of "a href=""blah". The stylesheet is

    <?xml version='1.0'?>
    <xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    <html>
    <body>
    <table Border="1">
    <tr>
    <td><i>Location</i></td>
    <td><i>Payments</i></td>
    <td><i>Amount</i></td>
    <td><i>Avergare Duration</i></td>
    <td><i>Maximum Utilisation</i></td>
    </tr>
    <xsl:for-each select="PaymentAnalysis/Meter">
    <tr>
    <td><xsl:value-of select="Location"/></td>
    <td><xsl:value-of select="TotalPayments"/></td>
    <td><xsl:value-of select="TotalAmount"/></td>
    <td><xsl:value-of select="AverageDuration"/></td>
    <td><xsl:value-of select="MaximumUtilisation"/></td>
    </tr>
    </xsl:for-each>
    <xsl:for-each select="PaymentAnalysis/Total">
    <tr>
    <td><b>Total</b></td>
    <td><xsl:value-of select="TotalPayments"/></td>
    <td><xsl:value-of select="TotalAmount"/></td>
    <td><xsl:value-of select="AverageDuration"/></td>
    <td><xsl:value-of select="MaximumUtilisation"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

    How can i Access the <meter location in the xml file within the XSL Sheet? Anyone ideas?


    Thanks in advance


    Simon

  2. #2
    SitePoint Guru siphilp's Avatar
    Join Date
    Nov 2001
    Location
    Fife, Scotland
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's ok sorted it.

    Just for reference: it was "@Location"

    Thanks anyway

    Si


Bookmarks

Posting Permissions

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