G
Guest
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.
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.