Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to prevent DTD validation during transform

Thread Tools

How to prevent DTD validation during transform

Posts: n/a
I'm having a problem getting this to work in ASP.NET 2.0. I'm trying to
prevent the validation of a DTD in the incoming XML.

I have this XML that I receive via xml web service from an external source.
In other words, I cannot modify anything about it prior to receiving it.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE UserResponse SYSTEM "UserResponse.dtd"[]>
<Description>Data Validation Error</Description>
<Description>Invalid value</Description>
<Description>Invalid value</Description>

I need to transform it to a string using an XSL stylesheet. I get the
following error when I run this:

Error message:

Date: 9/1/06 11:25:14 AM - Error: CommonFuncs.TransformXsl: Illegal
characters in path.

This is the function I'm using to transform the XML:

Public Shared Function TransformXsl(ByVal xmlFragment As String, ByVal
xslPath As String) As String

' Execute the transformation.
Dim settings As New XmlReaderSettings()
settings.IgnoreProcessingInstructions = True
settings.ValidationType = ValidationType.None
settings.XmlResolver = Nothing
settings.ProhibitDtd = True

Dim xslt As New XslCompiledTransform()
Dim ms As MemoryStream = New MemoryStream()
xslt.Transform(New XPathDocument(xmlFragment), Nothing, ms)

' Load the results into an XPathDocument object.
ms.Seek(0, SeekOrigin.Begin)
Dim sr As StreamReader = New StreamReader(ms)
'Dim doc As XPathDocument = New XPathDocument(ms)

Dim xread As XmlReader = XmlReader.Create(sr, settings)
Return xread.ToString

Catch ex As Exception
AppException.LogError("CommonFuncs.TransformXsl: " & ex.Message)
Return Nothing
End Try
End Function

How do I receiving the incoming XML stream and transform it without
validating against the DTD?

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
blocking I/O with javax.xml.parsers.DocumentBuilder.parse() and javax.xml.transform.Transformer.transform() Java 1 03-27-2005 06:56 AM
How to specify DTD to DTD.getDTD for DocumentParser? Ronald Fischer Java 4 03-17-2005 09:37 AM
Removing the dtd name when using print(...) on the dtd generated class Joseph Tilian Java 0 12-21-2004 02:58 PM
Ignore DTD pi in xsl transform? KatB ASP .Net 1 10-29-2003 02:11 AM