How to prevent DTD validation during transform

Discussion in 'ASP .Net' started by =?Utf-8?B?Sy4gV2lsZGVy?=, Sep 1, 2006.

  1. 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"[]>
    <UserResponse>
    <ResponseHeader>
    <VERSION_4_3></VERSION_4_3>
    <ReferenceNumber>85604579</ReferenceNumber>
    <Timestamp>2006-08-31T12:13:46EDT</Timestamp>
    </ResponseHeader>
    <Body>
    <Status>
    <StatusCode>-245</StatusCode>
    <Description>Data Validation Error</Description>
    <ValidationError>
    <PathName>/UserRequest/Body/CreateIndividual/LoginName</PathName>
    <StatusCode>-2319</StatusCode>
    <Description>Invalid value</Description>
    </ValidationError>
    <ValidationError>
    <PathName>/UserRequest/Body/CreateIndividual/Password</PathName>
    <StatusCode>-2319</StatusCode>
    <Description>Invalid value</Description>
    </ValidationError>
    </Status>
    </Body>
    </UserResponse>

    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

    Try
    ' 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()
    xslt.Load(xslPath)
    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?

    Thanks.
    =?Utf-8?B?Sy4gV2lsZGVy?=, Sep 1, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KatB

    Ignore DTD pi in xsl transform?

    KatB, Oct 28, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    700
  2. Joseph Tilian
    Replies:
    0
    Views:
    351
    Joseph Tilian
    Dec 21, 2004
  3. Ronald Fischer
    Replies:
    4
    Views:
    1,753
    Ronald Fischer
    Mar 17, 2005
  4. Replies:
    1
    Views:
    4,992
    Martin Honnen
    Oct 26, 2005
  5. test
    Replies:
    2
    Views:
    2,025
    Oliver Wong
    Jul 28, 2006
Loading...

Share This Page