473,513 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

not well-formed result of transformation not shown properly

Hello !

I was developing xslt sheet lately and - experimenting - I made
mistake resulting in that, the effect of the transformation is not
well-formed xml document.
I made these tests using XmlSpy and in output window I can see two
parallel elements - according to "logic" of me sheet. The error of
that document is that it doesn't have root element.

Here is the contents of XmlSpy output window:
<?xml version="1.0" encoding="UTF-8"?>
<child name="Peter" age="200">
<parent names="Eva" age="10090">
<children>
<child name="Peter" age="200"/>
<child name="Barbara" age="100"/>
</children>
</parent>
</child>
<child name="Barbara" age="100">
<parent names="Eva" age="10090">
<children>
<child name="Peter" age="200"/>
<child name="Barbara" age="100"/>
</children>
</parent>
</child>

I made small C# program intended to make xslt transformation for a
given xml input and xslt sheet. Here is my code:

using System;
using System.Xml;
using System.Xml.Xsl;
using System.IO;

namespace XsltTest
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
if (args.Length!=2)
{
Console.WriteLine("XsltTest InputDoc.Xml TransSheet.xsl");
return ;
}
else
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(args[0]);

MemoryStream memStream = new MemoryStream(1000);
XmlTextWriter xWriter = new XmlTextWriter(memStream,
System.Text.Encoding.UTF8);
xWriter.Formatting = Formatting.Indented;

XslTransform xTrans = new XslTransform();
xTrans.Load(args[1]);
xTrans.Transform(xDoc,null, xWriter, null);
xWriter.Flush();

memStream.Position = 0;
XmlTextReader xReader = new XmlTextReader(memStream);
xReader.MoveToContent();
XmlDocument xDocResult = new XmlDocument();

xDocResult.LoadXml(xReader.ReadOuterXml());

xDocResult.Save(args[0]+".xml");

}

}
}
}

I know there is possible to use other approach (Transform method has
18 overloads !!!!) but I want to have result of transformation as an
XmlDocument object. Save (in last line of the code) is for testing
purposes only.
But here comes my problem. The contents of the written file is only
the first element from results of transformation:
<child name="Peter" age="200">
<parent names="Eva" age="10090">
<children>
<child name="Peter" age="200">
</child>
<child name="Barbara" age="100">
</child>
</children>
</parent>
</child>

Is something wrong with my code, or rather XmlDocument .Net has some
strange behaviour when loading not well-formed xml ?
Nov 12 '05 #1
2 1773
TomekR wrote:
Is something wrong with my code, or rather XmlDocument .Net has some
strange behaviour when loading not well-formed xml ?


XmlDocument class by design supports only XML documents (with a single
root element).

--
Oleg Tkachenko [XML MVP, MCAD]
http://blog.tkachenko.com
Nov 12 '05 #2
> > Is something wrong with my code, or rather XmlDocument .Net has some
strange behaviour when loading not well-formed xml ?


XmlDocument class by design supports only XML documents (with a single
root element).


Oleg ! Thanks for response. That's explains the problem.
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

45
16811
by: Market Mutant | last post by:
I just wonder job selections, job openings and salary level of PHP programer or Perl programmer comparing to Java programmers. Is Java programmer's salary has a minimal of 60K in US? Are there...
14
3419
by: delerious | last post by:
Is there a list of well designed web sites anywhere? Or could you please list some that you think are well designed? Thanks!
58
4615
by: Jeff_Relf | last post by:
Hi Tom, You showed: << private const string PHONE_LIST = "495.1000__424.1111___(206)564-5555_1.800.325.3333"; static void Main( string args ) { foreach (string phoneNumber in Regex.Split...
3
3690
by: Will Woodhull | last post by:
Hi, I'm new here-- I've been reading the group for a couple of days. Nice group; I like the way n00b33 questions are handled. I've been using a Javascript routine in index.html to determine a...
13
7673
by: Adam H. Peterson | last post by:
I just made an observation and I wondered if it's generally known (or if I'm missing something). My observation is that static protected members are essentially useless, only a hint to the user. ...
13
2216
by: Ben | last post by:
Could anyone suggest an open source project that has particularly well written Python? I am especially looking for code that people would describe as "very Python-ic". (Not trying to start any...
1
1696
by: ad | last post by:
I want to determinate if a xml is well-format and valid before export it to database. We can determinate if xml is valid from the article:...
3
3533
by: eliasen | last post by:
Hi I would like to run through an XML file using C# 2.0 and check for well formedness - and I would like to get all errors and not jsut the first one. My code is, off course, very simple:...
18
2524
by: jeff_j_dunlap | last post by:
Dear C++ Users: I alwasy use std::string and avoid char buffers but last night I wanted to see if I could make a C style function that would be thread safe. For me, it was a good learning...
2
6019
by: jeff80 | last post by:
Hello, I'm an absolute newbie when it comes to SQL. I was told that SQL server does not function well on a WAN where network latency between, say, the SQL server and a front-end server is...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.