homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

Whats wrong with my XML/XSL?

 4:08 am on Mar 31, 2006 (gmt 0)

I have created two files, one XML and one XSL, but it outputs only HTML table header and no data which I instruct it to do, can anyone look at it and tell me what I do wrong?

By the way, I am using DOM XML in PHP5 for parsing, it works fine with PHP example files but not with my files.


<?xml version='1.0' encoding="ISO-8859-1"?>


<freports xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'

<freport id='200603268765427382'>
<title type="text">What a day!</title>
<date type="date">2006-03-26</date>
<editorname type="text">James W</editorname>
<articlecontent type="text">
This is a test test, hope it works.
<freport id='200603228765394857'>
<title type="text">Nothing works today</title>
<date type="date">2006-03-22</date>
<editorname type="text">Edvin</editorname>
<articlecontent type="text">
Maybe I shall write something, but not today


<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"

<xsl:output method="html" encoding="ISO-8859-1" />

<xsl:template match="/">
<h2>Style example</h2>
<table border="1">
<tr bgcolor="#9acd32">
<xsl:for-each select="freport">
<xsl:sort select="date"/>
<td><xsl:value-of select="date"/></td>
<td><xsl:value-of select="articlecontent"/></td>

I need to get out all freport nodes sorted by date.

Hope someone knows the answer, thanks in advance ;)



 9:55 am on Mar 31, 2006 (gmt 0)

That XML file doesn't look valid to me - can you call it up in Internet Explorer? I get 'only one top level element allowed' because of the <freport_loc> element


 2:54 pm on Mar 31, 2006 (gmt 0)

I forgot to add the last line to the XML file in the posting, this one:


It shows and works fine in IE, not of course with XSL... And I can parse it with expat method, but not successfully with DOM XML and XSLT, but as I said works fine with examples, even those on en.wikipedia.org


 3:02 pm on Mar 31, 2006 (gmt 0)

I added in the closing </freports> myself before I tried to call it up in IE. As I said I got that error caused by the <freport_loc> - removed that tag and it was fine. I'm on IE6.

There can only be one root element - you have two. I ran it through o'reilly's on-line xml validator as well


 3:37 pm on Mar 31, 2006 (gmt 0)

But what if I wanna add a node which marks the location but doesnt shall show up in freports, how do I do then because I should not place it within freports, that would be wrong structure wise.

And still it doesnt show up at all in PHP5 with DOM XML, works only with expat and no XSL.


 4:08 pm on Mar 31, 2006 (gmt 0)

Just wrap all your current xml in another element


 4:23 pm on Mar 31, 2006 (gmt 0)

But I thought I did that with this line:


But it works without it and not with it :(


 5:19 pm on Mar 31, 2006 (gmt 0)

How about






 1:09 am on Apr 1, 2006 (gmt 0)

Sounds like a good solution, so XML always needs a "root" node to include eveything like HTML <HTML> or else it wont work?


 11:47 am on Apr 2, 2006 (gmt 0)

That's correct. Think of it like a parent/child relationship.


In XML every tag must have a closing tag, and must be enclosed by a parent tag. Remember, you are creating a hierarchal structure to data.

Lemme take a closer look at your XSL.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved