473,700 Members | 2,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Map XSD/XML data to VB.net classes

Hi,

That's my first post here so I hope this is the right group to post to.
I have to design a good strategy to manipulate XML data in VB.net
language.

Here's the business case:
- I will have a large number (200+) of XML forms created with Infopath
that represents industrial machines specifications. Infopath makes a
XSD available for each form template.
- These forms templates will be maintained by non programmers.
- I am building an application that gathers form data to compute
several indicators (cost, volume, weight...) based on the data inside
the XML files created by Infopath. Implementing these indicators is
rather complex, because of mutual dependencies between forms and other
data non-xml'd. Therefore, computing an indicator cannot be done at
form level.
- structure of XML data is simple (basic types, little repeating
sections, no complex-nested data)

So now, here's the programmer case:
- I have good knowledge of VB.net & SQL Server technologies.
- I have little practice with XPath and Xml Schema.

Since forms templates will change, creating by hand VB classes with a
compatible structure (that maps XSD) will be a big job (several months,
plus added maintenance costs as form templates changes).

So I'd like to solve the more generical problem: how to map XML data
into business components? Is there some way to generate a strongly
typed class from an XSD and instanciate it with a specific XML doc ? Is
there some magical VS.net wizard for that or shoud I implement a
dynamic class creator from XSD?

Thanks in advance,
Pascal.

Nov 12 '05 #1
3 9414
See xsd.exe that is available from the Visual Studio .Net command prompt.
This tool can generated strongly typed classes from an XSD schema.

"Pascal Brunot" <pa***********@ gmail.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hi,

That's my first post here so I hope this is the right group to post to.
I have to design a good strategy to manipulate XML data in VB.net
language.

Here's the business case:
- I will have a large number (200+) of XML forms created with Infopath
that represents industrial machines specifications. Infopath makes a
XSD available for each form template.
- These forms templates will be maintained by non programmers.
- I am building an application that gathers form data to compute
several indicators (cost, volume, weight...) based on the data inside
the XML files created by Infopath. Implementing these indicators is
rather complex, because of mutual dependencies between forms and other
data non-xml'd. Therefore, computing an indicator cannot be done at
form level.
- structure of XML data is simple (basic types, little repeating
sections, no complex-nested data)

So now, here's the programmer case:
- I have good knowledge of VB.net & SQL Server technologies.
- I have little practice with XPath and Xml Schema.

Since forms templates will change, creating by hand VB classes with a
compatible structure (that maps XSD) will be a big job (several months,
plus added maintenance costs as form templates changes).

So I'd like to solve the more generical problem: how to map XML data
into business components? Is there some way to generate a strongly
typed class from an XSD and instanciate it with a specific XML doc ? Is
there some magical VS.net wizard for that or shoud I implement a
dynamic class creator from XSD?

Thanks in advance,
Pascal.

Nov 12 '05 #2
Visual Studio.NET has a tool called XSD.exe, which if given an XSD, will
create a .NET class representation for it.

I don't know anything about InfoPath, but I assume if it is exposing data in
XML (based on the XSD), it will be XML that can be deserialised into a .NET
object (once you've run xsd.exe on it).

Maybe someone else who knows about InfoPath can help a bit more.

"Pascal Brunot" wrote:
Hi,

That's my first post here so I hope this is the right group to post to.
I have to design a good strategy to manipulate XML data in VB.net
language.

Here's the business case:
- I will have a large number (200+) of XML forms created with Infopath
that represents industrial machines specifications. Infopath makes a
XSD available for each form template.
- These forms templates will be maintained by non programmers.
- I am building an application that gathers form data to compute
several indicators (cost, volume, weight...) based on the data inside
the XML files created by Infopath. Implementing these indicators is
rather complex, because of mutual dependencies between forms and other
data non-xml'd. Therefore, computing an indicator cannot be done at
form level.
- structure of XML data is simple (basic types, little repeating
sections, no complex-nested data)

So now, here's the programmer case:
- I have good knowledge of VB.net & SQL Server technologies.
- I have little practice with XPath and Xml Schema.

Since forms templates will change, creating by hand VB classes with a
compatible structure (that maps XSD) will be a big job (several months,
plus added maintenance costs as form templates changes).

So I'd like to solve the more generical problem: how to map XML data
into business components? Is there some way to generate a strongly
typed class from an XSD and instanciate it with a specific XML doc ? Is
there some magical VS.net wizard for that or shoud I implement a
dynamic class creator from XSD?

Thanks in advance,
Pascal.

Nov 12 '05 #3
Thanks Dave.

I've made several tests and I am able to use XSD generated classes with
infopath.

The main problem was that Infopath generates xsi:nil="true" attributes
for value types (int, double etc..) and the XML serialized does not
like it at all. To be handled correctly, the xml node must be completly
omitted in the XML. So to deserialize correctly my infopath form, I
have to apply first a XSL that will delete terminal nil nodes.

Here's my deserialization code that may be useful.
Pascal.

_______________ _______________ _______________ _________

clean.xsl:

<!-- XSL "specialize d identity pattern" -->
<?xml version="1.0" encoding="utf-8" ?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node( )">
<xsl:copy>
<xsl:apply-templates select="@*|node ()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//*[(count(child::* ) = 0) and (string-length(.) =
0)]"/>
</xsl:stylesheet>

VB.net:

Dim xmldser As New
System.Xml.Seri alization.XmlSe rializer(<XSDGe neratedClassNam e>)

docXML = New XPath.XPathDocu ment(New XmlTextReader(" infopathform.xm l"))

transform = New Xsl.XslTransfor m
Dim writer As XmlTextWriter = New XmlTextWriter(" temp.xml",
System.Text.Enc oding.UTF8)
' Apply XSL
transform.Load( "cleaninfoxml.x sl")
transform.Trans form(docXML, Nothing, writer)

writer.Close

' Load object from "clean" XML
Dim st As New System.IO.Strea mReader("temp.x ml")
Dim objSPR As <XSDGeneratedCl assName>
objSPR = CType(xmldser.D eserialize(New System.Xml.XmlT extReader(st)),
<XSDGeneratedCl assName>)

Nov 12 '05 #4

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

Similar topics

0
5402
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access Application Block (DAAB) in our .Net projects. We use SqlHelper in SQL based projects, and OracleHelper in Oracle based ones. OracleHelper was not published officially by Microsoft as part of the DAAB but it was given as a helper code in a sample .Net...
16
3027
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
9
4642
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
1
1211
by: Vikas | last post by:
Hi y'all, I have an existing GUI application where various windows has columns which are mapped to data members of various classes. Now, I have to implement a new functionality to all the classes and I was wondering if I can somehow map the data member fields to the column ids. Following code illustrates the question. // Existing code
28
3413
by: Act | last post by:
Why is it suggested to not define data members as "protected"? Thanks for help!
10
5782
by: Zap | last post by:
Widespread opinion is that public data members are evil, because if you have to change the way the data is stored in your class you have to break the code accessing it, etc. After reading this (also copied below for easier reference): http://groups.google.it/groups?hl=en&lr=&safe=off&selm=6beiuk%24cje%40netlab.cs.rpi.edu&rnum=95 I don't agree anymore.
4
2086
by: Oyvind | last post by:
I'm working on a Windows forms/C# database application. My background is 6-7 years of VB 4 - 6, MS Access, VC++, mixed in with a lot of T-SQL and MS SQL Server in general and some OOA/OOD. Previously, I haven't been overly impressed with the capabilities of the various "graphical" data access tools that have been provided with VB etc. Though deceptively simple to get started with, IMHO they haven't provided the necessary flexibility...
3
1616
by: zc2468 | last post by:
I am new to dot net and would like to write an application using a solid 3 tier design because I expect the app to require a lot of updates and maintenance over time. I am creating my own data objects to interact with the database but the more I understand the DataAdapter classes, the more confused I get. It seems that all I really need my data access classes to do is return a dataset, then accept it back again for updating the...
4
2048
by: alacrite | last post by:
I have a class that I want to turn its contents into csv file. I want to be able to set the value of the delimiter, the name of the file it gets saved to, the path of that file, and maybe a few other things. What would be a good design to accomplish these goals? Here are the ideas that I have come up with: Class X = class with data that I want to put into csv. 1. Nested Function Object use a nested function object to do the conversion.
2
3844
by: Peter Duniho | last post by:
I've been learning about mechanisms .NET offers to export data. The initial goal is to see what sorts of ways are available to save an application's state (document, internal database, whatever). Not counting storing data in a database (which is obviously suitable for some things, but not necessary or even necessarily desirable for other things), here's what I've explored: Serializable attribute, with BinaryFormatter and SoapFormatter...
0
8648
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9081
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
8975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8929
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7816
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6564
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
5904
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
4408
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...
3
2031
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.