Solved

TransformXML Error

Posted on 2008-06-11
5
974 Views
Last Modified: 2012-08-13
I am trying to transform XML with an XSL style sheet.

I read the XML and the XSL from a database, and then need to transform them together to generate HTML output.

When I try to load the XSL string I get the error:
System.UriFormatException was unhandled by user code
  Message="Invalid URI: The Uri string is too long."

CODE
//-----------------------
            XmlDocument oXml = new XmlDocument();
            XslCompiledTransform oXsl = new XslCompiledTransform();

            string transformedXML = string.Empty;
            string xsl = GetXLSByName(name);
            string xml = GetXMLbyShop(shopID, viewTime);
           
            oXml.LoadXml(xml);
            xsl = xsl.Replace(System.Environment.NewLine, "<br/>");
            oXsl.Load(xsl);

            oXsl.Transform(xml, transformedXML);
0
Comment
Question by:Rowdyone52
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:vbwizardry
ID: 21763107
XslCompiledTransform.Load (String) - Loads and compiles the style sheet located at the specified URI.
In your case it looks like you are providing the content of and not the path to the style sheet.
0
 

Author Comment

by:Rowdyone52
ID: 21763122
I dont have a file, I have it stored in a string, is there a way to load the string?
0
 

Author Comment

by:Rowdyone52
ID: 21763304
I am trying to load this strings like below, however I am getting no return for the writer
----
            string xslContent = GetXLSByName(name);
            string xmlContent = GetXMLbyShop(shopID, viewTime);
            xmlContent = xmlContent.Replace(System.Environment.NewLine, "<br/>");

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xmlContent);

            XslCompiledTransform transformer = new XslCompiledTransform();
            transformer.Load(new XmlTextReader(new StringReader(xslContent)));
            StringWriter writer = new StringWriter();

            transformer.Transform(xmlDoc,null,writer);

            Console.WriteLine(writer.ToString());

            return writer.ToString();
0
 
LVL 7

Accepted Solution

by:
vbwizardry earned 500 total points
ID: 21763328
try this out oXsl.Load(new XPathDocument(new StringReader(xsl)));
0
 
LVL 7

Expert Comment

by:vbwizardry
ID: 21763405
if you getting no return you probably have problem within your style sheet. It is not matching data in your XML document. I would output both the xml doc and xsl and use VS IDE to debug it.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now