xml:stylesheet references in XML data set

R

Ray Fink

I'm trying to include a reference to an XSL stylesheet as part of an XML
data file. XmlTextReader is choking on this, with an exception stating
"'xml:stylesheet' is an invalid name for processing instructions"

The sample xml file is:

<?xml version="1.0" encoding="utf-8" ?>
<?xml:stylesheet type="text/xsl"
href="http://mycomputer.mydomain/translator.xsl" ?>
<MyDataSet>
<xs:schema id="MyDataSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="MyDataSet" msdata:IsDataSet="true">
etc....

The code that is reading this is straightforward, works fine without the
stylesheet ref
FileStream fsReadXml = new FileStream(fileName, System.IO.FileMode.Open);
XmlTextReader myXmlReader = new XmlTextReader(fsReadXml);
this.dataContext.DataSet.BeginInit();
this.dataContext.DataSet.ReadXml(myXmlReader, XmlReadMode.ReadSchema);
this.dataContext.DataSet.EndInit();

Any suggestions on how to fix or work around this? I'd like to be able to
keep the stylesheet reference with the XML data set, so application data can
be easily reformatted for viewing in Internet Explorer.

-- Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top