Introduction - Markups and Scripts

 Top Next

Markup Languages and Programming Scripts :

At first sight this Click Start volume title seems a bit ambitious to say the least. However, don't panic, we are not going to grind through each and every aspect of Markup Languages and Programming Scripts.

But we do need to know what is there, and how they all interrelate, as well as becoming aware of what we as Vulcan and dotNet developers need to research, learn, and take onboard.

Let us throw down a few words (sorry acronyms) to give us the right mind set for the job :-

XML, DTD, XSD, XSLT, XPath, HTML, XHTML, CCS, RSS, DOM, SQL, ASP, ADO, JavaScript, Flash, WPF, XAML, and .NET(dotnet). As well as Flexible Documents, and the Unified Interface.

This all becomes clearer as we fit the parts of the jigsaw together. Below is an image to motivate us - it is a couple of lines of XAML in a free downloadable Microsoft applet called XAMLPad. You don't have to do much to get a result !

There is a wealth of suitable material out there, to aid our understanding of specific parts of the whole 'horizon', as it were. Let's say the topics above form a good part of this horizon.

I intend to try and paint a wider picture, showing how all these various topics fit together, and why these things exist. And when appropriate giving real and repeatable examples, that you can carry out for yourselves.

Obviously, not everything can be directly linked back to Vulcan, but we will try our best. having said that, I have just cast my eyes back to the long list, and ten most definitely relate to Vulcan, without looking too hard. So this volume is a must for guys and gals who are already a few steps down the path to developing with Vulcan.

The notes to come (speaking ahead of myself) are an attempt to help myself, to put all these things in place in my head. I hope it helps you in some way too.

It appears from research and reading done so far, that this may not be as difficult as I first thought, I had just let myself slip too far behind the cutting edge of technological development.

As usual, I am ably helped by colleagues of the Vulcan VOPS community. Thanks go out to these guys and gals - THANKS !

PHH - March 2009.


Change !

 Top Previous Next

"The World has changed - we Must change with it !"

If these aren't the exact words of a recently Very Famous man, then they are close to them.

Someone who is more important than Brian Feldman, and a man who has Bill Gates and the whole of Microsoft under his wing.

His word is good enough to be my command, and it ought to be yours too ;O)

Obama to the rescue !!! ???


Where are we headed ?

vector graphics and screen and image total resizing

no loss of quality as zoom in and out - see silverlight demo part one

printing from browser shell - and similar. Good Bye DIY printing ?

replaced by DIY document style sheet ?


What do we Leave Behind ?

GDI+ pixellated graphics


Sources of Information

First of all, let me tell you of a web link Paul Piko gave to me, it has played a major role in me getting to grips with these topics.

www.w3schools.com is a tremendous source for many of the markup and script related topics I listed in the first part of the Introduction.

So far I have spent hours read through the very clear and concise pages, and I intend to spend yet a good few more ;-)

Do be aware of the age of this site - a lot of this good solid stuff has been there for quite some time.

However, I have to say that as usual, a couple of books also got my mind focused on the job.

XML :

Reading a few pages of "Learning XML" from Erik T, Ray, published by O'Reilly ( sub-titled 'Creating Self-Describing Data' ) dispelled a few fears and got me to see clearly a few points I had previously not understood. I suppose to be honest, that I have been just a bit afraid of all the stuff I have not understood in this wide area. I recommend this book to you.

ISBN-10: 0-596-00420-6

ISBN-13: 978-0-596-00420-0

Here is a flavour of what he has to say :-

"Separate markup from presentation ..

For your document to have maximum flexibility for output format, you should strive to keep the style information out of the document and stored externally. Documents that rely on stylistic markup are difficult to repurpose or convert into new forms."

Dipping into this book while waiting outside of or Doctors was when I twigged to XML data files paired with either a schema file, or a template. We call templates those external supporting files for documents, and schemas those external supporting files for table and relational data. However, in essence they have the same purpose. More of this later.

XML :

If you like a good fistful of book, then here is a recommended 'tome' entitled "the XML 1.1 Bible", 3rd. edition, by Elliotte Rusty Harold. And published by Wiley

ISBN-10: 0-7645-4986-3

*** Note *** this book no longer has a CD in the back cover, with PDF version of the text, and other supporting material. The supporting material is available from the web. Pity, I do like working from PDF versions of a text, particularly when they are related to interactive learning and code entry and trial etc.

WPF and XAML :

Total Training on-line video tuition :

================================================================================================================================

I have used DVD version of training material from Total Training to good effect in the past. Now they offer a very reasonable yearly subscription for on-line tuition material, which is VERY extensive, and also appears to have material available which is not for sale on DVD. I think Visual Studio and Expression Studio are both in this category.

For around £200 or less (they do regular discount deals) you can have unlimited access to a wide variety of quality training material.

Below is a screen shot of the lower portion of the screen, which navigates the choice and selection of material :-

The courses available in the left hand pane form a long list indeed, as seen by the small size of the vertical scroll control 'handle'. however, you can see a few very choice option in the image shown, such as SQL Server, VS 2005/2008, and WPF.

Below are a few more in the Expression Studio suite :-


Information - Data and Templates

Separation - as a General issue :

The point to be made about separating data from information about how to use it, seems to prompt a short discussion about separation in general.

For may developers who have been around a few years, they are all too aware that in the past we have all been responsible for mixing up code which did different 'things'.

The most obvious case of needing a 'layered' structure, or approach, is that of Data Source, Business Objects and User Interface.

Many developers are just forcing themselves to get to grips with a layered solution to their business problems, and yet we are going to see that this is just the tip of the iceberg in reality.

Before you panic, let me say that if we stop to see all of the issues, and what else needs to be given the separate, or layered, approach, we may be pleasantly surprised. In fact our lives as developers may well get easier, and certainly more rewarding.

For years we have talked of "future proofing" our applications - well we all know that is impossible, however, grasping the "separation" issue now, and applying it rigorously will be the closest you will come to such a nirvana !

I was just thinking about when such issues first hit myself, and surprisingly it would appear to be about 1980. Yes, as long ago as that.

Remember folk turning up at Word Processing courses - and remember there was virtually no general understanding of WP in the population at large - and typing hard returns when the text got to the right hand side of the monitor ? Hard to spot on the screen but a mess when printed to the printer ;-)

Then a few years later when the same people turned up (with WP skills and ideas) and wanted to enter the world of DTP - the fight to get them to use customized font styles, and not specific fonts and sizes. And don't forget that this was way before style sheets and the web.

In fact it would appear in hindsight that this issue of separation has been there throughout IT for almost ever !

Now stop looking back, and lets look to the future - some would say today, but we will give ourselves the benefit of a period to catch up. What is obvious on the "separation" issue ?

Well, having been 'tripped up' recently when starting into WPF, to find you can no longer throw a bit of text at a rich text control, we better start there. Lets look at what RTF actually is, by looking at an example of a short note I produced before a visit to a customer of mine.

Yep ! looks a bit of a mess, and a long way from what I typed at my keyboard. What I was expecting to see was what is shown below :-

Please bare in mind that this is a simple note to myself, and that I have not used colours, different sized fonts, other font families, or even font styles etc. etc. - and it still is virtually unreadable in the "unseparated" form.

I use the phrase "unseparated" since WordPad only shows the data characters - that is what I typed. Whereas NotePad shows all the characters in the '.RTF' file itself.

Okay then, point taken, RTF is a mixture of data and formatting instructions. We could say data and style sheet are mixed up, and need to be separated. At one time in the past it may have been seen as 'useful' to have one file and everything rolled into it. On so today - and tomorrow.

If we had our data separate, or held in one file, we could apply different style sheets to produce different display results.

In one sense, applying 'word warp' instead of using hard returns, is the first step in the right direction. So lets look at having plain document data, and different style sheets to apply.

Okay then, now lets look at a simple set of help instructions from a currently developing Vulcan app. - one created in Visual Studio. Because I have not made the Help form modal, I can have two showing at once, and can therefore demonstrate the 'flexibility' to some extent.

We will see that basic document data in just a moment, but for now see that the help notes are displayed in a browser control.

Obviously the form, along with the control, can be sized to suit the user. And this may also depend on the device upon which the information is displayed.

Fine, now we need to take a look at the data as it is held in the help data file. The image below shows the XML format file displayed in NotePad :-

It is not our purpose at this moment to examine too closely the XML structure, or to define any parts. Some of that stuff will be done later.

For now just notice that all the enclosed data (in this example all text) is in meaningful format, and that not information about the display is included - nothing to tell of fonts and colours etc.

So what does the file look like with the information in it to control the display in the browser ? Study the file below :-

=========================================================================================

If you prefer, the right hand text display is in Expression Web, whereas the less colourful on on the left is shown in NotePad.

However, the layout is quite clear in both. This is a CSS or Cascading Style Sheet - quite commonly used on the web with HTML, and the parts of it clearly relate to the data parts shown earlier.

Lets look at the sub-section entitled "HEAD", this is in colour red, since the hex number refers to Red, Green, Blue in it three pairs of values. So 'FF' is red. The font size is also 20.

Likewise, "SUBHEAD" is blue (since the last pair is 'FF' in the hex number) and also font size 20.

Now for the big test, or should I say the meaningful test ? Can we display the same data using a different style sheet and get something quite different to view ?

Look at the image below and judge for yourself :-

Notice that the XML file called "HelpTest3.xml" is part of the URL pointed to at the head of the browser.

Lets check this out to see if it looks like that previously shown :-

The only difference is that in line two the style sheet pointed to is called "HelpTest3.xsl", the data lines are the same.

What of the style sheet ? Well it is different in two ways, obviously the display details must be different, as the visual result is so different.

However, on top of that, we have used an XSLT or XSL format, and not the CSS as first shown.

The XSL format of a style sheet is designed to go 'hand in hand' with XML, and our example is shown below :-

You may also like to see how this XSL file content looks in the software tool "XMLSpy" from Altova :-

================================================================================================================================================================================================

This is a purpose built tool for dealing with all things XML and XSL - just cast your eyes along the toolbar to get some indication.

Finally, before moving on, notice that at the bottom, the little green icon with a tick, suggests that the text contents is valid. More about well formed XML and valid files in another section.

Needless to say it looks a positive state of affairs ;-)

And very finally, the same XML data but with possibly better element names (more meaning?) and also in lower case to make reading easier on the eyes. You will see that tags are case sensitive so we need to take some care.

Here is the XML followed by the XSL :-

=============================================================================================================================================================

==========================================================================================================================================

Let us now move on to the next section, and discuss data schemas. See you there :O)


Information - Data and Schemas

=========================================================================


Browsers - What are They ?

- Navigate the web

- locate web pages

- display these pages

- present text and graphics on screen

- provide some interactivity for the user

- allow for layout 'flexibility'

- prevent unwanted 'outside' access

- provide a degree of 'backward compatibility'

Here is a picture to get us started :-

[ If you can picture something in your mind - then you are well down the road to understanding it - Confucius of Newport ! ]

Here is an early quote - to explain what a browser is and does :

Okay, we have moved on a lot in seven years so see what else we can discover in a Google search !

What about this from NWT ? (still a bit dated !)

Northern Web Technologies :

Web Site Design and Development - Browser Compatibility :

BROWSER

Short for Web browser, a browser software application is used to locate and display Web pages. It can display graphics as well as text. Most modern browsers can present multimedia information, including sound and video, though they require plug-ins for some formats.

DIFFERENT BROWSERS

For you to understand the following information it is helpful if you understand a little on HTML. HTML is the code that creates what you are viewing and your browser is the device used to translate it. A browser takes a web page document written in HTML and translates it into a formatted web page.

The World Wide Web consortium (W3) establishes the basic rules for translating HTML documents. The W3 consortium published the official HTML Standards. Northern Web Technologies validates each and every page of your website through the W3 validation service. The HTML language is continually being upgraded which is why the HTML standards usually run ahead of what the browsers support.

BROWSER VERSIONS

Because the HTML language is continually being upgraded browser versions are continually being upgraded to support the newer portions of the HTML language. A newer browser displays website pages better than an older one. However, most users do not upgrade their browser version unless they need new features or upgrade to a new computer and are happy to keep surfing the internet and viewing websites using their old browser.

This is where it is important for the web designer to create a balance with the use of the HTML code. It is no good building a website with the HTML features of the newer browsers if the older browsers can’t translate it. This also works the other way. Newer browsers can translate the latest Dynamic HTML which can make your website pages look very flashy, but the older browsers will not be able to translate it properly. Your pages may end up unreadable.
Most web designers design their pages to work for the last two versions of the major browsers. It is impossible to design a website that will cater for all the known browsers, but the balance is to design your website for browser compatibility for the majority of the popular browsers.

SCREEN SIZES

Everyone uses monitors with different screen resolutions. A lot of people change the screen resolution to suit their needs. Northern Web Technologies test your web pages using different screen resolutions. This means that your customers won’t have to scroll across the page to read your web pages, which most people find very annoying.

The most commonly used screen resolution is 800 x 600 pixels. However, many newer PC's and Mac's come with monitors that display 1024 x 768 pixels or more, and many people with older PC's have monitors set at 640 x 480. Browsers will actually move the Images around and the lines of text will stretch or shrink, all depending on the monitor's resolution. This can change a beautifully designed website into a mess!

Web TV squeezes web pages into a screen only 544 pixels wide, and then enlarges all the text.


Browsers - Which and Where

==================================================================================================================

WPF and Related technologies :


Chapter 1 - XML - Some Basics

As explained in the introduction, these eNotes are not intended to cover all the details of each technical topic included in the overall 'horizon'.

The link below will cover a huge amount of what you will you may wish to know about XML and related topics.

http://www.w3schools.com/Xml/

Just cast your eyes down the topics on offer - towards the left hand side of the page.

Also don't forget that a number of these topics have a whole learning section to themselves, so XSLT for example, has about twenty sub-topics of its own. But more about that in the next chapter.

===========================================================================================================================

Although we are not going to detail a lot of the XML stuff here, it is important to highlight a few aspects of the markup language in order for us to see how it fits into the present "software scene".

Lets state some important points to remember at all times :-

==========================================================

XML Does not DO Anything :

Maybe it is a little hard to understand, but XML does not DO anything. XML was created to structure, store, and transport information.

What is XML? :

· XML stands for EXtensible Markup Language
· XML is a markup language much like HTML
· XML was designed to carry data, not to display data
· XML tags are not predefined. You must define your own tags
· XML is designed to be self-descriptive
· XML is a W3C Recommendation

The Difference Between XML and HTML :

XML is not a replacement for HTML.

XML and HTML were designed with different goals:

· XML was designed to transport and store data, with focus on what data is.
· HTML was designed to display data, with focus on how data looks.

HTML is about displaying information, while XML is about carrying information.

==========================================================

Now that we have some basics to work with we may start to think about creating some XML of our own from the keyboard.

To this end, we need to know the following :-

=========================================================================

XML is Just Plain Text :

XML is nothing special. It is just plain text. Software that can handle plain text can also handle XML.

However, XML-aware applications can handle the XML tags specially.

The functional meaning of the tags depends on the nature of the application.

=========================================================================

Okay then, so if XML is just plain text we should be able to create a small sample in our standard tools - like Notepad and WordPad.

Well, take great care, it can be very easy to end up with files having the wrong extension using Notepad, and WordPad is RTF based and so extra information gets inserted into your code which you can't see at creation time.

Both correct filename structure, as well as character string content, are crucial to the XML and related files working as they should, or even at all. I know, I have been there ;-)

By all means open an XML file with Notepad to view it, but even then I would advise otherwise if at all possible.

You could even view it in the browser. But why not try to get a better solution from the beginning ?

==========================================================================================

=========================================================================================================================================


What is XML ?

From the previous sub-section we have seen that the W3schools "Learning Zone" says that XML does not do anything, and that it is a way of storing and transporting data.

The data may be in the form of relational database records, or some sort of report document. Obviously documentation itself has a very wide range of possible formats.

In the XML file we have only data, nothing about how to use it.

Extra external files, called schema and template files, can be applied to the XML data file to determine either how it is displayed, or in what way the data is interpreted.

The XSD external file is the schema file, and XSL (or sometimes XSLT) file is the style sheet file.

You may think of the pair of files - XML and XSD, or XML and XSL, as like hand and glove. One is designed to fir with the other - exactly. Well, that is if you get the correct pairing of your files.

We will return to this issue later - checking that the hand fits the glove, so to speak ;-)

Lets focus on the simple text of an XML document file :-

We have seen this before, it produced the help notes for our demonstration app.

Now we will look at it in a bit more detail, and realise that any XML file, without an external partner, is either "well formed" or not. There is no two ways about it !

What is meant by well formed ? Lets return to the w3schools notes to see :-

============================================================

============================================================

So if the XML code obeys all the criteria in the list of syntax rules it is "Well Formed". We as developers may say it is syntactically correct.

However, if the code also checks out against style sheet (or schema) file, then it is "Valid". So valid means the hand fits the glove.

The beauty to the developer of using an editor which is "XML aware", is that it checks out both the syntax and the validation for us. A basic editor does neither, and so you can't tell if you have a problem till 'run time'.

*** note *** remember, you are supposed to be reading the full w3schools notes on this to gain the most benefit from these eNotes.

DTD stands for "Document Type Definition" and is best summarized below :-

A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list of legal elements and attributes.

A DTD can be declared inline inside an XML document, or as an external reference.

Once again this is from w3schools.

We will discuss more on this in chapter 2 which is specifically on style sheets and document description files.

So far in my two year 'quest' into learning Vulcan and dotNet, I have come across and used the relational data record form of XML files, and their related schemas. It will probably be the same for any other newcomer to developing with Vulcan related tools, and Visual Studio.

See the sub-sections two on from this, about how XML can help some common tasks in Vulcan, and just how much (or in fact little) we need to know about the world of XML.

I have to confess, it was a topic which at first I wished to sweep under the carpet - well at least run away from ;-) However, once I realised just how easy it could make certain tasks, then I decided to give it a "good go". To the point of looking for XML ways to do things. This was exactly how I found out how to transform DBF data into SQL tables. Let the built-in XML methods and features do the trick - the big step for me was going to look for them.


Why is it so Important ?

I think you can get a quick grasp of the importance of XML if I show you another snippet from the w3schools site :-

Okay then, if you don't want to know about .NET then you can probably forget about XML.

Alternatively, if you intend to tap into the richness of the .NET Framework (and I am already two years in) then read this snippet :-

================================================================================================

Oh! yes, I see that I have use ADO and Forms quite extensively. Sounds as if this is for me then !

On the other hand I here some say - NO, I am only interested in developing application for local PCs an networks. That's is the first mistake in my book !

In Microsoft designing their new technologies for a Unified Interface (UI) we are in a similar situation now as when, some years ago, people said "I don't want to run my apps on a network" and they kept their heads down and wrote in a style which was certainly NOT multi-user.

Yes, you new guys may laugh, to think that there were times when some (I suspect many) of us ignored networked and multi user application use - but it did happen ;O)

Now it seems as if I here the same cries, just removed along the DateTime line a TimeSpan ! I don't want to design web applications or provide web services - is the cry this time !!

Well, sorry guys, whether you want to or not, we will all be building our apps in future, so that they will work across the net or locally, and the technology employed will be the same, ONE - hence the UI idea.

So hang on, then that makes sense, to send a descriptive set of instructions across the net is why we need an XML style application markup language. So WPF is the user interface of today and tomorrow. Notice I did NOT say web. It is for all, everywhere !

Oh! and as an extra pointer in the way to go, read this :-

So whether we use VIDE, and like it a lot (as I do), we can't ignore that we need to use Visual Studio for our development. No reason why we can't use both, and even (again as I do) use both at the same time, cutting and pasting etc. But one thing we must NOT do is pass up on VS - for what ever reason you choose to give as an excuse.

Yep, I was afraid of VS, but once I had the time to explore it without pressing deadlines for an app to be delivered, I found that it was not the terrible beast I thought it was.

We have no real choice, use VS, and I am sure the next version built on WPF technology similar in style to the Expression Studio suite, will be even better thought through in design terms.

It seems pointless to go any further with this section, the facts point to XML being "a must" !

See you in the next sub-section where we will see how to tap into XML facilities from Vulcan.


How does it Affect Vulcan ?

This sub-section would probably be best renamed as "How does it Affect 'YOU', using Vulcan".

The simple answer to this is it depends how you use Vulcan.

If you use Vulcan as a way of getting the most from the world of dotNet, and all its attendant technologies, then it will affect you a great deal.

Why ? Simply because the technologies interrelating with "all things dotNet" use XML so extensively. Check out the previous section.

A simple example of this is using SQL Server 2005/2008. Send a SELECT statement to find a bunch of records and return the results - well, if you choose to do it one way, you can have a DataTable filled in a DataSet supplied to a method, and the result is a strongly type data table. One short line of code - job done!

With another line or so, the returned data may be displayed in a DataViewGrid - as easy as pie ! So why try any other way if you don't have to ? Once I found this out I was sold.

Apparently SQL Server 2000 was the first time XML functionality was built in, or provided to the developer. I would have thought that it is now "WELL represented" in Server 2008. So I intend to go look for what is on offer to make life both easy and modern.

Visual Studio - Settings : (User and Application)

The new form of INI and Config files - the .NET way in the Visual Studio shell :


Vulcan and XML - Part I

Some Basic Programming Techniques using XML with Vulcan :

In this sub-section I will simply describe to you a few very useful programming techniques which got me into realising that XML was worth considering, and not just something to be avoided, if at all possible.

In the last two years I have written demo and exploratory apps in Vulcan, trying to make full use of all the dotNet facilities on offer in the latest Frameworks of the time. Obviously, I was guided by VOPS colleagues who tried to keep me on the straight and narrow. Let us look first at serialization, a neat and easy way to give up INI files and the like ;-)

Serialization :

If you look up serialization in the SDK before you get into using it, the wording and style of writing may put you off for ever ! The documentation hardly makes this topic accessible to the standard guy like me. But use it I do, and use it I will, AND, it is quite easy to do so.

Let us start by taking a real working example from my SQL demo app called "BEST company". And we will even motivate ourselves with a nice picture too ;O)

The above 'Connection' form is to allow users to set and inspect the connection string required to open a connection to the local SQL Server.

As you can see from the image the test connection was successful and an open state was achieved.

There are buttons to allow the user to see the XML code which is placed in the disk file after serialization.

The general operation of the form is straight forward to understand.

If no disk file were to be in existence, then text box user input may be used to supply the correct details. After a successful 'test' the light purple push button is used to create an XML by serialization.

Then the file may be inspected etc.

The whole purpose of this is to allow the connection string (seen below) to be easily made after reading the XML file at the next app launch.

So now that we have a working example to follow, where do we start ?

Well, it is quite simple really. What I am doing to achieve my aim, is make a single object form a class I call "ConnectionDetails".

This class has been designed to hold all the necessary details related to connecting to an SQL Server on my local machine.

Let us examine the class below :-

==================================================================

Also we need to know that we have to supply a namespace as follows :-

=============================================================================

If you are wondering about the greyed out entry, then I think this was due to recent compiler version changes. It used to work OK when I first made the app, but now I need to use the last line entry.

All to do with namespaces, obviously - version 155 to 156 of Vulcan was the change, I think.

Just be aware of this change, I am still making similar changes in my existing applications.

Okay then, back to our serializable class.

Because I wish all my properties to be persisted when I serialize, I have made them all publicly available. It is not the place here to get into any depth of argument about security issues - we need an approach which works first !

Also before I move on, let me say that not all types can be serialized, the only ones I have had problems with are brush and pen - if my memory serves me well. And even with these there are easy ways to serialize related string types, from which the brush and pen may be re-made when the de-serialization takes place.

As you can see when you study the class above, all types are quite fundamental. These will serialize with no problem at all.

Next step is to see the syntax of the Vulcan code which will carry out the serialization when it is run.

Study the code lines below to see how it is done :-

=========================================================================================

Notice that the XML file itself is created in the same folder as the application. Obviously, when we try to de-serialize we will need to test for the file's existence. Look out for this in the code sections below.

So, this is quite easy to follow. Just populate the object properties with appropriate data, and these values will be placed in a disk file - with XML 'well formed' structure.

Also the object "SELF:oParent:oConnDetails" is an instance of the 'ConnectionDetails' class.

=======================================================================================================================================

And now, here it is displayed in Notepad :-

I have shown this as I have since the tree structure is preserved as it ought to look for an XML data structure - word wrap makes it difficult for the eye to follow.

However, it is even clearer in 'Altova XMLSpy', as shown below :-

========================================================================================================================================================================================================

Notice that the 'blank' fields of User Name, Pass Word and Instance, have all got their opening tags missing. I will need to follow this up, as I was not aware that the code would be classed as 'well formed'.

OK, we are doing well, now we need to see just what Vulcan code is required in order to open and read in such an XML file, and how the object is re-made ready for use.

======================================================================================================

Fine, the above code does not have any surprises to us. Just notice that we need to cast to our desired class after we have de-serialized.

So, where does this leave us - oh, we could see the code which is used at the time we first launch the application itself :-

=====================================================================================================================

Where now ?

Well once you can do one example of serialization, then the world opens up to you 'dumping' all sorts of useful data to disk, so that it is persisted till the next launch of the application in focus.

Examples of what may be done include saving details of the location of forms on the screen, and which monitor (screen) the form is being displayed upon.

I will try and include my demo / test example of this later.

So basically, INI files are out, and config files can be made in XML format. In fact this brings up to our next small section below.

Configuration Files & Application Settings : [ Visual Studio ]

We have seen in the previous sub-section how Visual Studio has some in-built facility to allow both User and Application 'config' files to be created.

If you don't wish to do serialization in your own coding then you had better look out all the details to get the most from the 'settings' facilities that come with the Visual Studio shell.

=========================================================================================================================================

Above is the settings designer screen, we will have to get to grips with it's use with VS, however, notice that although there are font and color entries in the choice list, there are no pen or brush options.

This seems to fit in with my comments earlier of my observations on my report and printing demo app.

If I had to guess, I would suggest that all the designer is setting up for us is an 'automatic' way to create a class for file persisting. The screen allows us to manually, and interactively, add the properties names and their data types. Rather than us hand code them. However, I feel that this is doing something very similar to our code above.

I am interested in the synchronize tab shown above - will need to find out more ;-)

Interestingly, although this is quite new to me (I have never used Settings previously), I have had a quick try and entered into this "BellsAndVulcans" app the details shown below. Note I have provided property names and types just like those in our real example above. However, I have added suitable values so we may be able to trace through any XML data we find, and relate it back to our tests here.

View the image below to see what I have entered :-

And after a solution clean, rebuild, and running the app etc. (not quite sure which of these are required) the following Solution Explorer entry appeared long with the XML code shown.

Look at the property names and values to check that it is all from our first settings interactive input.

==============================================================================================================================================

Okay then, some more success, however, using these values in our code is another matter, and we will need to look into that carefully too.

Just how much of this is automatic, and how much we need to do ourselves, is still unknown to me.

What I do know however, is that serialization is something I will use for getting good solutions to my programming needs. Either doing it manually, as I have done using VIDE for over a year, or using the Settings Designer in VS.

Finally, before we leave application and user settings, lets see what has taken place at a Windows Explorer level, and what files have been created :-

=================================================================================================================================================================================================

Fine, just as we may have thought, one file has been made as a result of out settings interactive inputs.

The App.config file has been automatically created by the VS shell, and the contents are shown above, next to the explorer details.

Only part of the details we input are displayed, enough to convince us of what has taken place.

I have it on good authority from a VOPS supportive colleague, that the application config file has an extra part to it (compared to the user config file) and this is generally included first, at the top of the file.

Let's move on to an even more useful technique for us to employ from our Vulcan code.

See you in the next sub-section where we will cover dumping data to XML files on disk, and reading this data back in when required.


Vulcan and XML - Part II

Data Dumps :

Anyone who has read some of my ClickStart previous volumes of eNotes will realise that I am quite fond of using the technique of 'dumping' data from DataTable objects to disk file.

The term 'dumping' is mine, as I don't know another which seems more appropriate. However, I can't come up with a term for the opposite 'action'. A term which would neatly describe reading the data back into an empty DataTable. I will need to think on this one.

How about data 'Grabbing' to cover the reverse process to 'Dumping' ?

No, just had a better idea "Scooping".

Yes, "Dumping and Scooping" it is !

If we look in the SDk for the DataTable class, what do we find ?

Fine, just as we may expect, methods to read and write from XML data and schema files.

However, according to the SDK notes, the ReadXml method reads the data, and also the schema if it finds one with the same primary name.

We had better examine what the SDK has to say further on this :-

============================================================================================================================================

Well, that seems quite clear, but my preference in coding is to write both methods for read and write - to make it clear to myself when maintaining the code in the future, that I am using the data and the schema files.

You will see my example code below, which uses a file path as the parameter to the methods concerned.

Finally, on the SDK entries, note that below :-

====================================================================================================================

We as developers are not to use this, it is obviously used by the read and write methods we have already discussed.

Fine, we can do as we are bid, and not make problems for ourselves later - just because we don't understand enough ;O)

Lets see some working code in action :-

Let's start with the image of success, there is more to see than there is in the code ;-)

The demo app is one which I included in the first volume of ClickStart last year - and included on the DevFest CD for 2008.

The "File Multi Converter" can dump the DataTable on display in the grid, and make files of different format. We are interested in only XML format for these present notes.

So first there is a section of code to switch, depending on selected format, see this directly below :-

=======================================================================================================================================

So we need to see the code behind the last option, not a lot I have to add ! See for yourself below :-

==========================================================================================

Obviously, the oXDT object is our DataTable object.

From the notes it would appear that if we select a table from a DataSet object, then we can serialize child tables too. We will need to look into this further, since it is outside the scope of my experience to date.

However, this is what the SDK has to say :-

=================================================================================================================================

So is it surprising therefore, that a whole DataSet object can be written to XML file also ?

Fine, now lets move mode - from 'dumping' to 'scooping' !

Let's examine the images below, these are of what is shown on the screen when I point to a pair of existing XML and XDS files, and try to read them into the grid.

Let's see what we have :-

Arrh! The screen looks familiar, no data yet, and the selected in focus data and schema files are shown too.

However, we seem to be getting a message about some sort of validation.

Let's keep going. What else do we get ?

Another message, this time suggesting that some sort of check has been made of data against schema.

And finally, as shown below, we have information shown in the grid of the DataGridView control.

========================================================================================

Okay then, let's take this a section at a time, just to see what code I have written, and what the dotNet class is doing for us.

For now, let us skip the checking parts of any code, and see what happens when the 'scoop' actually takes place :-

=========================================================================

So we instantiate a new DataTable object, and notice we don't give it a name - this is important as it needs to get the name when the schema file is loaded.

I found that if I supplied a name (even the correct one?) I got a run time error. So leave it blank, well use the 'empty' constructor.

Subsequently, if we have the correct file names, then the schema is read in, followed by the data.

Below is the code section which displays the data table in the grid control.

Obviously, the data table is first added to the data set object. yes, there is a line of old VO style code in there too ;O)

I would not use ARRAYs these days - told you I did this some time ago now !

=================================================================================================

Very good so far. Now we have to address the problem of checking the XML file pair before we try to complete the scoop.

Examine the code below and see it all hinges on instantiating an object of the XMLChecker class :-

=====================================================================================================================

This class was given to me by Paul Piko, and replaced an earlier approach. I do need to contact him again to see if there is anything better to use these days.

However, since it seems to do the job OK most of the time (I will explain this remark later), lets us take a look at it and what is does for us.

We will also see it in action when we supply an 'incorrect' pair. And what happens when we supply two 'correct' files which don't belong together ;-)

Well, let's be brave and try the two test files Paul set me a year ago plus.

First of all the result of trying to read them in using the checker class, show that we have a couple of issues.

Lets be even braver and look at the XML code in both files, side by side. If we are lucky we may be able to spot the problem.

View the code below :-

Okay then, I think I know why we have software tools to check and process XML code ;O)

It is not impossible, or even difficult, to find the problems reported - but you do have to train your eye into what you are scanning, and then you could easily miss something.

Let me try to make a second version of the XML data file with the changes I think are required. The we can try again, and I can try and highlight what I have spotted so far.

Keep the thumbs held and those fingers crossed.

Have a look at this the :-

With my newly made XML data file (called "booksSchema2.xml") and the original schema file, we have managed to passed the first test it would seem.

I also have to confess that it took me a couple of more passes through the checker to see what i have not corrected, or left incomplete.

Hurray for checkers, is my sentiment ;-)

Also I have to say I found "Altova's XMLSpy" very useful in doing the editing task. I can see a purchase of this tool looming !

Okay then lets look at the data file which passed the test, it is shown below :-

===============================================================

Lines, 5, 10 25 & 26 have been either changed or added. Check them over against the originals.

Now, if we have got rid of all our errors then it ought to load !? Let's give it a whirl.

In order to catch this new error I change the old and original code I listed above to the following :-

=======================================================

CARE ! CARE ! CARE ! .... we are getting too close I feel. Remember the schema and data from Paul was designed to test the checker class, and show me what should be output when there were errors.

The data required for a data table is the flattest tree we can have. All columns are siblings, so we need to see if we can make a book table for our selves.

As a final part of this sub-section it will prove a valuable exercise, so let's give it a go !

Inputting Our Own Table Data :

For this exercise I am making a new project and keeping the main form (only form) as simple as possible.

Because this is a simple project I will only show the code for the setting up of the DataTable columns for our book information.

See below for code and initial form layout :-

Okay then, the process will be straight forward.

We will resize the column headers to suit our data, and then type in the data from Paul's sample file - keeping as true to the data as possible.

The image below shows the book information fully entered, and the two lines of code in the "DumpXMLpair" method.

I have displayed the contents of both resultant files to show us what we actually have generated :-

============================================================================================================================================================================================

I have to say that it is very easy indeed to set up tables and enter data in this manner.

It is also a big bonus to be able to make our XML files in two simple lines.

Till I wrote these notes I had only read back ('scooped') files which I had generated by table 'dumping', and so I never had any problems as such. I strongly suggest you do the same, unless you really have to do something different, AND, that you read up some more on Schema from the w3schools web note tutorials ;-)

Good Luck!

Final Problem with Our "File Multi Converter" ? :

I will have to talk with Paul and get some more advice - see what happens when we try to use two XML files which know nothing about each other ;-)

[ We could say they are totally incompatible - in street parlance. ]

Between my code and the checker class we are letting through a case where the schema does not match the data in any shape or form.

Could be simple, could be complex. We will have to see.

Now where is Paul's email address ?

Time to move on, see you in the next sub-section where we will look at a VERY useful example of using XML technology to transform our old DBF files into SQL Tables.

PHH - March 2009.

[ more information on the "File Multi Converter" may be found in 'ClickStartVDN' and downloaded from my web site at www.ClickStartVulcan.net ]


Working Code - Checker

Checker code - kindly sent to me by Paul Piko of the GrafXsoft Development Team.

Thanks a bunch Paul for all your help generally in my ClickStart series.

// Application : FileMultiConverter

// XMLchecker.prg , Created : 04/03/2008 16:52:13 PM

#using System.Xml

#using System.Xml.Schema

#using System.Collections

#using System.Windows.Forms

CLASS XMLchecker

EXPORT CheckerXmlReader AS XmlReader

EXPORT CheckerXmlSettings AS XmlReaderSettings

EXPORT XSDfileName, XMLfileName, XMLfolderName AS STRING

PROTECT PathXSD, PathXML AS STRING

PROTECT XMLError, XSDError AS Boolean

EXPORT Error AS Boolean

EXPORT LineErrors := ArrayList{} AS ArrayList

CONSTRUCTOR(cXSD AS STRING, cXML AS STRING, cFolder AS STRING)

SUPER()

SELF:XSDfileName := cXSD:Trim() //------ my schema file -----

SELF:XMLfileName := cXML:Trim() //------ my data file -----

SELF:XMLfolderName := cFolder:Trim() //------ where kept -----

SELF:Initialise()

RETURN

METHOD Initialise() AS VOID

SELF:XMLError := FALSE

SELF:XSDError := FALSE

SELF:Error := FALSE

SELF:PathXSD := SELF:XMLfolderName+SELF:XSDfileName

SELF:PathXML := SELF:XMLfolderName+SELF:XMLfileName

SELF:CheckerXmlSettings := XmlReaderSettings{}

SELF:CheckerXmlSettings:Schemas:Add(SELF:XSDfileName, SELF:PathXSD) //------ my schema file -----

SELF:CheckerXmlSettings:ValidationType := ValidationType.Schema

// Set the validation event handler

// This will call the function ValidationEventHandle() for each validation failure

SELF:CheckerXmlSettings:ValidationEventHandler += ValidationEventHandler{SELF,@ValidationEventHandle()}

SELF:CheckerXmlReader := XmlReader.Create(SELF:PathXML,SELF:CheckerXmlSettings) //------ my data file -----

RETURN

#pragma warnings(3012,off) // empty loop

METHOD DoTheCheck() AS VOID

LOCAL cHead AS STRING

TRY

// Clear any previous line errors if reusing the reader

SELF:ClearLineErrors()

// Read XML data

//#pragma warnings(3012,off) // empty loop

//----- these days (version 156 and later?) we need the #pragma outside the method -----

DO WHILE CheckerXmlReader:Read()

ENDDO

//#pragma warnings(3012,on)

MessageBox.Show("XML file validation finished !", "Paul Piko XML checker :")

CATCH e AS XmlException

cHead := "XmlException: "

MessageBox.Show(e:ToString(), cHead)

SELF:XMLError := TRUE

SELF:Error := TRUE

CATCH e AS Exception

cHead := "Exception: "

MessageBox.Show(e:Tostring(), cHead)

SELF:XSDError := TRUE

SELF:Error := TRUE

END TRY

RETURN

#pragma warnings(3012,on)

#pragma warnings(3009,off) // unused parameter sender

METHOD ValidationEventHandle(sender AS OBJECT, args AS ValidationEventArgs) AS VOID

SELF:LineErrors:Add(XMLCheckerErrorInfo{args:Exception:LineNumber,args:Exception:LinePosition,args:Message})

SELF:XSDError := TRUE

SELF:Error := TRUE

RETURN

#pragma warnings(3009,on)

METHOD ClearLineErrors() AS VOID

SELF:LineErrors := ArrayList{}

RETURN

METHOD GiveReport() AS VOID

//------- will encapsulate all error messages ---------

//------- and present for file dump or printing -------

IF SELF:LineErrors:Count > 0

MessageBox.Show("Number of errors: "+SELF:LineErrors:Count:ToString())

LOCAL i AS INT

LOCAL err AS XMLCheckerErrorInfo

LOCAL c := "" AS STRING

FOR i := 1 UPTO SELF:LineErrors:Count

err := (XMLCheckerErrorInfo)SELF:LineErrors[i-1]

c += String.Format("Line {0}, Column {1}: {2}",err:LineNumber,err:LinePosition,err:Message)+CRLF

NEXT

MessageBox.Show(c,"Errors")

ENDIF

RETURN

DESTRUCTOR()

SELF:CheckerXmlReader:Close()

RETURN

END CLASS

CLASS XMLCheckerErrorInfo

EXPORT LineNumber AS INT

EXPORT LinePosition AS INT

EXPORT Message AS STRING

CONSTRUCTOR(line AS INT, pos AS INT, msg AS STRING)

LineNumber := line

LinePosition := pos

Message := msg

RETURN

END CLASS

======================================================


Vulcan - a Specific Application

DBF file Data Records to SQL Table Rows :

Now that we have some idea of XML, and what an XSD schema file is, let us look at a specific working example of how using XML features - built into dotNet classes - helped me address a real life problem in a large database re-write project in my local city of Cardiff.

For fourteen years we have been building up data in a set of DBF files, started with an original Clipper application. The 'file set' was greatly expanded when we re-wrote the Clipper code completely, using Visual Objects 2.6 - so over the years our data and file set have increased greatly.

The Task :

This can be stated quite simply.

We need to transform, or convert, our existing DBF data into SQL Server table format for Microsoft's 2005 Server.

We need a solution which will effectively give us a "One Button" approach to transforming our whole selected data file set.

The method needs to be reliable, repeatable, and totally based on strong typing if at all possible.

Part of the brief was to keep away from dropping down into CSV format at any stage of the process.

We had looked at other available methods (not many to be found) and CSV seemed to feature in these somewhere.

We are very aware that once the data is taken across into SQL tables, it needs some extensive normalising to bring it up to modern relational database standards. This is most probably true for any data as old as this.

The Approach :

Once I focused on XML as a way to solve our problem - remember, XML was designed to hold and transfer data - it all started to unfold quite nicely.

And in fact worked out to be much easier that I first thought it would be.

From my work with the DataTable class when doing the "File Multi Converter" application, I was well aware that it was easy to convert any DBF file into a DataTable object with correctly typed, and strongly typed columns.

I was aware how easy it was to then make an XML file pair from the DataTable object.

What I did not know at the time, but suspected would exist if I looked, was a way of getting from the XML file data to an SQL table.

A quick 'Google' pointed me in the right direction, and I was made aware of the SqlBulkCopy class in dotNet, which the SDK documentation suggested was a totally new way to do this, and not like the BULK INSERT of earlier SQL Server versions. Yes, the older BULK INSERT had taken a CSV file, and this is what we wished to escape from.

The newer approach using the SqlBulCopy class takes an XML data file. But the table needs to exist, and it is best to have it in a 100% one-to-one column mapping.

Nothing seemed insurmountable - so off I went.

So that I could write this up in Pearls, and to support the recent developments by the GrafXsoft Team, I decided to make a VS solution from nothing.

I was to use methods and parts of code which were tried and tested in the VIDE "File Multi Converter" app. But all was to be dotNet in approach and freshly put together.

Since the code and full VS solution will be available to you, it seems sensible to start at the point where we have the main form to view.

Some basic nuts and bolts of the transformation process have been added to the solution too. See below to get a feel of what we have :-

Okay the, we can point at a source folder, in which our DBF file set resides.

We have the necessary 'parts' which open a DBF file and create a suitable schema for the DataTable from the structure details of the DBF.

Once the table is created and displayed, the schema may be viewed and even printed too.

We will walk through the process of generating the correct column data types, and issuing some suitable DateTime values to the data, in a section to be discuss a little later down the page.

First just lets us view some other images, like the one below which shows we have in place the code 'parts' which allow us to generate the XML file pair, and then read this data back for display purposes.

In an auto batch (one button) process these types of supporting features will be skipped, but they are very useful to see what is going on, and to use in case of any problems arising.

Below the data and the schema are for the table in focus in the grid :-

And now the third image shows we have a suitable code 'part' which processes the schema file and generates an INSERT SQL statement to create a table in the open SQL database.

Please notice that our whole approach to data conversion does not run away from handling NULL values in the database tables.

Another of Paul's good tips was to come to terms with NULLs and their use - not to run away by issuing initial values when the situation did not warrant it.

Do appreciate that this single string of characters shown below, is sent to the Server in a single statement - and this creates the required table structure.

Notice that an extra column is added to the right hand end of the table to serve as a row (or record) identity. It is placed last of all so that the 'one-to-one' column mapping is not 'broken'.

============================================================================================

Obviously, it was necessary to see if this simple procedure would work for my largest DBF. As large as I am likely to have in my whole DBF set, up to the time we actually transfer all data and go live with the new SQL system.

I had a 135 Mbyte file and all records seemed to go over quite smoothly. If anything was discovered it was that the attempt to display the whole text file (of the XML data) in a rich text control, was just a bit too much ;-)

Okay, I can live with that, and it seemed to be only this one big file which caused a problem of this sort.

Right, back to the code.

Walking Through the Code :

Let's now look at how we have solved the few important stages of this problem.

We need to look at :-

- Creating the Table Schema :

- Setting and Adjusting DateTime Values :

- Making the INSERT Statement :

- Doing the Bulk Copy :

Funnily enough, it is the important step of copying the XML data into the new SQL table structure which is the least visible.

I used Management Studio extensively while developing this solution - as you would when doing SQL work.

The other three stages can have meaningful data displayed on screen in some form or another.

Remember, when the "One Touch" button is used for the focus DBF, or the "Auto Batch" button sets the batch process to carry out "One Touch" operations on all of the selected 'batch' files, then the intermediate confirmational 'display' functions are not applied.

For the 'batch' process we only carry out the necessary basic transform operations.

The 'extra' operations (mainly display and confirmation) are very helpful for anyone coming new to the application. Someone trying to learn first time, or refresh their knowledge, about using the tool correctly.

Creating the Table Schema :

The process of taking the structure of an existing DBF and from it making a schema for a DataTable object - one which will eventually receive the DBF data - is not as difficult a task as it may first appear.

Let us list the appropriate code in the live app. , and the talk through the important parts.

Here is the code to be studied :-

====================================================================================================================================================================

No doubt you will be aware that a VO dynamic array is provided as output form the "DBStruct" property of any existing DBServer object.

Here is the relevant section of the VO 2.8 CHM notes :-

========================================================================================================

Once we have this array - at the start of the code section - we can use it to access in turn, each of the fields of the DBF.

For each field we we use its name (character string) to give a name to a new DataColumn object, and then from the type and decimals information for the field, select the most suitable data type for the new column.

In the array the type is held as a single character, it has one of the following values :-

"C", "L", D" and "N"

Most of this is reasonably obvious to a DBF user, and what is new is how the 'Date' type is handled.

In dotNet we have DateTime values, but in the actual SQL tables we have SqlDateTime values. These may be NULL, whereas the former can't.

We therefore need to make make our DataTable columns SqlDateTime (SDT) or the copying process to SQL Server tables will fail. I know, I've been there ;-)

While we are on this subject, you may like to know that DataSet objects do not support System.Nullable<DateTime> either, so it has to be SDT. Been there too !

Fine, the other bits are straight forward, and we end up with as many typed columns as we had typed fields in our DBF.

Now that we have a schema for our new table we can go ahead and fill the table with data values - see the sub-section below :-

Setting and Adjusting DateTime Values :

Okay then, we have navigated around the Date and SqlDateTime problem in going from DBF to SQL tables, but we need to take care of a few, but possible, extreme values.

If we don't do a tidy up of extremes, then we are likely to create exceptions.

Once again, let's look at the code section form the working app., and then we will walk through it to see what is required for success !

=======================================================================================================================

We are limited in what our early dates can be when we use SqlDateTime (SDT) data type columns. Any date before the start of the year 1753 can't be used.

However, a NULL value may be given to the cell value. I will not go into this potentially difficult and complex subject further, since the data I am being asked to transform has no dates before 1753, but does have DBF 'empty' values.

Simply then, for me to solve my problem, i will make NULL any cell with a Date in the DBF of blank or before 1753.

What do we do for the other dates then ?

Well, quite simply we make a DateTime value from the year, month and day values from the VO date. And, since DateTime (DT) is an infinite line with a continuous set of values, we actually make a DT value at the start of the day specified by these values. So hours, minutes and seconds etc. will all be zero.

When the values are decide upon they are added to the new row of the table being created.

There is then a chunk of code which is to update form values so the user can see on the GUI what is the progress of the record to row transformation.

yes, we have a nice progress bar - unfortunately it would appear that Vista users get any colour they wish for the bar, as long as it is GREEN !!!

When a batch of DBFs is being transformed, there is a second progress bar two lines up showing the overall "state of play" and you guessed it, that is green too ;0)

You may be interested to know that the UI display of Fields, Records, Columns and Rows, is a double check that nothing has gone wrong. And at the end, if these are not identical in the ways expected, then an entry is made in the report log being built up as the single file, and batch conversion proceeds.

The "View Log" push button provides access to all stored details of the file transformations attempted.

As you are no doubt well aware, the older style CSV conversions were prone to 'dropping' fields at which point all the other fields 'shuffled' along the record to row mapping - the result being a lesser number of cells than the number of columns. Not a necessary risk any more in the world of strong typing and XML data structures etc.

Making and Applying the INSERT Statement :

Once we have an XSD file we have all the information necessary to create a suitable SQL table in the SQL database.

My eventual aim is for me to use appropriate dotNet class tools to process the text in the XSD and extract the column names and data types.

However, as time is of an essence for our Cardiff project, I have just done some good old fashioned string handling to get me by for the moment.

Lets take a look at what I have put in place, and tested out to appear to do the job 100% as required.

First lets see how we make the SQL script string, and save it in a test file :-

====================================================================================================================================================

The format, or structure, of the SQL script statement required to create a new table, is such that there is a common top and bottom (start and end) to each statement.

The detail of the middle section is totally based on the name and data type of each of the columns.

So the string builder object is built up from sections of text string made to suit the column in focus. The "LineIsDataSpec()" method does this as you shall see very soon.

Once we have all the mid-section lines then the top and tail sections are made and concatenated, with the resultant long string being stored to text file on disk.

A relatively arbitrary value of 130 is used to trap when things may have gone wrong. All my files will make a string much longer than 130 if things go to plan. You can change this if it offends you ;-)

But remember, I am a simple man, and this is a simple solution to the potential problem of making new tables which are not correct, or have blank names etc. etc. etc.

Lets now see how we deal with each line in turn in the XSD file, as it is read in :-

===================================================================================

As you can see from my few lines of string handling code, we identify a line of text as a potential column specification, if it contains two substrings.

These are a head string portion of "<xs:element " and a mid-string portion of " type=".

Why did I do it like this ? Quite simple, I examined many of the XSD file created in the transformation, and realised that this would be sufficient to correctly identify all lines required for the process to succeed.

Look at a small example of and XSD file to see what I mean. It is shown open in XMLSpy (from Altova) :-

=============================================================================================================================================================

So where next ?

Well once we identify a line as needing to be turned into some SQL script to allow creation of a suitable column, we need to process it further.

The "ExtractNameAndType()" method does what we require. It finds both the column name and its data type, and then calls upon the "CreateSQLrecordString()" method to make the string portion to be added to the growing mid-section of the SQL script string.

Let's look at these two methods, one at a time :-

====================================================================================================================================================

This code section extracts the name and data type, then passes these to the 'script creator' method.

Now we can go and see just what is done with these two parameters :-

====================================================================================================================================================

It is probably best to view the resultant section of the SQL string for this particular data file being processed.

Below is the mid-section :-

============================================

As you can see, nothing very complex is being done, but every comma ( or missing comma ) is rather crucial to the success of the table creation process in a few lines time.

First we need to see what the top and tail methods do for us :-

================================================

This is the top section of the SQL script which contains the new table name and some fixed syntax stuff.

Let us see the method code for this :-

=============================================================================================================

And finally, the bottom section - we called 'tail' above :-

=============================================

===========================================================================================================

This bottom, and final, section is constant for all new tables required.

Once we have the full SQL script string we can save it to text file as shown :-

===============================================================================================

Creating the SQL Table :

The last part of this slightly long winded (but not complicated) section is to apply the SQL script to generate the new table.

Oh! and to provide a way to have a table removed, just in case it is required as part of our interactive process ;-)

I had to use this a few times while developing the code as you see it now! What's new ?

===================================================================================================================================================

As you can see I have had to include a few lines here and there to cover when the "One Touch" process in in action.

We don't wish to display unnecessary details if we are in "batch mode".

Removing the SQL Table :

Because this is a much simpler process than creating it, we can do all the code for removal in one method, and it does not get too long.

========================================================================================================================================================================================

And that is it - creation and removal of SQL tables, just as we require.

Doing the Bulk Copy :

Before we do any talking about this process, lets take a look at the code responsible for it :-

[ Remember all we need to do this is a suitable XML file and an SQL table already created. ]

===================================================================================================================================================

Okay then, most of the code is actually for safety, there are only few lines which actually do any 'real' work - six is my estimate.

Obviously, we need a connection to the SQL database, and this SqlConnection is passed into the constructor for the SqlBulkCopy (SBC) instantiation.

The SBC object also needs a table name for the destination table name property, and a correctly filled DataTable object too. This is made from the XML file pair.

And once that is setup we make a method call to the "WriteToServer" method of the class, and BINGO ! Job done.

You could say that the process of writing data to XML files could be missed out, and time saved - BUT - I prefer the process of a one off transformation to XML, and then data stored in the new format.

We intend to keep our transformed files for posterity. Just in case. We don't wish to go back to DBFs.

In any case the added time to the overall process is not a factor to be considered for my current task and project. Another day, another project, it may be different.

This is a solution to meet the needs of our project, not to satisfy the tastes of other onlookers ;-)

You may be interested to know that XML data is not as voluminous as we all may think. In a test carried out by myself, on our sample 'batch of data', we found that a zipped DBF set was larger than a RARed batch of XML/XSD files.

The RAR format is that used by "7Z" too. I got into using WinRAR some time back when I found it did a much better job at compressing DBFs.


XML from Server to Application

So far in this chapter we have looked at how XML code is created at the application end of things.

How our sample application uses dotNet for both internal use and storage to disk file.

However, there is a further aspect which we must consider, and that is what and how the application receives data from the SQL Server.

If we send our SQL select script to the server in a particular way, we get tables of information returned to the application for further processing.

This table information comes back from the server with columns of the tables being strongly typed.

In other words we get back strongly typed tables, just as we have seen previously that we needed a strongly type DataTable object for us to be able to carry out the bulk copying to the newly created tables in the server as part of the transform process.

Obviously, there are still some 'older style' approaches to retrieving data from an SQL server available to the developer - they don't appear to be XML based, and not a lot more code to extract the data type and field names for further use. Even if these older methods are 'supposed' to be faster, they are a lot more work to code.

Personally, I was completely delighted to find the XML table method for receiving my data, I can't get enough of it - and the fact that in a line or two at most, this can be seen in a data grid view control on a form, is a real plus!

Time for an example to see what all this means.

Let us look at the feature provided on the main form, for viewing the copied data - we have two buttons, one for the last 200 rows, and one for the complete table row set.

Let's see the relevant portion of the form :-

As you can see above the 'See First 200' push button option will attempt to find and display the first 200 rows in the table in focus.

Obviously, if there are less then only these will be returned.

Now let's turn our attention to the other button, that to return 'All Records', or in table parlance all rows.

As you can see above there are a total of nearly four thousand rows. Th last column called RECID was added by the application code at the time the SQL tables were made, precisely so we could view and check.

The row numbers we see like this should match exactly those we displayed on the form when the DBF was opened and first read into the DataTable.

If there is any discrepancy, then we record an error message in the report log.

Fine, now we know the problem and what the working solution looks like, let us now see the code which does this :-

==========================================================================================================================================================================

=============================================================================================================================================================================

Because the SQL script is the only thing which is different between the two 'feature buttons', we can separate out this code from the method needed to communicate with the server, and actually send the statement and receive the results.

Let us see the slightly longer method for this below :-

===========================================================================================================================

Yes, okay, I should have changed the name of the table from "CheckBack200" to probably "CheckbackN", when I made this code work for both eventualities.

So, I am human - nice to know ;-)

Anyone interested in the SQL code for the database factory approach, needs to download and study the ClickStartSQL volume which covers this in detail.

We are really only interested in the few lines of code which make it work in th way we are discussing above.

====================================================================================================================

And, out of these only four do what we are discussing.

After we assign the statement text using cScript, we expose the 'Fill()'method from the data adapter, and the data set object is populated with the results table.

Quite charmingly simple, some would say beautiful !

Obviously, to get the results displayed in the grid, we do nothing more than assign the data table to the data source property of the DataGridView control.

To summarise therefore, the server must create and send an XML file or 'packet' back to the application. Since it is XML code we also have the strong typing details included as "part of the deal".


Full Working Code

Enter topic text here.


Chapter 2 - Schema, Style Sheets, etc.

Lets start with a couple of lines from "w3scools" :-

The purpose of a DTD (Document Type Definition) is to define the legal building blocks of an XML document.

DTD defines the document structure with a list of legal elements and attributes.

[ A DTD can be declared inline inside an XML document, or as an external reference. ]

Is DTD old ? :

The Future !? :

XML Schema is used to define the legal elements of an XML document, just like a DTD.

We think that very soon XML Schemas will be used in most Web applications as a replacement for DTDs.

XML Schema is an XML-based alternative to DTD.

Unlike DTD, XML Schemas has support for data types and namespaces.

===============================================================================


DTD

Enter topic text here.


Schema (XSD) - for XML

Let's see what "w3schools" has to say :-

XML Schema is an XML-based alternative to DTDs.

An XML Schema describes the structure of an XML document.

The XML Schema language is also referred to as XML Schema Definition (XSD).

XML Schemas are more powerful than DTDs.

==========================================================

[ We think that very soon XML Schemas will be used in most Web applications as a replacement for DTDs.

The XML Schema language is very rich.

Unlike DTDs, it supports data types and namespaces. ]

==============================================================================

====================================================================================================

So far I have resisted the temptation to just repeat parts of text statements from elsewhere.

I am trying to draw together important ideas to help me, and anyone reading this, understand where we are today with all these related 'web' topics.

What is going to be used in future, and what will be left to one side. This way we can focus our learning energies on topics which will be of use and benefit to us in the future.

However, XSD files are so important to us when using Vulcan and dotNet that we need to view quite a bit of overall wisdom from "w3scools".

So here goes with some more important ideas to take onboard.

Even if documents are well-formed they can still contain errors, and those errors can have serious consequences.

So if we are to get the most from our XML files as 'relational data' (as opposed to document information), we need to use XSD files, and do so wisely and correctly.

We need to know how to check one against the other when we have an XML / XSD file pair.

Instead of these files being a pair - 'floating in space' as it were, the XML file can refer to the necessary XSD file, in a reference line near the start of the XML file itself.

Here is an example :-

However, the file pair we created in an earlier section, directly from a DataTable 'dump' does not do this.

Before we have a look at what we got from the simple "InTable" demo app 'dump', we need to consider the possible benefits of not hard wiring a reference into our XML data file.

Remember that the schema to an XML data file, is like a style sheet to an XML document file. It is possible to apply more than one to the same data, and get different, but perfectly acceptable results.

So why embed a reference when we are dealing with the DataTable example ? Here we tend to Read & Write each file in turn, and don't require a fixed internally coded link.

So our automatically dotNet made XML data file looks like this :-

=======================================================================


CSS - Use on the Web

Style sheets for HTML and web display :

Save a lot of work with CSS!

Use CSS to control the style and layout of multiple Web pages all at once.


Chapter 3 - HTML & XHTML

HTML was designed to display data, with focus on how data looks.

XML and HTML were designed with different goals, one is not to replace the other.

With HTML you can create a Web site.

This is what W3schools has to say :-

If you have read through the section on XML you will be quite familiar with tags and the general tree structure of a markup language.

No doubt like most, you probably started with HTML familiarity before branching out to find out more. That was my experience too.

However, it is useful to compare XML with HTML in a couple of ways. This makes it easier to understand a few ideas, and also quirks of HTML.

We know that XML has to be "well formed", and it not the processing software 'stops'. Well, HTML allows it writer to be a bit sloppy at times.

Sometimes closing tags can be left off - or not included. And also a pair of closing tags may also be in the wrong order - again this is not allowed in XML code.

Let us look at some examples of these :-

I think we should take note of the intension to tighten things up in future ;-) Sorry, these notes are old, the future is already behind us ;O)

XHTML is a stricter and cleaner version of HTML.

I have a feeling the this is what most of us refer to today as HTML, for one, it is easier to talked about in conversation!

It would also appear that the creators of browsers also welcomed the change, or at least got the message :-

XHTML is a combination of HTML and XML.

XHTML consists of all the elements in HTML 4.01, combined with the strict syntax of XML.

XML is a markup language where everything must be marked up correctly, which results in "well-formed" documents.

XML is designed to describe data, and HTML is designed to display data.

Today's market consists of different browser technologies, some browsers run on computers, and some browsers run on mobile phones or other small devices. The last-mentioned do not have the resources or power to interpret a "bad" markup language.

Therefore - by combining HTML and XML (and their strengths) into XHTML, we get a markup language that is useful now and in the future.

We need to write our XHTML code in lowercase letters and always include a closing tag.

So the sloppiness goes and we get :-

Okay, we don't want to get too deeply into this as there are other places to find out sufficient details if we require, but a final few thoughts may be handy to take onboard :-

===================================================

Fine, we are on our way to understanding how modern HTML fits in with the rest of the world surrounding it, and why !

It is now time to go onto the next sub-section where we will look at some software applications which allow a developer to rarely go into the HTML code, and even include JavaScript too.

The JavaScript adds interactivity into web pages - see chapter 8 later in these notes.


Letting the Software do the Work

Remember, any HTML document which is 'double clicked' in Windows Explorer will be displayed in the local browser.

For developers, we call this a 'shell execute'. below is an image of a portion of my WE pane, and I will use version 4 of the file in the image after next.

Let us look at what is being clicked first ;-

Here is what we then get after clicking :-

On the other hand we may with to actually open up the HTML file in the most appropriate software application - where editing may take place.

To open the file in a suitable editor (or similar) we need to use the 'Open with' option from the context menu as shown :-

====================================================================================================

====================================================================================================

Below is what we get when we opt to "Open with" MS Expression Web 2.

Notice it is shown in 'dual' mode. That is design and code mode :-

Personally, since I am not a serious web creator by any means, I use the full power of the designer at all times possible.

This means I have my apps switched into full screen display of the designer.


Chapter 4 - XAML and WPF

Definition :- XAML, Extensible Application Markup Language, is Microsoft's XML-based language for creating a rich GUI, or graphical user interface. XAML supports both vector and bitmap types of graphics, as well as rich text and multimedia files. XAML was introduced in 2003 as the language behind the Windows Presentation Foundation, which is Microsoft's GUI design tool for the upcoming Windows Vista operating system

XAML files can be produced in either Visual Studio, Microsoft's development tool for the .NET Framework, or in Microsoft's Expression toolset for designers, before exporting them to the Windows Presentation Foundation. This allows designers, who focus on the front end of an application, and developers, who focus on the code that defines the front end, to work from the same code base, which improves productivity.

public / developer perception

just a fancy version of Forms 2.0 ?

how do XAML and WPF interrelate ?

and how does silverlight fit in with this too ? LINQ ?

what software do we need to write XAML and to see the GUI results ?

compile interpret

XAML and BAML

you could try Silverlight (a subset of WPF) which is designed and optimized for web scenario.

Microsoft Silverlight is a free runtime that powers rich application experiences and delivers high quality, interactive video across multiple platforms and browsers, using the .NET framework. Learn why Silverlight is right for your business.

Chris Andersen's :-

http://www.simplegeek.com/permalink.aspx/100aec62-3352-4c35-b471-f3f2fa5fac5a

Here introduces one of our current debates - is XAML a programming language or a resource format?

With XAML you can define new types, define interactivity with "def:Code", and specify member variables of the type using "ID". XAML also defines the UI appearance of something, and is used for localization scenarios.

XAML lacks any imperative constructs (branching, etc.).

XAML is more of a "programming model" rather than a language, so we have left it at that - "XAML is a declarative programming model".

The general rules for XAML go something like this:

1. Tag names are class names. The CLR namespace and assembly is discovered by an XML namespace mapping scheme (more later).
2. XML Elements are mapped to CLR properties or events
3. Sub-elements of a tag can either be other class instances or "compound" properties (of the form Type.PropertyName)

There are a few more advanced rules around the "Definition" namespace and Style.VisualTree, but basically these three rules are it. Property values are converted from strings in markup to code using TypeDescriptors (just like in ASP.NET). Rule #3 has some complications to it - there are several ways that a child object gets attached to a parent (IAddChild, IList, etc.).

There is a fourth rule:

4. The root tag of a markup file is the base type of the class the markup file defines.

Thus a file like this:

<Window xmlns="..." xmlns:def="..." def:Class="Window1">
<Button>Hello</Button>
</Window>

Would define a new type called "Window1" that derives from "Window".

Bells and Whistles :

Okay, fine so far, but now I need to make a complaint. One which may be aimed at Microsoft's representatives, or certainly those trying to put WPF


Getting to Grips with XAML

Let us make some simple statements to help us on our way.

XAML belongs to Microsoft !

Where did it Come From ?

Microsoft dreamed it up and created it.

Because it is not 'Public Domain' you will not find it covered in any detail at all in the 'w3schools' web site for learning.

The W3 Consortium covers XML, HTML, and many other related markup and script technologies, including JavaScript, but you will see no mention 'at all' on their 'schools' learning site of XAML.

This is a pity for a couple of reasons, firstly it would help people like me trying to get my head around all this new 'stuff'. And secondly, they do such a good job of explaining things simply and clearly, and without fuss - it would be a good place to start learning XAML if it was under their wing.

However, now I know that I need to look elsewhere, that in itself is a help - I suppose. And it does confirm that I can simply say - "XAML belongs to Microsoft."

What is it ?

We need to be careful answering this question, as we may give the wrong impression. I have read some (in my mind) misleading comments recently while trying to understand this myself ;-)

It is often said to be a markup language, and is based on XML. There is no need to refer to anything else, or throw in other similarities!

Because XAML is XML code, it should be "well formed" when written correctly, and can be checked out as such.

Microsoft have added a whole list of tags, or markup elements which they say are part of XAML. We will explain more of this a little later, but we need to know that what elements exist are simply due to Microsoft's decisions.

So if a piece of software specifically designed for creating, editing and saving XAML code is used, it will also be able to check that no incorrect tags are used - by referring to 'internal' lists available to it.

Although XAML is XML based, we can't add our own elements (or tags) as we can in XML, otherwise all things would be possible, and not checking could therefore be made for correctness.

So to summarize, XAML is an extensive markup language which has been designed and 'built' by Microsoft, we can use the elements they had included (and presumably they may include others in the future).

If we are to create anything ourselves using XAML, we are likely to use a designer application. Although it is straight forward to learn and write XAML, it does lend easily to comprehensive designer tools to make the life of developer and GUI designer so much richer. More of this later.

What does it do ?

Well in one sense it does nothing, in the sense that XML does nothing.

[ On the other hand you could say that it makes WPF possible, and if that is the case then it makes .NET possible. ]

It actually contains all the declarative information to describe a GUI which is to support Microsoft's .NET technologies.

Think of the XAML for a screen, and the GUI itself, in the same way as a shopping list and the pile of goodies themselves.

[ It is very easy to transport the shopping list !]

If you will, it is a 'plan' for the User Interface. This plan can be easily transmitted across the web, and be employed at a remote terminal - the business logic residing on the web server.

So once again we need to consider the 'separation' model. Remember our discussion on 'layering' earlier ? Well, XAML allows the layering of the GUI and the business logic to take place.

Remember, the EXE file is a thing of yesteryear. The execution file has splintered into function parts, those required locally and those which may stay at a distance. This reduces the traffic of transmitted code and information at this same time as vastly improving the experience of the users of web based services.

Summarise this as - "only send the bits you have to" !

What is it for ?

Once again we need to be careful when answering this. Don't lets throw in too many rough comparisons, let us get a few 'critical' ones - which are totally correct.

Microsoft would say 'UI' the Unified Interface.

At a very useful 'free' Microsoft presentation at their Thames Valley site, they said that WPF was best approached and thought about as solving the Unified Interface (UI) problem. I believe four older and separate technologies could be replaced with one. And that would also remove a lot of barriers to developers, and improve experiences for users too.

With WPF and XAML, we can have the same rich technology creating local application GUI screens as that creating remote and web based improved interactive screens.

So simply it is to allow separation of GUI and application logic, such that the same solution can run locally as applications did, as well as remotely as web services. In fact the new program model is really a web service model.

Once we know what it is for, we can see other benefits, like being able to separate the designers who make the XAML for the rich GUI experience, from the developers writing the application logic.

However, be careful when you read some source material, it is often suggested that this is the reason for XAML - not so ! this is a nice side benefit ;O)

If we (by design) have separated the GUI from the application logic at runtime then it is not difficult to see that we can have separation of these two at design time.

Why ?

If you have a business eye view to how MS works, you could say Bill Gates was tired of paying large sums of cash to support four different, and hardly overlapping technologies, attempt to solve the same problem.

Others may say that it is just a natural progression of the development of the IT world we live in.

Myself ? I feel it may be a bit of both. Certainly, the waste of resources must have helped focus the mind on pushing to carry out what seems like a necessary 'next step'

How does it Affect Developers ?

"Simply", in my book.

We can't ignore it. We therefore must either retire of embrace it.

For those who may wish to think about a rush to retirement, I would suggest they research whether this exciting new raft of technologies rolled into .NET are actually an 'excellent' way to enjoy retirement.

Take it from me (a standard computer guy) this stuff is a whole lot easier than it may at first appear. Your in-built fears are doing you a disservice!

I know, I've been there - and escaped! No retirement for me, I am just intending to enjoy my coding and development for years to come - God willing ;O)

Can we as Developers Ignore the new Challenge ?

Well, first of all don't panic!

The answer to this is both yes and no.

The existing world of Forms 2.0 and EXE files, and GDI+ pixellated graphics is going to be around for a while. Also you programs won't stop running over night.

[ I see the new book (arrived yesterday) I am reading on XAML was published in March 2006. ]

Because of the complexity and nature of the this newer world of IT we have long run in times. The wise amongst us will see this as plenty of time to engage it developing new skills, and gradually introducing them into our solutions, as and when we see fit.

The foolish amongst us will see this as an easy way of putting off until tomorrow, or even next week.

Being a bit close to retirement myself, I see these changes in the following way. My age and experience means that for years in the past, we has had to do things the had way as developers and program writers. At time the experience was far from 'rich', sometimes closer to monotonous and unexciting.

So when the world is getting colourful, rich, and more exciting, why run away now ?

In fact as well as the above sentiments being true, it is also true to say that the modern .NET coding approach is far, far, more productive, It has been estimated to be five times faster than previous experiences, and after two years 'at it' I would agree indeed.

Sources of Information :

XAML in a Nutshell - O'Reilly. By Lori MacVittie ( and interesting and experienced lady - and its shows ).

ISBN-10 : 0-596-52673-3

This is also Safari 'Books Online' enabled. Includes Free 45-Day Online Edition - I will try this !

try >> http://safari.oreilly.com

Mapping XAML to the .NET Framework :

Every XAML tag corresponds directly to a .NET Framework class.

The attributes of the tag (or element), correspond directly with the properties of that class.

So a specific property may be 'set' through the inclusion of a specific XML attribute. Remember XAML is XML, and at certain time we will refer to the 'XMLness' of the XAML script. the existence of elements (tags) and attributes, is an XML feature.

Properties that are 'read only' are NOT exposed through XAML. Properties which are public, and which have both a 'Set and a Get' methods, are accessible to developers through XAML.

Let's see how this works out with a simple code example :-

<Button Name="MyPress" Height="50" Width="200" Background="Red" Foreground="White" FontFamily="Times New Roman" FontSize="14" Content="Red Button" />

PROTECT MyPress AS Button{}

MyPress:Background := Brushes.Red

MyPress:Foreground := Brushes.White

MyPress:Content:= "Select"

MyPress:FontFamily := "Times New Roman"

MyPress:FontSize := "14"

MyPress:Height = "50"

MyPress:Width = "200"

We will see how to include reference to the event handler a little later.

The live test of our first XAML script line is shown above.

I have used XamlPad to input and display our code. This obviously check for 'well formed' XML and also correctness of tags and attributes. We say there has been a 'parse check', or the script is parsed.

As you can see there is an applet toggle function which allows parsing and rendering on keyboard entry. This can get a bit annoying once you know what you are doing, so it is easy to turn off and on at will of the user.

See below to see what we get if I change the code and render, and then add a 'typo' and reparse. The error in the text entered is indicated with a small vertical grey marker, and all the text is displayed in red.

Check this out for yourself :-

We must do something about the layout of the XamlPad applet !

Let's see what can be done to improve both readability and display :-

I think you will agree that it has improved somewhat ;-)

If I consult the back of the book of Lori's book (XAML in a Nutshell) I see some predefined colours I can use with brush elements.

See below for the changes :-

So our output get more compact as it gets more interesting ;-)

Notice we have changed the colours of the brushes, and increased the size quite a lot, as well as adding a style of italic.

[ I have yet to find out why it would not take "Bold". ]

Fine, just before we complete this part of our XAML introduction, lets see what happens if we include an attribute in our script in XamlPad which relates to an event and an event handler.

This is what we get :-

It looks as though we need to look at visual Studio itself for this inclusion. And maybe a taste of Expression Blend too.

See you in the next sub-section.


Getting to Grips with WPF

Bells and Whistles :

Okay, fine so far, but now I need to make a complaint. One which may be aimed at Microsoft's representatives, or certainly those trying to put WPF

PHH- March 2009.


Vulcan and WPF

Enter topic text here.


A Working Vulcan Example

Enter topic text here.


Expression Blend, Visual Studio

Enter topic text here.


Chapter 5 - ADO and SQL


What is SQL ?


SQL Script


What is ADO ?


Chapter 6 - .NET (dotnet)

What is .NET, and is it more than a Framework ? :

.NET Defined

We are now moving into the Third phase of the Internet where profit is the main priority. The focus here is to Businesses effectively communicate with their customers and partners who are geographically isolated, participate in Digital Economy and deliver a wide range of services. How can that be possible? The answer, with .NET.

What is .NET ?

Many people reckon that it's Microsoft's way of controlling the Internet, which is false. .NET is Microsoft's strategy of software that provides services to people any time, any place, on any device. An accurate definition of .NET is, it's an XML Web Services platform which allows us to build rich .NET applications, which allows users to interact with the Internet using wide range of smart devices (tablet devices, pocket PC's, web phones etc), which allows to build and integrate Web Services and which comes with many rich set of tools like Visual Studio to fully develop and build those applications.

What are Web Services?

Web Services are the applications that run on a Web Server and communicate with other applications. It uses a series of protocols to respond to different requests. The protocols on which Web Services are built are summarized below:

UDDI: Stands for Universal Discovery and Description Integration. It's said to be the Yellow Pages of Web Services which allows Businesses to search for other Businesses allowing them to search for the services it needs, know about the services and contact them.

WSDL: Stands for Web Services Description Language, often called as whiz-dull. WSDL is an XML document that describes a set of SOAP messages and how those messages are exchanged.

SOAP: Stands for Simple Object Access Protocol. It's the communication protocol for Web Services.

XML, HTTP and SMTP: Stands for Extensible Markup Language, Hyper Text Transfer Protocol and Simple Message Transfer Protocol respectively. UDDI, WSDL and SOAP rely on these protocols for communication.

......

What is .NET Built On?

.NET is built on the Windows Server System to take major advantage of the OS and which comes with a host of different servers which allows for building, deploying, managing and maintaining Web-based solutions. The Windows Server System is designed with performance as priority and it provides scalability, reliability, and manageability for the global, Web-enabled enterprise. The Windows Server System integrated software products are built for interoperability using open Web standards such as XML and SOAP.

..........

.NET and XML

There is a lot of connection between XML and .NET. XML is the glue that holds .NET together. XML looks similar to HTML which is readable and text-based. XML is a method of putting structured data into a text file. XML is the specification for defining the structure of the document. Around this specification a whole family of optional modules are being developed. The reason why XML is linked so much to .NET is, it's platform independent and is well supported on any environment. To move the data contained in an XML file around different organizations using different software on different platforms it should be packed it into something. That something is a protocol like SOAP.

About SOAP

SOAP, Simple Object Access Protocol is a simple, lightweight protocol for exchanging information between peers in a decentralized, distributed environment. It is an XML based protocol that consists of three parts: an envelop that describes what is in the message and how it should be processed, a set of encoding rules and a convention for representing remote procedure calls and responses.

.NET vs Java

Many of us wonder what .NET has to do with Java. Is there any relation between them? Are they similar? and so on. I even hear some people say .NET is Microsoft's answer to Java. I think every language has its own pros and cons. Java is one of the greatest programming languages created by humans. Java doesn't have a visual interface and requires us to write heaps of code to develop applications. On the other hand, with .NET, the Framework supports around 20 different programming languages which are better and focus only on business logic leaving all other aspects to the Framework. Visual Studio .NET comes with a rich visual interface and supports drag and drop. Many applications were developed, tested and maintained to compare the differences between .NET and Java and the end result was a particular application developed using .NET requires less lines of code, less time to develop and lower deployment costs along with other important issues. Personally, I don't mean to say that Java is gone or .NET based applications are going to dominate the Internet but I think .NET definitely has an extra edge as it is packed with features that simplify application development.

I hope the information above puts some light on the technology aspects behind .NET and helps you in getting started.

[ Parts of an article in Startvbdotnet.com ]


What is it - Microsoft Answers

Enter topic text here.


XML and .NET

==============================================================================================================================================================

===============================================================================================


Chapter 7 - Flexible/Flow Documents

Overview :

"The web is King, long live the King !"

Whether you agree with this sentiment or not, it would appear that the web, and the way it appears to work, are with us for good.

In some ways this is a good things, in others a bad ;-)

One thing that most users have noticed is the way that information on a web page often changes its layout as the display window, or browser window, changes its shape and size.

This is very different to our fixed printed layout in the GDI+ pixellated graphics world. However, it is also very easy to print out the information shown in a web page. This seems to be handled by the browser shell.

It would appear the 'Flow or Flexible' Documents, are a part of the new MS "Unified Interface" approach, where one newly thought out approach can replace a few older and restrictive ones, and may give us more functionality at the same time.

If you are going to be around a few more years then you will need to take Flow Documents into account in your applications and solutions.

Let's see what Microsoft Framework 3.5 SDK has to say about the overview :

"Flow documents are designed to optimize viewing and readability. Rather than being set to one predefined layout, flow documents dynamically adjust and reflow their content based on run-time variables such as window size, device resolution, and optional user preferences. In addition, flow documents offer advanced document features, such as pagination and columns. This topic provides an overview of flow documents and how to create them."

Okay then learn we must, so let's go to the next sub section to see what these are.

PHH - May 2009.


What are these ?

What is a Flow Document :

"A flow document is designed to "reflow content" depending on window size, device resolution, and other environment variables. It is designed to be displayed on many different hardware platforms, including 'hand held's and printers, as well as PC monitors.

In addition, flow documents have a number of built in features including search, viewing modes that optimize readability, and the ability to change the size and appearance of fonts.

Flow Documents are best utilized when ease of reading is the primary document consumption scenario.

In contrast, "Fixed Documents" (FDs) are designed to have a static presentation. FDs are useful when fidelity of the source content is essential. See Documents in Windows Presentation Foundation for more information on different types of documents. "

.........................................

As the display area changes, the content reflows to make the best use of the available space.

Flow content can include many components including paragraphs, lists, images, and more. These components correspond to elements in markup code, and objects in procedural code.

WPF :- RichTextBox Class :

Represents a rich editing control which operates on FlowDocument objects.

The first thing to realise about moving from Forms 2.0 to WPF is that the control for display text and images etc. - called the RichTextBox control, is different to that in Forms 2.0 so don't be caught out.

Don't try and throw a character string at the 'text' property - there isn't one. You need to assign a 'FlowDocument' object to the 'document' property instead.

However, it is possible to extract the 'text' content from a RichTextBox quite easily, so all is not lost !

PHH - May 2009.


Why do we use them ?

Enter topic text here.


Flow Related Classes

Flow Document Overview :

===========================================================================

For the purposes of flow content, there are two important categories:

Block-derived classes: Also called "Block content elements" or just "Block Elements". Elements that inherit from Block can be used to group elements under a common parent or to apply common attributes to a group.

Inline-derived classes: Also called "Inline content elements" or just "Inline Elements". Elements that inherit from Inline are either contained within a Block Element or another Inline Element. Inline Elements are often used as the direct container of content that is rendered to the screen. For example, a Paragraph (Block Element) can contain a Run (Inline Element) but the Run actually contains the text that is rendered on the screen.

PHH - May 2009.


What was wrong with the old way ?

Enter topic text here.


What of the future ?

Enter topic text here.


Chapter 8 - JavaScript and Flash

If left to itself, XHTML - or modern HTML - would display a limited amount of features to Browser users.

Many of the more interesting features we have come to expect as standard, on interesting and pleasing to use web sites, are provided by extra scripts.

Remember HTML is now a tight markup language, and part of the XML stable (or family). To add to what can be displayed or rendered by the Browser we have seen, over the years, the development and employment of some addition scripts which provide this extra functionality. Providing some richer features.

Many of you no doubt have heard of JavaScript - well this is explained in the next sub-section - it is responsible for adding the interactivity to the web.

So what is more than one script required ?

I think we had better read and digest this snippet of an article in Wikipedia :-

ActionScript is a scripting language based on ECMAScript.

ActionScript is used primarily for the development of websites and software using the Adobe Flash Player platform ........

Originally developed by Macromedia, the language is now owned by Adobe (which acquired Macromedia in 2005).

ActionScript was initially designed for controlling simple 2D vector animations made in Adobe Flash.

Later versions added functionality allowing for the creation of Web-based games, and rich Internet applications with streaming media (such as video and audio).

So then, a bit to be digested, and looked into in the next but one sub-sections.

It would appear that we are currently at version ten (10) of Flash player and I would think most of us are using version nine by now through our Browsers.

I think is is fair to summarize by saying that ActionScript allows - through the Flash Player - some impressive moving image and sound experiences.

We probably need to find a good example, but you will need to be able to follow the link, as I can't do moving images and video with soundtrack through H&M5, as good as it is ;O)

Easy - found in seconds :-

http://www.adobe.com/products/flashplayer/

Wow! you ought to give this a whirl - a step up from boring old HTML ;-)

Here is a still picture for just a small taste - now go and download Flash Player 10 as the Adobe site suggests you do. I am just about to do it.

=======================================================================================================================================

Okay then enough for now.

You should at least know what this chapter is all about, and what the two scripts Java and Action bring to all our web experiences worldwide.

See you in the next sub-section.


using JavaScript

First of all let us see what W3schools has to say about JavaScript :-

JavaScript is 'THE' scripting language of the Web.

JavaScript is used in millions of Web pages to add functionality, validate forms, detect browsers, and much more.

JavaScript is easy to learn!

Okay then let's take them at face value ;-) If it is that easy to learn then lets us do something now !

I have adapted a trial / test example from the W3 site, to suit our purposes and needs.

This has been entered into the code section of Expression Web 2 (XW2), see below :-

==============================================================================================================

You will notice that the XW2 application displays the HTML in the designer lower section, but does not seem to do anything with the JavaScript (JS).

This is because it is the job of the Browser itself to run JS, and this means we need to shell execute the saved '.html') file by double clicking in Windows Explorer (WE).

===========================================================================================================

Let us see what we get when we complete the Browser launch this way :-

Oh! of course, that security 'thing' I often see while surfing the web. That is what is is doing - not running the JS content of any web page until I give the 'go ahead'.

So let's do that, give permission :-

And please do remember that the extensively used Java language is quite, quite, different. In both their design and their concept.

Java from Sun, is a powerful language like C++ and with its complexity too. It is compiled, and not interpreted as JS is.

So what is the similarity ? Well, just four letters of the name it would appear ;O) Just to help confuse !

At times while using the web you will also see a message to you to say you need to download some extra JS support material.

In fact you may also be aware that similar messages get displayed for your extension - from to to time - about 'Flash'. We will get to Flash and it's 'Action Script' (AS) later.

Flash belongs to Adobe and so we don't see anything in the W3schools site on the topic.

Fine so far, now back to JS :-

What can a JavaScript Do?

- it gives HTML designers a programming tool

- it can put dynamic text into an HTML page

- it can react to (certain) events

- it can read and write HTML elements

- it can be used to validate data

- it can be used to detect the visitor's browser

- it can be used to create cookies

Let us go through these these seven points and explain a little more on each, to help our understanding :-

- HTML authors are normally not programmers, but JS is a scripting language with a very simple syntax!

Almost anyone can put small "snippets" of code into their HTML pages

- a JS statement like this: document.write("<h1>" + name + "</h1>") can write a variable text into an HTML page

- a JS can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element

- a JS can read and change the content of an HTML element

- a JS can be used to validate form data (user input) before it is submitted to a server. This saves the server from extra processing

- a JS can be used to detect the local (or client) browser, and - depending on the browser - load another page specifically designed for that browser

- a JS can be used to store and retrieve information on the local (or client) computer

Now that we have some better ideas as to what JS is, and what it can do for our web pages and hence web site, where do we put the script itself ?

The JS is placed directly into the HTML page itself.

To insert a JS into an HTML page, we use the <script> tag. Inside the <script> tag we use the 'type' attribute to define the scripting language.

So, the <script type="text/javascript"> and </script> tells where the JavaScript starts and ends:

<html>

<body>

<script type="text/javascript">

.....

</script>

</body>

</html>

So far, so good, We now need to know how to get text output onto the page being displayed. This is done with the document.write command.

This is used a bit like a static method in the world of dotNet.

By entering the document.write command between the <script> and </script> tags, the Browser will recognize it as a JS command and execute the code line.

In the case shown below the browser will write Pearl People of the Vulcan NG! to the page:

<html>

<body>

<script type="text/javascript">

document.write("Pearl People of the Vulcan NG!")

</script>

</body>

</html>

Now let us shell execute the new saved '.html' file and see what happens :-

======================================================================================================

Yes, we have success, but not a lot in the Browser.

The W3 learning notes now tells us to try the following. Leave out the script opening and closing tags.

Let's do just that and see what we end up with :-

The changed small HTML document now produces the results shown below :-

=================================================================================================================================================================

Which is what W3 shows us we should get in their working example below :-

=======================================================================================================

This certainly confirms that the script tag indicates to the Browser that the enclose text has to be interpreted as JS, and nothing else.

Lets move on a little.

W3 then has this to say :-

Browsers that do not support JavaScript will display JavaScript as page content.

To prevent them from doing this, and as a part of the JavaScript standard, the HTML comment tag can be used to "hide" the JavaScript.

Just add an HTML comment tag <!-- before the first JavaScript statement, and a --> (end of comment) after the last JavaScript statement.

Some of this seems dated - which modern Browser would be ignorant of the existence of JS ?

However, if it is a standard then lets try it to see what it looks like :-

=====================================================================================================

The two forward slashes at the end of comment line (//) is the JS comment symbol. This prevents JS from executing the --> tag.

Where do we put our JS code ? :

JSs in the body section will be executed when the page loads.

JSs in the head section will be executed only when called.

JSs may be held in an external script file

Let us see examples of each of these, even though we have seen the body example previously :-

===========================================================================================================

And now the second case, when the JS is in the 'head' section.

Scripts that contain functions go in the head section of the document. Then we can be sure that the script is loaded before the function is called.

We will now run the W3 example and see what we get :-

=======================================================================================================

So here is a neat little feature, displaying a message box at page load time. However, do remember, we are not going to get sucked into making these notes a comprehensive set of notes on JavaScript itself. The whole purpose is to place all these modern 'elements' of 'parts' of the IT horizon, into context. To see what does what, and why, etc.

Oh! I should have said, the Browser being used to run this is the latest Google Chrome (version 1.0.154.53).

Finally, we run the JS which calls on the external file. I will leave it to you to work out exactly what text must be in the file.

Hint, note that the file is accessed before the HTML paragraph is rendered / displayed.

======================================================================================================================================

Where to Put the JavaScript :

JavaScripts in a page will be executed immediately while the page loads into the browser. This is not always what we want. Sometimes we want to execute a script when a page loads, other times when a user triggers an event.

Scripts in the head section:

Scripts to be executed when they are called, or when an event is triggered, go in the head section. When you place a script in the head section, you will ensure that the script is loaded before anyone uses it.

Before we move on to another aspect of web page display, let us take time to see a few other JS interactive features which spice things up for the user :-

The above example was one of a possible few 'popup boxes'.

Finally, let us see an event being responded to by our JS code. We will choose the mouse over event, and may have to use Snagit to show the change in the mouse pointer icon too.

For this event example, let us first see the code required :-

And now the two possible states of the output display - one with the mouse 'off' (or not over) the 'target' object, and the other when it is over it :-

Having had success with the demo screen I thought I had better copy and paste the JS into our own file in XW2 and run it in the same way we have run our earlier '.html' files.

So here is our own file :-

[ Notice the two '.gif' files for the mouse over display - before and after - so to speak ! ]

I needed to download and copy the GIF files into the same folder as out 'JavaS04.html' file.

There was a slight 'trick' needed to do this - I will reveal all later ;-)

So, now look at the two mouse-over states below in the IE8 environment :-

This seems to do exactly as we were told to expect by W3schools.

Now, what of the trick to download the images from the URL related to the W3 site ?

Well, one is easy, right click the image and use the context menu option of "Save image as", and place it in the required folder with the HTML file.

However, we can only get to one of the images this way - as soon as we place the mouse over the image to right click, the original 'blue' image is replaced by the pink one :o(

So, how about a bit of 'lateral thinking' - Edward de Bono style ? [ Check out his ways to improve thinking ! ]

Simple - don't focus on the images and the display, focus on the code.

If we change the names of the images around then the other one is available for right clicking and download - "save image as ..".

In fact we only really need to change the name of the image in the 'mouseOut' function so as to gain access to it this way.

For now I think we should leave JS and move on to see what Flash is all about.

What does Flash and its related Action Script do for us and the web ?

See you in the next sub-section.


using Flash and Action Script

Well, even if we don't think we need code (or script) writing skills, we need to know what Flash and ActionScript (AS) is all about.

Also, we need to have the latest version of Flash Player available to our Browser(s) so that they can render the HTLM page content as well as possible.

Browsers use the downloaded Flash Player to interpret the AS so that the desired effects of the designer are achieved.

If any AS to be run needs a version of Flash Player greater than the one currently available to the Browser, we get a download message box, and after our permission is granted a new version is plugged into the Browser framework.

Below is what I got when I searched the Adobe site from my IE8 (Microsoft) Browser :-

===============================================================================================

So seeing that the Flash Player download appears to be Browser related, I tried the same from the new Google Chrome Browser.

The screens below is what I got :-

I was informed that I needed to close the Chrome Browser before install could be accomplished - which I did.

The completed operation happens to be shown over an image - the Browser itself is actually closed.

============================================================================================================================

And while we are in the Adobe sight it seems a good idea to look up some information on ActionScript itself :-

=======================================================================================================================================================================

This following snippet seems appropriate from an Adobe employee :-

[ He at least should know his stuff. ]

=======================================================================================================================================================================

Lee goes on to say :-

Finally, on the ActionScript information finding mission, here is an offering from O'Reilly :-

======================================================================================================================================================================

From this information available on the Adobe web site it would appear that ActionScript 3.0 (AS) has gone 'OO' recently, so it must not have been able to handle the object approach previously.

Reading this, and also doing some learning about the Expression Studio suite from Microsoft, I think I will not invest any more time in AS until I have thoroughly checked out the way WPF is heading, and what the Designer 2 application does.

The reason I say this is to keep in-line with my strategy I previously discussed, that of spending what time and effort I have on only things that will be around in a few years time. Some may call this trying to "pick the winner"!

However, I don't think that WPF and Silverlight technology will disappear, so I had better see what that has to offer first ;-)

The Unified Interface (UI) is trying to simplify the number of technologies required to present a rich user interface both locally and across the web.

I hope to feed back on this in a little while.

After some Research :

Okay, I have found out from watching a few free video downloads from the Microsoft site pages, that Desinger 2 is the still image design tool, and does some great stuff to slice images up for transport to HTML. You need to see it in action, great stuff, life will be a lot easier to many.

Note however, that slices can also be as easily exported to WPF and Expression Blend 2, as well as Siverlight. So we can guess where things are heading ;-)

Here is a fun image from the free video download :-

Also, I have found that the software tool in the Expression Studio suite for handling video, moving images, and sound tracks, is Encoder 2.

The target for the results is a Silverlight solution. I will now go find out more about Encoder2, and how this fits with WPF and Silverlight.


Chapter 9 - Silverlight


Training Materials - Video

Some more Lateral Thinking :

If you doubt the seriousness of Silverlight then use this as an indicator of whether you need to learn anything about it, or even bother with it at all.

In the past Microsoft have made available for free download, training materials to support some of their major products. I for one, got myself into SQL Server with the 13 Bob Tabor videos which I downloaded and re-viewed a few times.

I have also criticised Microsoft heavily over their inability to present their technologies in a clear and accessible way to those who ought to be able to understand - like myself.

However, here with Silverlight (version 2) we seem to have a new and refreshing situation.

I have easily found via the MS home page and searching, the link shown below :-

http://silverlight.net/learn/videocat.aspx?cat=2#HDI2Controls

This site has an unbelievable large set of video clips fro free download. I have shown some parts of the site below - to give you a flavour of what is in store, and to motivate you to go and grab yourself a whole library of free traing material on Silverlight.

I have now downloaded seventy one (71) such '.wmv' files which amounts to a grand total of 3.1 Gigs of just .WMV file material.

[ There was one file I could not download in what I call the usual way - it always started to play instead ;-) - see below (later) for how to download these more modern video offerings !!! ]

So if you wish to learn from this material then you better put aside a full weekend - as the total viewing time is 21 (yes, twenty one) hours.

I suggest that this tells us a lot about the likelihood of us as developers needing to know about Silverlight.

And, while I am on this subject, I see there are other suitable materials on offer too. For more information on this link :-

http://expression.microsoft.com/en-us/cc136535.aspx

See my notes after the Silverlight images below :-

=====================================================================================================================================================================

Controls :

====================================================================================================================================================================

Data :

====================================================================================================================================================================

Media :

===================================================================================================

And now as promised above, we will look into what else is available from MS and the web for our education.

Here is your option choice in the supplied link :-

[ http://expression.microsoft.com/en-us/cc136535.aspx ]

There seems to be a lot on offer - a step up from the SQL Server 2005 (thirteen in total) Bob Tabor videos in the past.

Lets just hope we get some on Visual Studio 2008 (and later) as well as SQL Server 2008. I need to search some more to see what is there now.

Here is what you get for one selection from the link - as indicated by the colour change above :-

===============================================================================================================================================================================================

How to Download the Modern Video Offerings from MS :

When I first started downloading, I did the seventy Silverlight video files - only one of which appeared to give me a problem.

Well 'old dog' and ''new tricks' but in this case I was taught ;O) The newer video clips from MS seem to be done in a thoroughly modern way, and a way built around their new technologies I suspect.

Whe you select in the Browser to download the WVM version, the media player is launched on your PC and it starts to play. There is no download option dialog box as we have been used to.

At first I thought this would stop me getting a saved file where I could locate it afterwards and review while not on the web. However, the 'new tricks' are well learned ;-)

Simply realise that it still takes time to download your file, and it is downloading while it starts to play the clip in the media player.

So, we are okay - BUT - don't listen to it in real time if all you want is to download a copy. Keep dragging the slider to advance in large jumps through the file. It may show a buffering message at bottom left of screen, so let it have its head. You can hear your hard drive still capturing the download file, so eventually it will be completed. Make sure you have the slider completely to the right of screen.

When you see the icon in the top right of screen of the play list type pane (see image below) then right click in the menu bar to get the context menus as shown. From here you can save to file, and in the folder of your chaoice, in the usual way.

========================================================================================================================================

You will need to employ this technique if you wish to download and capture the video files for all the Expression Studio applications.

For now, get the Silverlight ones and learn some new and exciting 'stuff'.

Good Luck !


What is it ?


How do we use it ?

Enter topic text here.


When will it be Commonly Used ?

Enter topic text here.


Chapter 10 - LINQ

SQL technology and developing applications :

Looking back to see where we have been, and turning to face today, and where we are headed :

I only came to SQL via ADO.NET last June, some nine months ago now. Since then I have enjoyed using it and was surprised from early days as to the fact that it just worked.

After a little while of writing Vulcan dotNet code however, I thought that the interface for my Vulcan code to the SQL scripting was, and felt, rather old fashioned.

In the world of dotNet to which I had become accustomed after 18 months or more, the need to 'drop out of object thinking' seemed "odd" to say the least !

I felt in my bones the MS would not leave things like this, and that something would turn up. In my ignorance I thought the solution would come from the direction of SQL Server 2008 - so it would appear as though I was wrong on one account at least.

Apparently, I should have know about LINQ, this is the answer to my prayers for "Objects Everywhere", and it is Visual Studio 2008 where I should have turned for an answer ;-)

I hope the following chapter is as illuminating to me as it proves to you too.

However, I don't know what I am so happy about, it would seem I may have a lot of demo apps to convert to a more modern way of doing things.

Oh! I fear I may dismay some of my colleagues, as I fear LINQ may be only compatible with MS SQL Server 2008, and not other proprietary brands of server.

We shall see in time.


Video Training Material

Downloading Free Video Material :

Try to find the link below :-

http://windowsclient.net/learn/videos_linq.aspx

I used this link (shown in the next image) to download the whole set of 19 video files.

This totals to a grand value of 4.8 hours of LINQ tuition to guide us on our way.

==========================================================================================================

===========================================================================================================================================

Good Luck with the download, and enjoy LINQ.

And remember, Confucius of Newport said ..... "Objects are good, more objects are better!"


What is LINQ ?

Language Integrated Query

From Wikipedia, the free encyclopedia.

http://en.wikipedia.org/wiki/LINQ

Language Integrated Query (LINQ, pronounced "link") is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages.

Microsoft LINQ defines a set of proprietary query operators that can be used to query, project and filter data in arrays, enumerable classes, XML (XLINQ), relational database, and third party data sources. While it allows any data source to be queried, it requires that the data be encapsulated as objects. So, if the data source does not natively store data as objects, the data must be mapped to the object domain. Queries written using the query operators are executed either by the LINQ query processing engine or, via an extension mechanism, handed over to LINQ providers which either implement a separate query processing engine or translate to a different format to be executed on a separate data store (such as on a database server as SQL queries (DLINQ)). The results of a query are returned as a collection of in-memory objects that can be enumerated using a standard iterator function such as C#'s foreach.

Many of the concepts that LINQ has introduced were originally tested in Microsoft's Cω research project. LINQ was released as a part of .NET Framework 3.5 on November 19, 2007.

LINQ to Objects :

The LINQ to Objects provider is used for querying in-memory collections, using the local query execution engine of LINQ. The code generated by this provider refer the implementations of the standard query operators as defined in the Sequence class and allows IEnumerable<T> collections to be queried locally. Current implementation of LINQ to Objects uses e.g. O(n) linear search for simple lookups, and is not optimised for complex queries[4].

LINQ to XML :

The LINQ to XML provider converts an XML document to a collection of XElement objects, which are then queried against using the local execution engine that is provided as a part of the implementation of the standard query operator.[5]

LINQ to SQL :

The LINQ to SQL provider allows LINQ to be used to query SQL Server databases as well as SQL Server Compact databases. Since SQL Server data resides on a remote server, and because it already includes a querying engine, LINQ to SQL does not use the query engine of LINQ. Instead, it converts a LINQ query to SQL query which is then sent to SQL Server for processing.[6] However, since SQL Server stores the data as relational data and LINQ works with data encapsulated in objects, the two representations must be mapped to one another. For this reason, LINQ to SQL also defines the mapping framework. The mapping is done by defining classes which corresponds to the tables in database, and containing all or a subset of the columns in the table as data members.[7] The correspondence, along with other relational model attributes such as primary keys are specified using LINQ to SQL-defined attributes.

LINQ to DataSets :

The LINQ to SQL provider works only with Microsoft SQL Server databases; to support any generic database, LINQ also includes the LINQ to DataSets, which uses ADO.NET to handle the communication with the database. Once the data is in ADO.NET Datasets, LINQ to Datasets execute queries against these datasets.[8]

Other Providers :

The LINQ providers can be implemented by third parties for various data sources as well. Several database server specific providers are available from the database vendors. Some of the popular providers include:

· Data Services: LINQ to ADO.NET Data Services[9]
· Entity Framework: LINQ to Entities[10]
· DbLinq: LINQ to MySQL, PostgreSQL, Oracle, Ingres, SQLite and Microsoft SQL Server[11]
· Google search: LINQ to Google[12]
· Windows Search: LINQ to System Search[13]
· NHibernate: LINQ to NHibernate[14]
· OpenMapi: LINQ to MAPI[15]
· LLBLGen: LINQ to LLBLGen[16]

Summary from "msdn" details :

Stands for "Language-Integrated Query".

http://msdn.microsoft.com/en-us/library/bb425822.aspx

LINQ to SQL provides a runtime infrastructure for managing relational data as objects without losing the ability to query.

Your application is free to manipulate the objects while LINQ to SQL stays in the background tracking your changes automatically.

Applies to:

Visual Studio Code Name "Orcas"

.Net Framework 3.5

Introduction :

Most programs written today manipulate data in one way or another and often this data is stored in a relational database. Yet there is a huge divide between modern programming languages and databases in how they represent and manipulate information. This impedance mismatch is visible in multiple ways. Most notable is that programming languages access information in databases through APIs that require queries to be specified as text strings. These queries are significant portions of the program logic. Yet they are opaque to the language, unable to benefit from compile-time verification and design-time features like IntelliSense.

Of course, the differences go far deeper than that. How information is represented—the data model—is quite different between the two. Modern programming languages define information in the form of objects. Relational databases use rows. Objects have unique identity as each instance is physically different from another. Rows are identified by primary key values. Objects have references that identify and link instances together. Rows are left intentionally distinct requiring related rows to be tied together loosely using foreign keys. Objects stand alone, existing as long as they are still referenced by another object. Rows exist as elements of tables, vanishing as soon as they are removed.

It is no wonder that applications expected to bridge this gap are difficult to build and maintain. It would certainly simplify the equation to get rid of one side or the other. Yet relational databases provide critical infrastructure for long-term storage and query processing, and modern programming languages are indispensable for agile development and rich computation.

Until now, it has been the job of the application developer to resolve this mismatch in each application separately. The best solutions so far have been elaborate database abstraction layers that ferry the information between the applications domain-specific object models and the tabular representation of the database, reshaping and reformatting the data each way. Yet by obscuring the true data source, these solutions end up throwing away the most compelling feature of relational databases; the ability for the data to be queried.

LINQ to SQL, a component of Visual Studio Code Name "Orcas", provides a run-time infrastructure for managing relational data as objects without losing the ability to query. It does this by translating language-integrated queries into SQL for execution by the database, and then translating the tabular results back into objects you define. Your application is then free to manipulate the objects while LINQ to SQL stays in the background tracking your changes automatically.

LINQ to SQL is designed to be non-intrusive to your application :

It is possible to migrate current ADO.NET solutions to LINQ to SQL in a piecemeal fashion (sharing the same connections and transactions) since LINQ to SQL is simply another component in the ADO.NET family. LINQ to SQL also has extensive support for stored procedures, allowing reuse of the existing enterprise assets.

LINQ to SQL applications are easy to get started :

Objects linked to relational data can be defined just like normal objects, only decorated with attributes to identify how properties correspond to columns. Of course, it is not even necessary to do this by hand. A design-time tool is provided to automate translating pre-existing relational database schemas into object definitions for you.

Together, the LINQ to SQL run-time infrastructure and design-time tools significantly reduce the workload for the database application developer. The following chapters provide an overview of how LINQ to SQL can be used to perform common database-related tasks. It is assumed that the reader is familiar with Language-Integrated Query and the standard query operators.

LINQ to SQL is language-agnostic. Any language built to provide Language-Integrated Query can use it to enable access to information stored in relational databases. The samples in this document are shown in both C# and Visual Basic; LINQ to SQL can be used with the LINQ-enabled version of the Visual Basic compiler as well.

The first step in building a LINQ to SQL application is declaring the object classes you will use to represent your application data.

LINQ Query Syntax versus Method Syntax (C#) :

Most queries in the introductory LINQ documentation are written as query expressions by using the declarative query syntax introduced in C# 3.0. However, the .NET common language runtime (CLR) has no notion of query syntax in itself. Therefore, at compile time, query expressions are translated to something that the CLR does understand: method calls. These methods are called the standard query operators, and they have names such as Where, Select, GroupBy, Join, Max, Average, and so on. You can call them directly by using method syntax instead of query syntax.

In general, we recommend query syntax because it is usually simpler and more readable; however there is no semantic difference between method syntax and query syntax. In addition, some queries, such as those that retrieve the number of elements that match a specified condition, or that retrieve the element that has the maximum value in a source sequence, can only be expressed as method calls. The reference documentation for the standard query operators in the System.Linq namespace generally uses method syntax. Therefore, even when getting started writing LINQ queries, it is useful to be familiar with how to use method syntax in queries and in query expressions themselves.


How do We Use LINQ ?


Chapter 11 - Expression Studio - Details

Enter topic text here.


Video training materials

http://expression.microsoft.com/en-us/cc136535.aspx#ExpressionEncoderTrainingVideos

===============================================================================================================================================

==============================================================================================================================================

Expression Blend 2 - Sixty Five (65) in all !

===============================================================================================================================================

Expression Web 2 : Twenty nine (29) in all !

============================================================================================


Appendix A -

COMPUTER TYPES

12% of computer users still use The Macintosh. Just to make the situation worse, the PC and the Mac usually display web pages differently using the same browser.
The reasons for this are
· Internet explorer. Microsoft outsources the development of Internet Explorer for the Mac, which results in it being a different browser from the PC version. The Mac version of Internet Explorer is prone to quirks and bugs that you won’t see in the PC version.
· Font Size. The Mac and PC render typeface differently. Using Cascading Style Sheets to set font sizes in pixels solves the problem.
· Font availability. Not all computers have the same fonts as your computer. This is even more so in the case of the PC and the Mac computers.

When do they go wrong ?

Too Old :

Too New :

Going Further :

As web sites evolved into dynamic web applications composing content from various web sites, browsers have become multi-principal operating environments with resources shared among mutually distrusting web site principals. Nevertheless, no existing browsers, including new architectures like IE 8, Google Chrome, and OP, have a multi-principal operating system construction that gives a browser-based OS the exclusive control to manage the protection of all system resources among web site principals. In this paper, we introduce Gazelle, a secure web browser constructed as a multi-principal OS. Gazelle’s Browser Kernel is an operating system that exclusively manages resource protection and sharing across web site principals.

Source:→ Slashdot

==============================================================================================================================================================

=====================================================================================================================================================================

Problems - when and why !? :

==============================================================================================================================================


Which One to use ?


Cross Browsers

Cross-browser : [ From Wikipedia, the free encyclopedia ]

Cross-browser refers to the ability for a website, web application, HTML construct or client-side script to support all the web browsers. The term cross-browser is often confused with multi-browser. Multi-browser means something works with several web browsers. Cross-browser means something works with all versions of all browsers to have existed since the web began.

The term was widely used during the browser wars in late-1990s. In that context, the term referred to websites and code snippets that worked in both Internet Explorer and Netscape Navigator. During the browser wars, new features were added to browsers without any coordination between vendors. Thus it often happened that though both browsers supported some particular feature, there were differences in the way the feature worked, ranging from slight cosmetic issues to profound conceptual differences.

The term is still in use, but to lesser extent. The main reasons for this are:

- Later versions of both Internet Explorer and Netscape included support for HTML 4.0 and CSS1, proprietary extensions were no longer required to accomplish many commonly desired designs.

- Somewhat more compatible DOM manipulation techniques became the preferred method for writing client-side scripts.

- The browser market has broadened, and to claim cross-browser compatibility, the website is nowadays expected to support browsers such as Mozilla Firefox, Opera, and Safari in addition to Internet Explorer and Netscape.

- There has been an attitude shift towards more compatibility in general. Thus, some degree of cross-browser support is expected and only its absence needs to be noted.

Accessible Web Design & Consulting : by Joe Dolson :

What is “Cross-browser compatibility?”

{ Here’s the first clue: it’s not creating a pixel-perfect replication of your ideal version of a site in all browsers.

In fact, cross-browser compatibility ultimately has very little to do with what a web site looks like, and a lot more to do with how it functions.

It also has relatively little to do with browsers, and perhaps could better be explained as multiple user-agent compatibility.

“Compatibility” (in this context) is not a term which means “looks and behaves identically” — - instead, it may be better described as “performs equivalently under alternative conditions.”

But developers and designers tend to most immediately seize upon appearance as the guiding line for cross-browser compatibility.

...................................................

But the absolute key to cross-browser compatibility is simply functionality. A lack of cross-browser compatibility doesn’t mean that something looks different; it means that it doesn’t work.

....................................................

There’s nothing at all that you can do to actually guarantee the same view for everybody; instead, you need to guarantee an equivalent view for everybody.

Equivalent in that they will be able to get the same information and use the functions of the site to perform the same actions. }

How to Use Multiple Browsers on a Single Machine

To Check Your Site for Cross-Browser Compatibility

by Christopher Heng, thesitewizard.com

We all know the importance of checking our web pages with multiple browsers, especially when we are designing a new layout for a website. This is the case even if we are writing validated standards-compliant code. The number of extant browsers we need to check with are enormous: Internet Explorer (IE) 7, 6, 5.5 and 5.0, Firefox 2.0 and 1.5, Opera 9 and 8, and so on. And then there are the different platforms: Windows, Macintosh (Mac), Linux, etc. The problem for most people is that multiple versions of certain browsers cannot co-exist with each other, the most notable example of this is IE for Windows. Unless you are privileged to have multiple computers, this presents a certain difficulty for the average webmaster. This article suggests some ways for you to run multiple versions of multiple browsers on one computer.

Note that this article is written primarily from the point of view of a person using Windows (the majority of people reading this article), although it does address the issue of Mac browsers and Linux browsers as well.

Firefox, the Mozilla Suite, Seamonkey and Netscape

It's possible for different versions of Firefox, Seamonkey, Netscape and the old Mozilla browser to all co-exist on the same machine.

If you did not already know, Mozilla Firefox, Seamonkey, Netscape 6 to 9 and the (old) Mozilla Suite browser use the same Gecko rendering engine. As such, if you have Netscape 6.X, you are in effect using the rendering engine of a beta version of Mozilla (one of the 0.9.X series); if you use Netscape 7, you are using the Mozilla 1.0.X engine; and if you use Netscape 7.1 you're using the same engine as Mozilla 1.4. The point is that you don't have to install, say, Mozilla 1.0.X if you're using Netscape 7, and so on.

It is easy to make these versions of Netscape/Mozilla/Firefox co-exist with each other. Install them into separate directories and create a different profile for each browser you install. (For non-Netscape/Mozilla users, this browser allows you to create different profiles so that you can store different settings for different situations.)

.............................

.............................


Appendix B -

To get us think along the right lines as far as Web Services are concerned, read this snippet :-

=================================================================================================

=================================================================================================

And if that wasn't enough in itself then there is this too :-

=================================================================================================

=================================================================================================


Appendix C - Printing Documents


Appendix D - Expression Blend 2

 Top Previous

Enter topic text here.