Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    156
    156 is offline
    New to the CF scene
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Linking XML and XSL

    When I open the XML file in Firefox, the XSL table does appear, however, the cell rows aren't populated with data from the XML file, I'm not the best coder, so I know I've obviously gone wrong somewhere, it's probably a really obvious problem too, but if anyone thinks they hold a solution to my problem, please do share!

    Thank you, and Merry Christmas!

    XML Code:

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="schedule.xsl"?>

    <joblist>


    <job status="unallocated">
    <customer_id>AHJ9873</customer_id>
    <category>washing machine</category>
    <make>Neff</make>
    <model>NFJ1000</model>
    <problem reported="2013-10-24T15:05:00">Water leaking</problem>
    </job>
    <job status="complete">
    <customer_id>AKP3571</customer_id>
    <category>coffee maker</category>
    <make>Bosch</make>
    <model>BH402</model>
    <problem reported="2013-10-04T11:00:00">Will not turn on</problem>
    <actions>
    <engineer started="2012-10-04T15:00:00" finished="2012-10-04T15:00:00">J. Golding</engineer>
    <note>Was not plugged in</note>
    <note>Did maintanance process</note>
    </actions>
    </job>
    <job status="logged">
    <customer_id>AKQ6534</customer_id>
    <comments>Call customer before arrival</comments>
    <category>tumble drier</category>
    <make>LG</make>
    <model>LG9742</model>
    <problem reported="2013-10-12T18:00:00">lights flashing</problem>
    <actions>
    <engineer started="2012-10-15T15:00:00" >A. Harding</engineer>
    <note>Engineer en-route</note>
    </actions>
    </job>
    </joblist>




    XSL 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>
    <h2>Schedule</h2>
    <table border="10">
    <tr bgcolor="#FFFFFF">
    <th>Customer ID</th>
    <th>Category</th>
    <th>Equipment</th>
    <th>Problem Reported</th>
    <th>Job Status</th>
    <th>Problem</th>
    <th>Engineer</th>
    <th>Comments</th>
    </tr>
    <tr>
    <xsl:for-each select="joblist/job">

    <td><xsl:value-of select="Customer ID"/></td>
    <td><xsl:value-of select="Category"/></td>
    <td><xsl:value-of select="Equipment"/></td>
    <td><xsl:value-of select="Problem Reported"/></td>
    <td><xsl:value-of select="Job Status"/></td>
    <td><xsl:value-of select="Problem"/></td>
    <td><xsl:value-of select="Engineer"/></td>
    <td<xsl:value-of select="Comments"/></td>

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

    </xsl:stylesheet>

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,763
    Thanks
    23
    Thanked 548 Times in 547 Posts
    A problem in your xsl is missing a couple of closing tags and the wrong 'selects'
    you have
    Code:
    <td><xsl:value-of select="Customer ID"/></td>
    S/B
    Code:
    <td><xsl:value-of select="customer_id"/></td>
    Here's a part of what you should have. I think you need a start date and end date in table and a method to work with multiple comments.
    Code:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/1999/xhtml">
    
    <xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <body>
    <h2>Schedule</h2>
    <table border="10">
    <tr bgcolor="#FFFFFF">
    <th>Customer ID</th>
    <th>Category</th>
    <th>Equipment</th>
    <th>Problem</th>
    <th>Reported</th>
    
    <th>Engineer</th>
    <th>Comments</th>
    </tr>
    
    <xsl:for-each select="joblist/job">
    	<tr>
    	<td><xsl:value-of select="customer_id"/></td>
    	<td><xsl:value-of select="category"/></td>
    	<td><xsl:value-of select="make"/></td>
    	<td><xsl:value-of select="problem"/></td>
    	<td><xsl:value-of select="problem/@reported"/></td>
    
    	<xsl:for-each select="actions">
    		<td><xsl:value-of select="engineer"/></td>
    		<td><xsl:value-of select="note"/></td>
    	</xsl:for-each>
    	</tr>
    </xsl:for-each>
    
    </table>
    </body>
    </html>
    </xsl:template>
    
    </xsl:stylesheet>
    If more help needed read this http://www.w3schools.com/xsl/. If still in the dark ask here.
    Last edited by sunfighter; 12-24-2013 at 02:18 AM.
    Evolution - The non-random survival of random variants.


  •  

    Tags for this Thread

    Posting Permissions

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