Groups | Blog | Home
all groups > dotnet xml > september 2003 >

dotnet xml : XML Transform Problem



B Johnson
9/7/2003 8:37:24 PM
I am trying to transform an xml document using an xsl
document into HTML.

I am getting the following error:

"There are multiple root elements in the output XML."

So I had the contents of the loaded xml document written
out on screen - copied it and placed the contents in a
physical file and saved it. I then created a simple HTML
page with javascript and loaded the xml doc and the xsl
doc I've been using - and javascript with the XMLDOM
object it transforms just fine.

I've ran both the xml and xsl documents in a browser and
they are well formed.

I am baffled. Any clues what is going on?

Thanks


B Johnson
9/8/2003 9:49:16 AM
I changed to using a stream. That worked fine for the
first transformation. But the succeeding transformation,
which is supposed to output HTML tags is failing with the
same error ("There are multiple root elements in the
output XML.").

All the HTML tags fall under one root node which is a div
tag.

Perhaps I'm not understanding what a root element is.

One thing I do notice is that the html is similar to this:

<div>
<table>
<tr>
<td>Test</td>
</tr>
</table>
<table>
<tr>
<td>Test</td>
</tr>
</table>
</div>

So there are children under the DIV element who are on the
same level (ie. table tags).

Any help would be very appreciated.
[quoted text, click to view]
Oleg Tkachenko
9/8/2003 2:44:36 PM
[quoted text, click to view]

Sounds like you are transforming to XmlWriter or XmlReader, both of which
ensure XML document is wellformed (aka has the only root element). Transform
to TextWriter or directly to Stream instead.
Alternatively fix up your stylesheet, because multiple root elements in html
is not good thing either.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
Bjoern Hoehrmann
9/8/2003 3:20:52 PM
* B Johnson wrote in microsoft.public.dotnet.xml:
[quoted text, click to view]

Add a template like

<xsl:template match = '/'>
<root>
<xsl:apply-templates />
</root>
</xsl:template>

Oleg Tkachenko
9/8/2003 10:59:30 PM
[quoted text, click to view]

What's "succeeding transformation"?

Above exception is thrown by XSLT engine when outputted document has
more than one root element (outermost element) and:
1) output method is xml, and
2) you have either doctype-system="ddd" or standalone="yes"
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel
AddThis Social Bookmark Button