473,688 Members | 3,153 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlReader and <xs:import> in schema

I am trying to produce a generic "audit report" for
various transactions in our application. Each transaction
type defines a document (and has an associated schema).
When a transaction leads to a "write to the database", we
store the dataset's diffgram in the audit table. To
render the audit report we load the diffgram into a
generic DataSet and bind it to a grid. All works well
unless the document's schema had an <xs:import> to bring
in common GlobalTypes.

The orignal code used an XmlTextReader. I thought that we
could use an XmlValidatingRe ader and exploit its
XmlSchemaCollec tion property. In the code below
everything is a local file just to keep the verification
of the concept simple. But the wheels seem to fall off
when I used the XmlValidatingRe ader. For XML files without
<import>s the resulting DataSet object, dsResults, is
Nothing. For files with <import>s deserialization fails
with a schema error (types defined in the import are not
being found -- suggesting that the schema cache does
nothing for the <import>)

Note that experiments have shown xsc.Add() is finding the
refernced schema (misname the file or put an error in the
file and Add() throws an exception). I later desparately
threw in the XmlUriResolver, to no effect.

Any suggestions?
dsResults.Clear ()
' A FileStream is needed to read the XML document.
Dim filename As String = "SmfDg.xml"
Dim fs As New FileStream(file name, FileMode.Open)
Dim xtr As New XmlTextReader(f s)
Try
Dim vxtr As XmlValidatingRe ader = New
XmlValidatingRe ader(xtr)
vxtr.Validation Type = ValidationType. None
Dim xsc As New XmlSchemaCollec tion
xsc.Add
("http://vanguard.com/fima2/TransactionType s.xsd", "C:\\Fim
a2\\Solutions\\ Projects\\Commo n\\DataSets\\Tr ansactions\\"
& "TransactionTyp es.xsd")
xsc.Add
("http://vanguard.com/fima2/SmfDataSet.xsd" , "C:\\Fima2
\\Solutions\\Pr ojects\\Common\ \DataSets\\Smf\ \"
& "SMFDataSet.xsd ")
vxtr.Schemas.Ad d(xsc)

Dim ser As XmlSerializer = New XmlSerializer
(GetType(DataSe t))
'Your results may vary between xtr and vxtr
dsResults = CType(ser.Deser ialize(vxtr),
DataSet)

dgAuditDetail.D ataSource = dsResults
dgAuditDetail.D ataMember = dsResults.Table s
(0).TableName

Catch ex As Exception
Trace.WriteLine (ex.ToString)
Finally
fs.Close()
End Try
Nov 12 '05 #1
1 2684
Ed,

you don't show the XSD file here. Since you say that the .xsd files are
being found successfully, maybe it's in the schemas themselves that they
can't resolve namespaces...

"Ed Bacon" <Ed********@van guard.com> wrote in message
news:d4******** *************** *****@phx.gbl.. .
I am trying to produce a generic "audit report" for
various transactions in our application. Each transaction
type defines a document (and has an associated schema).
When a transaction leads to a "write to the database", we
store the dataset's diffgram in the audit table. To
render the audit report we load the diffgram into a
generic DataSet and bind it to a grid. All works well
unless the document's schema had an <xs:import> to bring
in common GlobalTypes.

The orignal code used an XmlTextReader. I thought that we
could use an XmlValidatingRe ader and exploit its
XmlSchemaCollec tion property. In the code below
everything is a local file just to keep the verification
of the concept simple. But the wheels seem to fall off
when I used the XmlValidatingRe ader. For XML files without
<import>s the resulting DataSet object, dsResults, is
Nothing. For files with <import>s deserialization fails
with a schema error (types defined in the import are not
being found -- suggesting that the schema cache does
nothing for the <import>)

Note that experiments have shown xsc.Add() is finding the
refernced schema (misname the file or put an error in the
file and Add() throws an exception). I later desparately
threw in the XmlUriResolver, to no effect.

Any suggestions?
dsResults.Clear ()
' A FileStream is needed to read the XML document.
Dim filename As String = "SmfDg.xml"
Dim fs As New FileStream(file name, FileMode.Open)
Dim xtr As New XmlTextReader(f s)
Try
Dim vxtr As XmlValidatingRe ader = New
XmlValidatingRe ader(xtr)
vxtr.Validation Type = ValidationType. None
Dim xsc As New XmlSchemaCollec tion
xsc.Add
("http://vanguard.com/fima2/TransactionType s.xsd", "C:\\Fim
a2\\Solutions\\ Projects\\Commo n\\DataSets\\Tr ansactions\\"
& "TransactionTyp es.xsd")
xsc.Add
("http://vanguard.com/fima2/SmfDataSet.xsd" , "C:\\Fima2
\\Solutions\\Pr ojects\\Common\ \DataSets\\Smf\ \"
& "SMFDataSet.xsd ")
vxtr.Schemas.Ad d(xsc)

Dim ser As XmlSerializer = New XmlSerializer
(GetType(DataSe t))
'Your results may vary between xtr and vxtr
dsResults = CType(ser.Deser ialize(vxtr),
DataSet)

dgAuditDetail.D ataSource = dsResults
dgAuditDetail.D ataMember = dsResults.Table s
(0).TableName

Catch ex As Exception
Trace.WriteLine (ex.ToString)
Finally
fs.Close()
End Try

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2174
by: Bernd Oninger | last post by:
As far as I know one could use other xsd schemas with the import and the xlink feature. What are the differences (beside the syntax)? Bernd
6
3846
by: PA | last post by:
My dream XML will look like as follows: <?xml version="1.0"?> <bk:bookList xmlns:bk="urn:BookSampleSchema.xdr"> <book> <title>Doe's Book</title> <author>J Doe</author> <year>2002</year> </book> <book>
0
1278
by: Rupa | last post by:
Hi, Can anyone tell me how to eliminate the import tags from an XSD? I want to be able to take this XSD into a Dataset using the ReadXMLSchema method of a XMLDataDocument. Currently this fails because of the import tag I have in the XSD. Is there a solution for this? Thanks Rupa
5
3810
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace ) Person.xsd includes Common-Naming.xsd ( anonimous schemas ) Common-Naming.xsd includes common.xsd ( both are anonimous schemas ) Compilation of Resident.xsd raise the following exception: "System.Xml.Schema.XmlSchemaException: The attribute 'oid'...
2
5659
by: MarkAurit | last post by:
How does one go about getting the information from an .xsd file into a WSDL document? I have a web service that creates a simple object that IBM Websphere can see and use. Great. However, when I expose a DataSet, Websphere cant use the WSDL document, as it doesnt describe the data elments in the dataset. Im done a lot of readying and looking at posts, and typed datasets sounds like they might be the answer, but I cant figure out how to...
5
5394
by: Jeff | last post by:
We are using .Net and the wsdl Utility to generate proxies to consume web services built using the BEA toolset. The data architects on the BEA side create XML schemas with various entities in separate files for ease of maintainability. These schemas are all part of the same namespace. When defining a web service that access more than one of these entities, the wsdl file generated by BEA contains multiple schema elements with the same...
3
7576
by: sachinvyas | last post by:
Hi, I have following schema saved in new.xsd <?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="http://www.smpte-ra.org/schemas/429.7/2006/CPL" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:cpl="http://www.smpte-ra.org/schemas/429.7/2006/CPL"
2
3080
by: Darrell Plank | last post by:
I'm a real XML novice, but my ultimate goal here is to get a workable schema for the GEDCOM XML format as spec'ed out here: http://www.familysearch.org/GEDCOM/GedXML60.pdf It's a proposed XML format for genealogical records. They include a DTD in the spec but sadly its incomplete in that the spec allows for "html" (unlimited HTML or a subset they don't say) in certain elements to allow for formatting. There is also a sample GEDCOM...
4
1907
by: IsValidUN | last post by:
I have an XSD which has an import to an XSD located on the web which has a DTD within it. (Using VS-2005 2.0 framework) If I load the XSD using the following, it can't find elements defined within the "xmldsig-core-schema.xsd" file, when I validate. Dim oXmlReaderSettings As New XmlReaderSettings() oXmlReaderSettings.ProhibitDtd = False '-- Set for schema validation oXmlReaderSettings.ValidationType = ValidationType.Schema...
0
9076
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6454
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5810
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4321
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4547
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2219
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1952
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.