Solved

TransformXML Error

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert html to string 6 34
How do I prevent the pages in my site from showing up in a google search? 2 79
XML SQL 8 25
XML Document XPath with Namespaces 3 20
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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