473,386 Members | 1,715 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,386 software developers and data experts.

XmlResolver in .NET v1.1

In pre v1.1, this is how I would do an Xsl transformation:

System.IO.FileStream fs = new System.IO.FileStream(sFilePath,
System.IO.FileMode.Create);
System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(fs,
System.Text.Encoding.Unicode);
try
{
XmlDataDocument xmlDoc = new XmlDataDocument(SomeDataSet);
System.Xml.Xsl.XslTransform xslTran = new System.Xml.Xsl.XslTransform();
xslTran.Load(XslPathUrl);
xslTran.Transform(xmlDoc, null, xtw);
xtw.Close();
}
catch (Exception ex)
{
xtw.Close();
throw(ex);
}

Now in v1.1 I have to use an XmlResolver. The code below works perfectly,
except, I'm not sure if I'm repeating myself since I have to pass the
XmlResolver in two places. Any thoughts? Is this the right way?

System.IO.FileStream oFileStream = new System.IO.FileStream(sFilePath,
System.IO.FileMode.Create);
System.Xml.XmlTextWriter oXmlTextWriter = new
System.Xml.XmlTextWriter(oFileStream, System.Text.Encoding.Unicode);

try
{
XmlDataDocument oXmlDataDocument = new XmlDataDocument(SomeDataSet);
XslTransform oXslTransform = new XslTransform();

XmlUrlResolver oXmlUrlResolver = new XmlUrlResolver();
oXmlUrlResolver.Credentials = CredentialCache.DefaultCredentials;
Evidence oEvidence = XmlSecureResolver.CreateEvidenceForUrl(XslPathUrl) ;

oXslTransform.Load(XslPathUrl);
oXslTransform.Transform(oXmlDataDocument, null, oXmlTextWriter,
oXmlUrlResolver);

oXmlTextWriter.Close();
}
catch (System.Exception ex)
{
oXmlTextWriter.Close();
ExceptionManager.Publish(ex);
throw(ex);
}
Nov 18 '05 #1
0 971

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

Similar topics

2
by: Showjumper | last post by:
I've got the following code. But the XSLTransform line is underlined by the blue squiggle and vs tells me c:\inetpub\wwwroot\Sites\RiderDesign\articles\test.aspx.vb(37): 'Public Sub...
4
by: Erwin Gabler | last post by:
Trying to validate a document with a reference to a DTD ("PUBLIC" identifier): <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE systems-description PUBLIC "-//foo/nono" ""> .... The DTD uses...
2
by: Paul | last post by:
Hi I'm currently having a problem with XMLResolvers. To put it simply using the same stylesheet and the same xml I am getting different results. When using the code and style sheet below. I...
1
by: rocio | last post by:
I'm trying ti use the example in http://support.microsoft.com/default.aspx?scid=kb;en-us;330587#appliesto but doe s not work. I keep getting the error Public WriteOnly Property XmlResolver()...
4
by: damien morton | last post by:
Hi, I need some help... Im trying to use XmlValidatingParser with a custom XmlResolver. Im finding, however, that the custom resolver never gets called, and that the XmlValidatingParser acts as...
2
by: Bennett Smith | last post by:
Could anyone within Microsoft comment on the status of the XmlResolver class in upcoming versions of the .NET framework? I am particularly interested in hearing about any improvements in how...
3
by: Rouven Hertenstein | last post by:
Hi, I'm trying to test the vb.net-exercise "How to use a DataSet with the Office XP Chart Component and ASP.NET" on http://support.microsoft.com/kb/303016/en-us Visual Studio rails against the...
1
by: Keith Chadwick | last post by:
Have been doing a fair amount of reading but at this point no joy. The scenario is - XSL template is stored within db. - Template has a xsl:include statement as <xsl:include...
1
by: cashdeskmac | last post by:
I have this code from an example on the MSDN site: Dim rdr As New XmlTextReader("http://localhost/bookstore/book.xml") rdr.XmlResolver.Credentials = CredentialCache.DefaultCredentials Dim doc As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.