473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

"Invalid Xml" with XmlTransform

GS
Hi!

I am getting an "Invalid Xml" exception when I try to load an xsl file
using XslTransform.Load(string url). The Xsl file is valid and works
fine if I just rename the file.

There are some postings with this problem, but none of them have a
solution as yet. If anyone has any ideas on how to resolve this, please
do post.

Thank you.

Feb 17 '06 #1
7 2217
GS wrote:
Hi!

I am getting an "Invalid Xml" exception when I try to load an xsl file
using XslTransform.Load(string url). The Xsl file is valid and works
fine if I just rename the file.

There are some postings with this problem, but none of them have a
solution as yet. If anyone has any ideas on how to resolve this, please
do post.

Thank you.


http://msdn.microsoft.com/library/de...loadtopic2.asp
Is this what you're doing?

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

public class Sample
{
private const String filename = "books.xml";
private const String stylesheet = "output.xsl";

public static void Main()
{
//Load the stylesheet.
XslTransform xslt = new XslTransform();
xslt.Load(stylesheet);

//Load the file to transform.
XPathDocument doc = new XPathDocument(filename);

//Create an XmlTextWriter which outputs to the console.
XmlTextWriter writer = new XmlTextWriter(Console.Out);

//Transform the file and send the output to the console.
xslt.Transform(doc, null, writer, null);
writer.Close();

}
}
Feb 18 '06 #2
GS
Yes, but it fails at ---

xslt.Load(stylesheet);

Also the xml and the xsl files are not as simple as in the example.

Feb 18 '06 #3

Are you using a try/catch block and can you see the exception?

GS wrote:
Yes, but it fails at ---

xslt.Load(stylesheet);

Also the xml and the xsl files are not as simple as in the example.

Feb 18 '06 #4

I've seen this happen where you may need to use special entity
characters to replace ampersands and other characters.

SO

<myxml>This & that</myxml>

becomes

<myxml>This &amp; that</myxml>

GS wrote:
Yes, but it fails at ---

xslt.Load(stylesheet);

Also the xml and the xsl files are not as simple as in the example.

Feb 18 '06 #5
GS
I don't know what the problem was, but I re-installed IIS. It certainly
fixed the problem.

Feb 20 '06 #6
I had a likely problem
this part of code:

I am working with .NET and IIS6


Expand|Select|Wrap|Line Numbers
  1. XslTransform xslt = null;
  2. try
  3. {
  4. xslt = new XslTransform();
  5. xslt.Load(currentFile);    
  6. }
  7. catch(Exception Ex)
  8. {
  9. throw new Exception("XSLLoadError", currentFile, Ex.Message);
  10. }
  11. return xslt;
was working for everybody at work exept for me
when the debbuger reach the line

Expand|Select|Wrap|Line Numbers
  1. xslt.Load(currentFile);
it was throwing an exception "Invalid xml"

I was testing the xslt, and it was fine.
I test the xslt with an altern program to transform and xml by using a xslt
and it works fine
so that, the problem was not in the xslt file

I have restarted the server several times, deleted temporal files but the same for one specific XSLT the Exception is thrown again. :confused:

I will try your solution about re-install the IIS. :cool:

for now, after being debbuging, I had the idea to rename the XSLT
and in someway, the

Expand|Select|Wrap|Line Numbers
  1. xslt.Load(currentFile);
works with my XSLT file :D

my old name was: FIN.IN.AR.Carrier.xslt
my new name: FIN.IN.AR.Carriers.xslt

As you can see I cannot find a factible reason why was happing this issue
any idea about the real reason because

after it works I return back to the filename that was wich one I had had the problem

and the problem appeared again :confused:

regards
Mar 2 '06 #7
Me again,

About this problem.

I delete the .NET temp files
from:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Tempo rary ASP.NET Files

besides I remove temp files by using the menu
Tools > Internet Options > delete Files > Delete All Online Content > OK

I thought that that it could fix my problem with the Invalid Xml, maybe it is a problem,
but that does not work, :mad:

I think there are a problem with the memory
with the cache memory or somethig about it :confused:

finally

I create a new website with another diferent name

I install my application in that new Site

and the problem has gone :p


I think that In some way, IIS or the Net Framework itselft was storing a reference to a wrong file

so that, when you re-install the ISS the reference was clearer
and when I create a new Site, the reference was a new one

when I was using the same site, I think it was using the same reference where the error was

If someone had a better answer for this issue
I will be waiting for it

Thanks
Mar 2 '06 #8

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

Similar topics

3
by: Tjerk Wolterink | last post by:
Hello, I've xml code that looks like this: <?xml version="1.0" encoding="ISO-8859-1"?> <xc:xcontent xmlns:xc="http://www.wolterinkwebdesign.com/xml/xcontent"...
6
by: TS | last post by:
Hi, i have a problem validating xml against schema. I used http://apps.gotdotnet.com/xmltools/xsdvalidator/Default.aspx validator and it says it is fine. Can you tell me why this doesn't work? ...
7
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm...
3
by: Arnold | last post by:
I am having problem loading the image from the database. It gives this error: "Invalid parameter used." This is my source code: Private abyt() As Byte Private fo As New OpenFileDialog Private sf...
0
by: sjallard | last post by:
Dear all, This is my first work with the XML extenders: I'll have to decompose an XML file into a DB2 table, and "flatten" it in the same time, like in the example at the end of this message. I...
1
by: Java Guy | last post by:
I'm trying to view a web page. IE tells me there are (Java?) errors on the page. Here they are: Line: 15 Char: 7 Error: Wrong number of arguments or invalid propert assignment Code: 0 URL:...
1
by: =?Utf-8?B?am1ncm8=?= | last post by:
I created a web service in visual studio 2003, tested it with a sample.xml file from a vendor we are using, and it worked exactly like it should. I deployed it to our server, created a project...
0
by: jeoffh | last post by:
Background: I am trying to "merge" some attributes into an existing XML column in my MS SQL 2005 database. The general idea is that I have an XML column in a table and I would like to update/delete...
0
by: r.battistoni | last post by:
Hy to everyone I have created a simple SAX parser for a very simple XML file. When I run the code that follows I get this error: "Invalid hexadecimal character reference" The strange...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.