matthewst Posted November 13, 2006 Share Posted November 13, 2006 This is what I need:User opens HTML file---->data from XML file is displayed in order in HTML fileThis is my problem:User opens HTML file----> Only the heading "current log" and "tstamp" and "entry" are displayedI took the HTML and SXL from http://www.w3schools.com/xsl/xsl_client.aspHTML: <html><body><script type="text/javascript">// Load XML var xml = new ActiveXObject("Microsoft.XMLDOM")xml.async = falsexml.load("CurrentLog.xml")// Load XSLvar xsl = new ActiveXObject("Microsoft.XMLDOM")xsl.async = falsexsl.load("CurrentLog.xsl")// Transformdocument.write(xml.transformNode(xsl))</script></body></html> XML: <?xml version="1.0" standalone="yes" ?> - <IncrepDataset xmlns="http://tempuri.org/IncrepDataset.xsd">- <Control> <Control_ID>0</Control_ID> <Name>DocViewer</Name> <Filename>docviewer.dll</Filename> <Icon>doc</Icon> <IncrepLoadable>true</IncrepLoadable> <Version>4.0.0.28546</Version> <TStamp>2006-11-06T18:00:09.4160070-06:00</TStamp> </Control>- <Control> <Control_ID>-1</Control_ID> <Name>RIDS</Name> <Filename>ridswrapper.dll</Filename> <Icon>tool</Icon> <IncrepLoadable>true</IncrepLoadable> <Version>4.0.0.28559</Version> <TStamp>2006-11-06T18:00:32.8518090-06:00</TStamp> </Control>- <Control> <Control_ID>-2</Control_ID> <Name>Explosives</Name> <Filename>atfwrapper.dll</Filename> <Icon>tool_bomb</Icon> <IncrepLoadable>true</IncrepLoadable> <Version>4.0.0.28559</Version> <TStamp>2006-11-06T18:01:01.2952610-06:00</TStamp> </Control>- <Control> <Control_ID>-3</Control_ID> <Name>ChecklistViewer.Bomb Response</Name> <Filename>checklistwrapper.dll</Filename> <Icon>tool_checklist</Icon> <IncrepLoadable>false</IncrepLoadable> <Version>4.0.0.28559</Version> <TStamp>2006-11-06T18:01:21.5461976-06:00</TStamp> </Control>- <DataType> <Datatype_id>1</Datatype_id> <name>String</name> <description /> </DataType>- <IncidentLog> <IncidentLog_ID>-10</IncidentLog_ID> <TStamp>2006-11-06T18:01:26.7541536-06:00</TStamp> <Entry>- 'COMMENCE IED SOP/ERG ACTIONS. GATHER ALL INFO.' checked</Entry> <AddedByUser>false</AddedByUser> <submission_id>0</submission_id> <Priority>Low</Priority> <Control_ID>-3</Control_ID> </IncidentLog>- <IncidentLog> <IncidentLog_ID>-11</IncidentLog_ID> <TStamp>2006-11-06T18:01:26.8142454-06:00</TStamp> <Entry>- 'SET INITIAL EXCLUSION AREA.' checked</Entry> <AddedByUser>false</AddedByUser> <submission_id>0</submission_id> <Priority>Low</Priority> <Control_ID>-3</Control_ID> </IncidentLog>- <IncidentLog> <IncidentLog_ID>-12</IncidentLog_ID> <TStamp>2006-11-06T18:01:26.8943678-06:00</TStamp> <Entry>- 'MAKE ALL NOTIFICATIONS.' checked</Entry> <AddedByUser>false</AddedByUser> <submission_id>0</submission_id> <Priority>Low</Priority> <Control_ID>-3</Control_ID> </IncidentLog>- <IncidentLog> <IncidentLog_ID>-13</IncidentLog_ID> <TStamp>2006-11-06T18:01:26.9644749-06:00</TStamp> <Entry>- 'IDENTIFY ON-SCENE COMMAND (OSC)/ COMMAND POST (CP) LOCATION.' checked</Entry> <AddedByUser>false</AddedByUser> <submission_id>0</submission_id> <Priority>Low</Priority> <Control_ID>-3</Control_ID> </IncidentLog>- <IncidentLog> <IncidentLog_ID>-14</IncidentLog_ID> <TStamp>2006-11-06T18:01:38.6222841-06:00</TStamp> <Entry>Incident Summary selected</Entry> <AddedByUser>false</AddedByUser> <submission_id>0</submission_id> <Priority>Low</Priority> </IncidentLog> </IncrepDataset> XSL: <?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited with XML Spy v2006 (http://www.altova.com) --><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/><xsl:template match="/"> <html> <body> <h2>Current Log</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">TStamp</th> <th align="left">Entry</th> </tr> <xsl:for-each select="tstamp/entry"> <tr> <td><xsl:value-of select="TStamp"/></td> <td><xsl:value-of select="Entry"/></td> </tr> </xsl:for-each> </table> </body> </html></xsl:template></xsl:stylesheet> I have two other versions of the HTML file that don't require XSL but they only half work.One displays everything I want but not in the right order the other displays in the right orderbut only displays the first TStamp and Entry. Link to comment Share on other sites More sharing options...
boen_robot Posted November 13, 2006 Share Posted November 13, 2006 First stop, if you want to use JavaScript to render the output of an XSLT transformation, you'll be better off using this script as it's a cross browser one. The one you've copyed only works in IE.As for your problem. I really don't see how you've managed to get even a single entry. I mean, I don't see "tstamp" and "entry" elements. Only "TStamp" and "Entry" ones.What exacltly you want to display and in what order? If you want to display all "TStamp" and "Entry" elements in the order of which each appears in the document, you could do so with something like this: <?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited with XML Spy v2006 (http://www.altova.com) --><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/><xsl:template match="/"> <html> <body> <h2>Current Log</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">TStamp</th> <th align="left">Entry</th> </tr> <xsl:for-each select="//IncidentLog"> <tr> <td><xsl:value-of select="TStamp"/></td> <td><xsl:value-of select="Entry"/></td> </tr> </xsl:for-each> </table> </body> </html></xsl:template></xsl:stylesheet> Link to comment Share on other sites More sharing options...
matthewst Posted November 13, 2006 Author Share Posted November 13, 2006 That's exactly what I want to do but I can't seem to make yours script work either. Link to comment Share on other sites More sharing options...
boen_robot Posted November 13, 2006 Share Posted November 13, 2006 What exactly is not working?In any way, try to change <xsl:template match="/"> to <xsl:template match="/{http://tempuri.org/IncrepDataset.xsd}*"> or simply remove the namespace in the XML. Link to comment Share on other sites More sharing options...
matthewst Posted November 14, 2006 Author Share Posted November 14, 2006 You did it dude!!!!Thanks man!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now