473,575 Members | 3,390 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 9411
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
5378
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...
16
3005
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
4630
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
1208
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
3393
by: Act | last post by:
Why is it suggested to not define data members as "protected"? Thanks for help!
10
5770
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...
4
2082
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....
3
1615
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...
4
2042
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...
2
3842
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...
0
7845
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7775
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...
0
8281
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...
1
7868
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...
0
8143
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...
0
6515
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...
0
3778
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...
1
1382
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1107
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...

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.