![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm creating an xmlReader to be used in conjuction with an xml document to validate schemas. If I specifiy a FileName in the xmlReader.Create method everything works as it should However if I use the fileName and create a FileStream, when I load the xml document with the reader, I get an error saying that one of the types in the schema can't be found. |
|
I've tried specifying the baseURI when using a stream but this doesn't help. |
|
For example: Private Function GetSchemaReader(ByVal sXMLData As String, ByVal oSchema As Stream) As XmlReader Dim oReader As New StringReader(sXMLData) Dim oXmlReaderSettings As XmlReaderSettings = GetSchemaSettings() AddHandler oXmlReaderSettings.ValidationEventHandler, AddressOf ValidationCallBack Dim oSchemaReader As XmlReader = XmlReader.Create(oSchema, oXmlReaderSettings) oXmlReaderSettings.Schemas.Add(Nothing, oSchemaReader) oXmlReaderSettings.ValidationType = ValidationType.Schema Return XmlReader.Create(oReader, oXmlReaderSettings) End Function |
#3
| |||
| |||
|
|
SBea... (AT) accessitx (DOT) com wrote: I'm creating an xmlReader to be used in conjuction with an xml document to validate schemas. If I specifiy a FileName in the xmlReader.Create method everything works as it should However if I use the fileName and create a FileStream, when I load the xml document with the reader, I get an error saying that one of the types in the schema can't be found. Does the schema have any xs:include or xs:import elements? I've tried specifying the baseURI when using a stream but this doesn't help. For example: Private Function GetSchemaReader(ByVal sXMLData As String, ByVal oSchema As Stream) As XmlReader Dim oReader As New StringReader(sXMLData) Dim oXmlReaderSettings As XmlReaderSettings = GetSchemaSettings() AddHandler oXmlReaderSettings.ValidationEventHandler, AddressOf ValidationCallBack Dim oSchemaReader As XmlReader = XmlReader.Create(oSchema, oXmlReaderSettings) oXmlReaderSettings.Schemas.Add(Nothing, oSchemaReader) oXmlReaderSettings.ValidationType = ValidationType.Schema Return XmlReader.Create(oReader, oXmlReaderSettings) End Function Where do you set a baseURI? Have you tried supplying an XmlResolver for your XmlReaderSettings? -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/- Hide quoted text - - Show quoted text - |
#4
| |||
| |||
|
|
Yes, there are several imports. In fact is on one of the elements refered to by an imports schema that the problem arrises. |
#5
| |||
| |||
|
|
SBea... (AT) accessitx (DOT) com wrote: Yes, there are several imports. In fact is on one of the elements refered to by an imports schema that the problem arrises. Do those xs:import elements use relative URLs so that there could be a problem resolving them? |
#6
| |||
| |||
|
|
<xs:import namespace="http://www.useitx.com/TDL_Interface" schemaLocation="tdl_interface.xsd"/ <xs:complexType name="TDLRequest_DateType" The problem is that the "tdl_interface.xsd" is not being loaded, since a type defined in this file is not found. How would I specify to load this? As I said it works using a file name to load the original but not if it is loaded as a stream. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |