SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    formating xml with html help

    okay, i think i'm missing something here and i can't remember/find what it is...

    here's my xml:
    PHP Code:
    <?xml version='1.0' standalone='yes'?>

    <parseme>
    <file>P2040756small.jpg</file>
    <file>P2040757small.jpg</file>
    <file>P2040758small.jpg</file>
    <file>P2040759small.jpg</file>
    <file>P2040761small.jpg</file>
    <file>P2040762small.jpg</file>
    <file>P2040763small.jpg</file>
    <file>P2040764small.jpg</file>
    <file>P2040765small.jpg</file>
    <file>P2040766small.jpg</file>
    <file>P2040775small.jpg</file>
    </parseme>
    (on a side note, i also have a php script that outputs the above and that leads to another question)

    and here is my html:
    PHP Code:
    <html>
    <
    body>

    <
    xml id="current" src="current.xml"></xml>

    <
    table border="1" datasrc="#current">
    <
    tr>
    <
    td><span datafld="FILE"></span></td>

    </
    tr>
    </
    table>

    </
    body>
    </
    html
    when you run the html file, it shows a blank table and i can't figure out why. all i want to do is load it into rows that go across (okay so i guess it would be columns to go across) and then down...if that makes sense...where am i going wrong?


    the side note, here's the php script i'm using:
    PHP Code:
    <?php
    function od ($d) {
      
    $d stripslashes($d);
      if (
    $handle opendir($d)) {
        
    chdir($d);
        while((
    $list readdir($handle)) !== false) {
          if (
    is_file($list)) {
            
    $fa[] = $list;
          }
        }
      }
      if (
    count($fa)>0) {
        for (
    $n=0$n<count($fa); $n++) {
          echo 
    "<file>".$fa[$n]."</file>\n";
        }
      }
    }
    header ('Content-type: text/xml');
    echo 
    "<?xml version='1.0' standalone='yes'?>\n\n";
    echo 
    "<parseme>\n";
    od ('directory/of/choice');
    echo 
    "</parseme>\n";
    ?>
    i'm wondering if i can use this instead of the xml file above, because it would be real time...is that possible?

    thanks in advance
    i want to be a nerd....

  2. #2
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Err, I don't understand.

    You're not doing xslt transforms, you're just loading the xml into the html? What is supposed to happen? I've never seen this done before.

  3. #3
    SitePoint Guru
    Join Date
    Sep 1999
    Location
    Singapore
    Posts
    854
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vr6stress' doing it with the IE specific data island way.

    Is your PHP file named current.xml? Only thing I could think of now.

  4. #4
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm not really using the php file at this point, i was just trying to get the xml file to format through the html file..but it's not working...
    i want to be a nerd....

  5. #5
    SitePoint Guru
    Join Date
    Sep 1999
    Location
    Singapore
    Posts
    854
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IIRC you'll need to do something like this for your XML file:

    Code:
    <?xml version='1.0' standalone='yes'?>
    
    <parseme>
    	<item>
    		<file>P2040756small.jpg</file>
    	</item>
    	<item>
    		<file>P2040757small.jpg</file>
    	</item>
    	<item>
    		<file>P2040758small.jpg</file>
    	</item>
    	<item>
    		<file>P2040759small.jpg</file>
    	</item>
    	<item>
    		<file>P2040761small.jpg</file>
    	</item>
    	<item>
    		<file>P2040762small.jpg</file>
    	</item>
    	<item>
    		<file>P2040763small.jpg</file>
    	</item>
    	<item>
    		<file>P2040764small.jpg</file>
    	</item>
    	<item>
    		<file>P2040765small.jpg</file>
    	</item>
    	<item>
    		<file>P2040766small.jpg</file>
    	</item>
    	<item>
    		<file>P2040775small.jpg</file>
    	</item>
    </parseme>

  6. #6
    SitePoint Enthusiast
    Join Date
    Feb 2003
    Location
    India
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Complete website using just XML, XSL/XSLT

    If you want to see a complete site developed using XML, XSL/XSLT without using SCRIPT or IE specific, then check out my site

    http://www.v4cnet.com


    To learn more about IE using data island, i think u need to go to school... u can check the link below for w3schools.



    http://www.w3schools.com/xml/xml_data_island.asp

    rgds
    Sukesh
    thnX n Rgds
    Sukesh Ashok Kumar
    Brain Behind - http://www.V4Cnet.com
    Microsoft MVP in .NET

  7. #7
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    after looking around the net for some help, i'm come up with an xsl that gets me pretty close to what i want, but i want more...and i don't know how to do it. instead of the link being text (<xsl:value-of select="image"/>) i would like it to be an image of a specific size. i sort of understand the concept of how the href works, but it's at the brink of my ability, and i can't think of how to do an image instead.

    could someone help me with that?

    PHP Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
      <html>
      <body bgcolor="#334D78">
        
        
    <table border="1" cellpadding="5" bordercolor="#FFFFFF" style="border-collapse:collapse">
      <tr bgcolor="#9acd32">
        
        <th>Image</th>
        <th>Size Kb</th>

      </tr>
      <xsl:for-each select="Import/Row"> 
      <tr>
        
        <td>
        <A>
           <xsl:attribute name="href">
           <xsl:value-of select="image"/>
           </xsl:attribute>
           <xsl:value-of select="image"/>
        </A>
        </td>
        <td><xsl:value-of select="size"/></td>
        
      </tr>
      </xsl:for-each> 
    </table>
      </body>
      </html>
    </xsl:template></xsl:stylesheet>


    the xml data is this:

    PHP Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml
    -stylesheet type="text/xsl" href="archivetest.xsl"?>
    <Import>
        <Row>
            <size>112,351</size>
            <image>p2040756small.jpg</image>
        </Row>
        <Row>
            <size>110,391</size>
            <image>p2040757small.jpg</image>
        </Row>
        <Row>
            <size>118,139</size>
            <image>p2040758small.jpg</image>
        </Row>
        <Row>
            <size>114,813</size>
            <image>p2040759small.jpg</image>
        </Row>
        <Row>
            <size>528,912</size>
            <image>p2040761small.jpg</image>
        </Row>
        <Row>
            <size>564,047</size>
            <image>p2040762small.jpg</image>
        </Row>
        <Row>
            <size>116,965</size>
            <image>p2040763small.jpg</image>
        </Row>
        <Row>
            <size>115,371</size>
            <image>p2040764small.jpg</image>
        </Row>
        <Row>
            <size>124,403</size>
            <image>p2040765small.jpg</image>
        </Row>
        <Row>
            <size>142,684</size>
            <image>p2040766small.jpg</image>
        </Row>
        <Row>
            <size>105,822</size>
            <image>p2040775small.jpg</image>
        </Row>
        <Row/>
    </Import>
    Last edited by vr6stress; Feb 16, 2003 at 18:07.
    i want to be a nerd....

  8. #8
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand you correctly
    Code:
        <A>
    
           <xsl:attribute name="href">
    
           <xsl:value-of select="image"/>
    
           </xsl:attribute>
    
           <xsl:value-of select="image"/>
    
        </A>
    should be
    Code:
        <A>
    
           <xsl:attribute name="href">
    
           <xsl:value-of select="image"/>
    
           </xsl:attribute>
            <img>
             <xsl:attribute name = "src">
           <xsl:value-of select="image"/>
           </xsl:attribute>
             </img>
        </A>
    The sizing issue is more problematic, as you've stuck both dimensions in one element. If you change your <size> element to a <w> and <h>, it will be trivial. Actually, I implement them as attributes and not child elements, but either shoudl be technically sufficient.

  9. #9
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how about adding a path to point to a smaller image

    like lets say right now, if i add what you showed me there, and it works (thanks by the way!!!) it pulls up the full size image (don't let the file name fool ya) could i point it to another directory to load a smaller image?

    would i need to add the file name of the thumbnail so it could select that file...

    which leads me to how to add the path in, would it be another attribute? or would i just add the code right in there?
    i want to be a nerd....

  10. #10
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The lazy way to do this is to name all of the thumbnails the same thing as the full versions and place them in a different directory, then append that directory name to the src attribute.

  11. #11
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hahaha i am lazy...

    <xsl:attribute name = "src">

    would turn into:

    <xsl:attribute name = "src="path/to/directory">

    or is something wrong with the use of the = and the quotes?
    i want to be a nerd....

  12. #12
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not even close
    Code:
        <A>
    
           <xsl:attribute name="href">
    
           <xsl:value-of select="image"/>
    
           </xsl:attribute>
            <img>
             <xsl:attribute name = "src">
           <xsl:text>/path/todirectory/</xsl:text><xsl:value-of select="image"/>
           </xsl:attribute>
             </img>
        </A>

  13. #13
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sweet!!!

    thanks!!!
    i want to be a nerd....


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
  •