472,972 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,972 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 2188
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.