public decimal AddTotal(Order orders, int zip)
{
decimal total = 0;
foreach (Item item in order[Zip == zip].item)
{
total += item.price * item.quantity;
}
return total;
}
What in the heck is "Order"? what is this new syntax on the right side of the foreach loop? it's a little hard to explain without first giving a short history lesson on XSD types, and the importance of them (obviously) in the integration of Xen with C# (which is elegantly described as Xen = C# + XSD + XML + XQuery + SQL). here are the basic types in XSD that Xen will attempt to roll up:
sequence choice all * + ? T , U T | U T & U attribute attributeGroup required typedef mixed xml:space T requires exprand a short example using some of these types based on an SVG scenario:
<xs:complexType name="container">
<xs:complexContent mixed="false">
<xs:extension base="t:shape">
<xs:sequence>
<xs:element name="desc" type="xs:string" />
<xs:element name="title" type="xs:string" />
<xs:choice maxOccurs="unbounded">
<xs:element name="rect" type="t:rect" />
<xs:element name="line" type="t:line" />
<xs:element name="g" type="t:group" />
<xs:element name="ellipse" type="t:ellipse" />
<xs:element name="polygon" type="t:polygon"/>
<xs:element name="styles" type="t:styles"/>
</xs:choice>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
So the question is how to take this declarative model and model it in Xen? here it is:
public class rect : shape
{
attribute int x;
attribute int y;
attribute int width;
attribute int height;
}
class container : shape
{
sequence {
string title;
string desc;
choice {
rect;
line;
group g;
ellipse;
polygon;
styles
}*
}
}
As you can see, the XSD constructs of "sequence" and "choice" are made first class citizens of Xen, as well as the notion of zero or more as indicated by the asterisk for the "choice" block, and attributes are strongly typed and mapped to CLR prmitives. this is quite obviously quite an improvement over the XSD way of handling things. so that covers the XSD part of the equation, now on to the XML portion and what is slated to be included. There are 5 fundamental XML Literals that are mentioned, along with their importance to the XML language, they are:
namespace "URI" { }
using prefix = "URI";
Foo f = ;
Code snippets: ;
XSD validation by the compiler
One ramification of this is that the Xen compiler will be doing the XSD validation at compile time. of course you can validate in the current version of .Net, but a realistic situation is that you will be building an XSD document at runtime to be sent to perhaps another application to be consumed, what happens if it's not valid? Trying to track down the source of the error is also time consuming and arduous. the benifits of moving this sort of validation into the compiler should be quite obvious. here is an example of some code that uses current XML technologies in .Net to build an HTML table:
protected override table GetResult() {
table result = new Table();
tr row = new row();
result.Items.Add(row);
th cell = new th();
cell.InnerText = "ID";
row.Items.Add(cell);
cell = new th();
cell.InnerText = "Name";
row.Items.Add(cell);
…
foreach (tr row in GetCustomersByCountry(this.country)){
table.Items.Add(row);
}
return result;
}
- "Intro to Xen, Page 1/3"
- "Intro to Xen, Page 2/3"
- "Intro to Xen, Page 3/3"



