XSD for Visual Basic Developers
As you develop distributed Web applications, you will need a way to represent your structured data and send it from one tier to the other possibly over the Web. XML is an excellent choice for representing structured data. For example, you’ll find yourself sending XML data between the middle tier and the user interface. The result is a set of middle-tier methods that emit or receive XML strings. You might have a method that receives invoice data like this:
Public Function SaveInvoice(sInvoiceXML As String) As Boolean
This function receives an XML string that contains the invoice document. The function then validates the invoice data according to your business rules then saves it to the database and returns a Boolean indicating success or failure.
When the UI tier wants to invoke this function, they look at the above function declaration and wonder just what the heck does the invoice XML look like? So you might give them an example invoice XML document and tell them this is what they have to send you. This works for a while, until you change the invoice XML document to accommodate a new feature that you’re adding. Now all of a sudden, saving an invoice from the UI does not work and you spend hours troubleshooting the problem before you realize it’s a mismatch between what the UI is sending and what you expect.
The problem here is that declaring XML data as just a String means your function must handle validating the contents of that string to make sure that it is XML and that it is a valid invoice document. It becomes very difficult to ensure the UI is sending you the right invoice document unless you write lots of tedious validation code and you maintain that code as the invoice document evolves. XML schema solve this problem by providing a standard language to communicate the invoice document structure to the UI tier and to validate the invoice document that the UI sends to the middle tier before the middle tier starts processing it. Think of the invoice XML schema as an extension to the above function declaration where you specify exactly what the invoice XML looks like.
Get pdf download XSD for Visual Basic Developers
Related Tutorial
Tags: business rules, developers, document structure, failure, invoice data, mismatch, new feature, schema, user interface, validation code, web applications, what the heck, xml string, xsd
Comments
Leave a Reply