Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

TransformXML Error

Posted on 2008-06-11
5
980 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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