Preface In Chapter 13 of Watson's Data Management the author introduces XML (eXtensible Markup Language) and presents an extended example for a CD library involving XML data, an XML schema (XSD) and XML stylesheet (XSL or XSLT). This note demonstrates developing and adjusting this example using Microsoft Visual Studio (VS).

Caveats

Visual Studio is one of many, many tools for working with XML projects; it would be a mistaken 'take away' from this presentation to conclude that VS was required to work with XML or that XML is something proprietary to Microsoft.

If this is your first exposure to Visual Studio realize that VS is an extensive, multi-purpose tool for a wide-variety of system development. We'll use only a tiny part of it but the conventions and menus may seem overwhelming at first. The step-by-step guidance and accompanying video should help mitigate these issues.

Another mistaken conclusion would be that end users of the XML project would open Visual Studio to work with the CD list and view the results. 'In real life' the project would be deployed so users could use the web or an app for access to the library. VS is a tool for doing XML project development which also gives us a handy tool for getting a sense of how XML is formatted and tooled.

Lastly (IMHO): Maintaining a personal CD library with XML (or other formal structure) isn't a likely project and lacks the oomph that might be derived from a more realistic, enterprise project which could better demonstrate 'Why would anyone bother?'. But it makes a convenient example, small enough to see the pieces so 'pretend' there is a client who is interested and, more importantly, envision how this structure might be scaled for more interesting uses.

Resources

The following files have been copied from Watson's textbook for easier download:

WatsonCDLibXML.txt (XML data)

WatsonCDLibXSD.txt (XML schema)

WatsonCDLibXSL.txt (XML stylesheet)

The video XML Intro and Demo briefly introduces XML and provides some 'look and feel' for the steps below.

Developing the Project

Start Visual Studio and select Create a new project. If this dialog does not appear or you are already in Visual Studio use File | New | Project from the menu which will take you to the next screen (Create a new project).

Type blank in the search area, select Blank Solution and click Next.

Change the solution name to CDLibrary and, using the ellipsis ..., change the location to your Documents folder. Then click Create.

Screen Cap

We need to get the sample XML, XSD and XSL files as part of the project and here is one approach. Right-click the Solution in Solution Explorer, then select Add, then New Item. If you don't see the Solution Explorer then use View | Solution Explorer to find it.

 

Select XML File from the list, change the name to CDLib.xml and click Add. You will see an empty XML file with only an xml declaration at the top.

Leaving Visual Studio open, open the link WatsonCDLibXML.txt in a web browser. Click into the web page, use Ctrl+A to highlight it all and then Ctrl+C to copy this text to your clipboard. Then get back to CDLib.xml in Visual Studio, click in the page, and use Ctrl+A then Ctrl+V to paste this text over what was there originally. You might click the Save icon to save these results.

Perform a similar process to add a new XSLT file to your project named CDLib.xslt by copying, pasting and saving the results from visiting WatsonCDLibXSL.txt in a web browser. Finally, add a new XML Schema item to your project, naming it CDLib.xsd. As a default, an XML schema comes up in a designer view so before copying, pasting and saving the results from visiting WatsonCDLibXSD.txt in a web browser you will need click 'Use the XML Editor to view and edit the underlying XML schema file' on the designer view.

Click into the CDLib.xml file and look at the properties window (use View | Properties Window if it is not there). Validate / update the Schemas and Stylesheet properties so they point to, respectively, CDLib.xsd and CDLib.xslt as shown below. Be sure to save all files afterward.

The accompanying video XML Intro and Watson's CD Library Example demonstrates a bit more how the XML and its schema and stylesheet interact to control and present the data, and also shows some simple updates to expand the system. As a final check of your development, though, click into the XML file then use XML | Start XSLT Without Debugging from the menu. A new window will be created which renders the XML data according to the presentation defined by the stylesheet.