Hello,
I would like to validate the XmlDocument passed into the method below against a DTD. The XmlDocument was constructed in memory (DOM representation). Clearly, I do not need the XmlValidatingReader to read my file. However, I need a way to validate my newly generated XML document before transforming it.
The "Transform" method I call is also marked as "obsolete," and recommends that I use an XmlResolver. I understand that XmlResolver could validate against a DTD, but all of the documentation I have seen is either obscure or doesn't provide a useful example to me (grrr, MSDN). Thanks for your help.
Nick Ruiz
Associate Integrator
PPLSolutions IT Billing and Transactions
I would like to validate the XmlDocument passed into the method below against a DTD. The XmlDocument was constructed in memory (DOM representation). Clearly, I do not need the XmlValidatingReader to read my file. However, I need a way to validate my newly generated XML document before transforming it.
Code:
' Transforms the XmlDocument (stored in memory) to Excel format, and saves it to "savePath".
Public Sub ConvertXmlToExcel(ByVal doc As XmlDocument, ByVal savePath As String)
Try
'Create and load the XSL object
Dim xslTrans As New XslTransform
xslTrans.Load("../../SuezLoader/XML/IpbToExcel.xslt")
'Create an XPathNavigator object and load XML data to be transformed
Dim xPathNav As XPathNavigator = doc.CreateNavigator()
'Create a writer to output the Excel file
Dim txtWriter As New XmlTextWriter(savePath, System.Text.Encoding.UTF8)
txtWriter.Formatting = Formatting.Indented
txtWriter.WriteStartDocument()
'Perform the transform and output the Excel file
xslTrans.Transform(xPathNav, Nothing, txtWriter)
Dim p As XmlResolver
txtWriter.Close()
Catch ex As Exception
Debug.WriteLine(ex.ToString())
End Try
End Sub
The "Transform" method I call is also marked as "obsolete," and recommends that I use an XmlResolver. I understand that XmlResolver could validate against a DTD, but all of the documentation I have seen is either obscure or doesn't provide a useful example to me (grrr, MSDN). Thanks for your help.
Nick Ruiz
Associate Integrator
PPLSolutions IT Billing and Transactions