Xen Samples

The following samples are written entirely in the Xen Programming Language and demonstrate the various aspects of the Xen Type System and what is possible with the XML and SQL integration in Xen.

Setup Information

Some of these samples connect to the Northwind database released with SQL 2000. These samples store the database connection string in the application configuration file named *.exe.config.  Before running these samples you may need to modify those settings to point to a SQL server database that you have access to.

Xen PetShop and NorthwindASP samples require IIS and ASP.Net installed on your machine. If you had IIS installed on your machine at the time you installed Xen, installer has already configured it for you and you are all set to proceed to samples.

In case you did not have IIS installed, in order to run Xen PetShop or NorthWind ASP samples, please perform the following steps:

Pet Shop .Net Sample

This sample is based on .Net Pet Shop Case Study (1.3). The data access part of the sample is rewritten using Xen SQL features: select, insert, update, and delete expressions and transaction blocks. See for details source file XenPetShop\Components\SqlStoredProc.xs

Here are some of the highlights from the comparison between the original sample and its Xen version:

Before running Xen PetShop Sample you will need to install the PetShop DataBase. Make sure you have SQL 2000 server and a user name/password that has sufficient permissions to create a database. Perform the following steps:

To run the sample, compile XenPetshop\XenPetshop.xsproj and launch the default.aspx page.

Northwind - ASP.NET Scenario

This is an ASP.NET application that connects to SQL Server Northwind database via an tool-generated "interop" assembly named Northwind.dll and produces an HTML table showing lists of customers and orders.  This is done via a custom System.Web.Control implemented in Xen that does the SQL select and yields XML literals that build the HTML tables using a simple set of HTML objects that are modeled in Xen. The HTML is generated as XML, so it is really XHTML. This XML output could be any user defined XML and is not limited to HTML. Check out main.xs where you will see very tight integration between the SQL queries on one side and the XHTML generation on the other, especially in the OrderDetails class.

To run this sample, load NorthwindASP.xsproj in Visual Studio, check the Web.Config file to make sure the Northwind database connection string is correct, build the project and launch the web page CustomersByCountry.aspx.

XQuery Use Cases - XQuery and Xen Object Queries side-by-side...

This sample is based on the W3C XQuery Use Cases .  It demostrates the power of the Xen type system and object queries capabilities, and demonstrates the impact of adding strong typing to an XML query language.   To run this sample, load the xquery.xsproj project in Visual Studio and hit F5. This sample includes a readme that discusses the differences between XQuery and Xen in these various use cases.

SqlXml - WinForms SQL Scenario

This is a WinForms demo that loads customer information out of the Northwind database and presents it in a grid.  It also caches the customer information locally in a cache.xml file using the XmlSerializer.  This demo shows a consistent programming model over XML and SQL data.   It also shows how objects can be constructed directly in the SQL select projection list using XML literal expressions. To run this sample, check the sqlxml.exe.config file to make sure the Northwind database connection string is correct, then load the sqlxml.xsproj project in Visual Studio and hit F5.

XSVG - WinForms XML Scenario

This is a WinForms demo showing Xen XML literal expressions for manipulating SVG graphic elements. SVG is the W3C XML standard for Scalable Vector Graphics. Included with this sample is a separate svg.dll which renders SVG graphics and the interface between this dll and the Xen sample is a serialized stream of XML data. So this sample also shows how to use the Xen XmlSerializer which has extended serialization capabilities based on the Xen type system extensions.   To run this sample, load the demo.xsproj project in Visual Studio and hit F5.

Ledger - XSLT Scenario

This demo shows the Xen equivalent of the Ledger.xsl style sheet. The demo loads XML data via XmlSerialization and transforms it to XHTML objects using a nested series of transforming "iterators" then it displays the result in a Web Browser control. This shows than Xen can do some XSLT scenarios just as elegantly as XSLT, but because Xen is based on a general purpose programming language the Xen approach is also more powerful. For example, the XSL style sheet requires the use of <msxsl:script> blocks for some things. In Xen this code is inlined, which makes it more managable and a lot more debuggable. To run this sample, load the Ledger.xsproj project in Visual Studio and hit F5.

WARNING: You may get an error during compilation about missing Microsoft.mshtml.dll. In this case close VS, open ledger.xsproj in the notepad and change the HintPath attribute value on the element for the Microsoft.mshtml assembly to point to \Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll

Hamlet - From DTD to XSD to Xen...

The Shakespeare XML samples by Jon Bosak are an XML industry classic. In this sample we took the Play.dtd, converted it to XSD, then imported the XSD into a Xen project.  This shows how to use the XmlSerializer to round trip the Hamlet.xml document which demonstrates good fidelity between XML content models and the Xen type system.





[ Back to Welcome Page ]