Development XSLT

Discussion in 'Software' started by simon w, 26 Sep 2006.

  1. simon w

    simon w What's a Dremel?

    Joined:
    3 Nov 2003
    Posts:
    1,302
    Likes Received:
    0
    I'm trying to transform PHPSysInfo's XML output using my own XSL.

    Here's a snippet

    PHP:
    <phpsysinfo>
        <
    Generation version="2.5.2_rc3" timestamp="1159205078"/>
        <
    Vitals>
            <
    Hostname>somewhere.co.uk</Hostname>
            <
    IPAddr>XXX.XXX.XXX.XXX</IPAddr>
            <
    Kernel>3.2</Kernel>
            <
    Distro>Debian</Distro>
            <
    Distroicon>Debian.png</Distroicon>
            <
    Uptime>1178621.57</Uptime>
            <
    Users>1</Users>
            <
    LoadAvg>0.00 0.00 0.00</LoadAvg>
        </
    Vitals>
    ...
    <
    phpsysinfo>
    I've got the hostname with
    PHP:
    <xsl:for-each select="phpsysinfo/Vitals">
       <
    xsl:value-of select="Hostname" />
    </
    xsl:for-each>
    What I can't figure out, is how to get the timestamp attribute. Any ideas?
     
  2. FredsFriend

    FredsFriend What's a Dremel?

    Joined:
    20 Jul 2005
    Posts:
    486
    Likes Received:
    0
    gah trying to remember this stuff from uni so don't shout if i'm wrong but i think that its:
    Code:
    <xsl:value-of select="Generation[@timestamp]" />
    Let me know if i'm wrong and i'll dig out my XML books
     
  3. simon w

    simon w What's a Dremel?

    Joined:
    3 Nov 2003
    Posts:
    1,302
    Likes Received:
    0
    That's not working. I've tried some minor variations so that and still no joy.

    Would you recommend any of the books you have?
     
  4. simon w

    simon w What's a Dremel?

    Joined:
    3 Nov 2003
    Posts:
    1,302
    Likes Received:
    0
    Got it (thanks to XMLSpy)

    PHP:
    <xsl:value-of select="phpsysinfo/Generation/@timestamp" />
    I wonder if there's a date format function...
     
  5. FredsFriend

    FredsFriend What's a Dremel?

    Joined:
    20 Jul 2005
    Posts:
    486
    Likes Received:
    0
    ah ok cool.
    A half decent book for XML in general is Learning XML by O'Reilly which covers most of the basics including XSLT it was one of out course books
     

Share This Page