Thursday, February 26, 2004
WSD -> C# ... broke out the facet validation
Per Dimitri Glazkov's suggestion, I've split out the simpleType facet validation into separate AssertXXX and IsValidXXX methods so there is no unnecessary duplication anymore.
The latest output also shows the generation of nested classes, which happens when you have a nested complexType (versue one defined at the root level).
Here are the input schema and generated output files:
I still need to put in support for a lot more of the value types (mapping xsd types to CLR types), as well as the minOccurs/maxOccurs support.
Keeps me out of trouble, in any case.
The latest output also shows the generation of nested classes, which happens when you have a nested complexType (versue one defined at the root level).
Here are the input schema and generated output files:
I still need to put in support for a lot more of the value types (mapping xsd types to CLR types), as well as the minOccurs/maxOccurs support.
Keeps me out of trouble, in any case.
# posted 2/26/2004 10:59:57 PM |
It never ceases to amaze me how far of the mark the .NET team fell with their globalization.
I've been banging my head against the lack of proper support in the TimeZone class the past few days. Turns out its basically a super thin veneer onto the Win32 APIs for timezone handling. But with almost no extra effort, it could have been made "useful".
Case in point: the Win32 registry contains a list of timezones - the same list used in the Regional Settings applet in Control Panel. But there is no way to pull that into .NET and use it with the TimeZone class. Want to know the time in Australia via .NET? Better go to Control Panel and set your machine to be in Australia first. Good grief.
In an ideal world (wasn't that what they were trying to build?) you would want to be able to get a timezone via the CultureInfo. Countries have more than one? OK - return an array - I can handle it. Instead I'm left building code on top of the registry data and doing the conversion functions myself
The annoying thing is that I'm having to do all this work, but my only requirement is to be able to display a time for a component that will probably only work in the US and therefore always say "CST". But having written an app that works just fine in 85 countries, I just hate writing code that hard-codes things like that.
Ah well. Its done now.
Another team had to do a whole bunch of locale version handling code today to handle all the locales that .NET doesn't support, such as Tanzania so we could handle orders from those countries.
Perhaps we need to petition Microsoft to rename it to
OK. Rant over. Stepping away from the keyboard.
I've been banging my head against the lack of proper support in the TimeZone class the past few days. Turns out its basically a super thin veneer onto the Win32 APIs for timezone handling. But with almost no extra effort, it could have been made "useful".
Case in point: the Win32 registry contains a list of timezones - the same list used in the Regional Settings applet in Control Panel. But there is no way to pull that into .NET and use it with the TimeZone class. Want to know the time in Australia via .NET? Better go to Control Panel and set your machine to be in Australia first. Good grief.
In an ideal world (wasn't that what they were trying to build?) you would want to be able to get a timezone via the CultureInfo. Countries have more than one? OK - return an array - I can handle it. Instead I'm left building code on top of the registry data and doing the conversion functions myself

The annoying thing is that I'm having to do all this work, but my only requirement is to be able to display a time for a component that will probably only work in the US and therefore always say "CST". But having written an app that works just fine in 85 countries, I just hate writing code that hard-codes things like that.
Ah well. Its done now.
Another team had to do a whole bunch of locale version handling code today to handle all the locales that .NET doesn't support, such as Tanzania so we could handle orders from those countries.
Perhaps we need to petition Microsoft to rename it to
System.Partialization 
OK. Rant over. Stepping away from the keyboard.
# posted 2/26/2004 07:41:06 PM |
Sunday, February 22, 2004
XSD -> C#... basically working!
I still have work to do try it out with anonymous types. I know that a
Of course, my definition of right, and the rest of the XML community's definition stand to be radically different.
I'm attaching my hokey sample schema, and the C# that was generated from it:
It would probably also be a good idea to finish reading through the excellent book Definitive XML Schema before I can really say this is a done deal.
simpleType does the right thing... Need to try an anonymous complexType too. What it needs to do in that case is generated a nested class. I'll probably have to refactor it somewhat to make it do that. Then its a case of throwing lots of stuff at it and making sure it does the "right thing".Of course, my definition of right, and the rest of the XML community's definition stand to be radically different.
I'm attaching my hokey sample schema, and the C# that was generated from it:
It would probably also be a good idea to finish reading through the excellent book Definitive XML Schema before I can really say this is a done deal.
# posted 2/22/2004 10:04:31 PM |
Yesterday I picked up my HDTV DVR (digital video recorder), a Scientific Atlanta 8000HD from Time Warner Cable. It adds $6.95 to my cable bill, but could save me a lot in DVDs over time... assuming I can be bothered to hunt around for stuff I'm interested in.
Of course, the first day it was put to work recording a bunch of Hi-Def TV-MA shows I can never bothered to stay up to watch. After getting through one of them though, I remember why I don't bother staying up, and erased them again
The XSD -> CLR code generator is going pretty well. I've got
I'm just about to start on handling
Of course, the first day it was put to work recording a bunch of Hi-Def TV-MA shows I can never bothered to stay up to watch. After getting through one of them though, I remember why I don't bother staying up, and erased them again

The XSD -> CLR code generator is going pretty well. I've got
xsd:choice working fairly transparantly. You still have to check an enum value to know which of the value properties to request, but at least you never need to set it. That gets done for you if you assign one of the values. It also throws an exception if you request the wrong one, though I may build a flag into the compiler to make that optional.I'm just about to start on handling
simpleType blocks, and then onto facets such as minInclusive (dynamically building the validation code into the property setter).# posted 2/22/2004 08:31:48 PM |
Friday, February 20, 2004
XSD and CodeDOM... What was I thinking?
The last day or so I've been getting back into the CodeDOM. Its been a while... The last big thing I did was write a system that took XML targeting expressions out of a Commerce Server 2000 database and convert them to C#... which in the process made them run 200x faster (or so).
My new "project" is to build a system that can read in an XSD schema, and generate a full-on class from it. There is XSD.EXE of course. And .NET provides the
One of the first shortcomings you come across is that it doesn't understand facets such as
Ideally what you would want would be to get a block of code out of this such as:
The problem is that is only the tip of the iceberg. There are other narly issues such as decent handling of
The generated code also handles
Perhaps what I should do is take the code that comes out, and then do my own pass over the that might be say
Its fun to work on stuff sometimes which doesn't involve questions like "why did this come out 5 pixels too far left in Netscape 4.7?"
My new "project" is to build a system that can read in an XSD schema, and generate a full-on class from it. There is XSD.EXE of course. And .NET provides the
XmlCodeExporter class (see a short tutorial). This gets you some of the way, but falls a long way short.One of the first shortcomings you come across is that it doesn't understand facets such as
minInclusive that you might use to define a type such as "employee:age" that is based on a restriction of xsd:integer to only be between 16 and 70.<xsd:simpleType name="age">
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="16" />
<xsd:maxInclusive value="70" />
</xsd:restriction>
</xsd:simpleType>Ideally what you would want would be to get a block of code out of this such as:
private int m_age; // an instance of employee:age
public int age
{
get { return m_age; }
set
{
if( m < 16 || m > 70 )
{
throw new ArgumentOutOfRangeException( "age" );
}
m_age = value;
}
}The problem is that is only the tip of the iceberg. There are other narly issues such as decent handling of
xsd:choice, that XmlCodeExporter handles by managing an enum. This is annoying to a consuming developer, as its requires them to think of the object in an XSD way, and requires two or more calls to change which choice you are using.The generated code also handles
minOccurs and maxOccurs quite badly. It will make an array, but its not doing any range checking.Perhaps what I should do is take the code that comes out, and then do my own pass over the
XmlSchema (the XML Schema "DOM"), and generate a Validate() method that does all of the required validatations (probably having a switch to control whether you want it to descend into and validate the instances of other complex types you are referring to). That approach can work well, particularly as there are times when your object may be temporarily invalid. A case in point is where you have an foodType and your choices are objects of type sushi, steak or tofu. If you assigned one of the other types, but hadn't assigned the enum value, the object would be invalid. Setting the enum then makes it valid again.Its fun to work on stuff sometimes which doesn't involve questions like "why did this come out 5 pixels too far left in Netscape 4.7?"
# posted 2/20/2004 09:53:01 PM |
Thursday, February 19, 2004
I haven't seen a whole lot of folks using GDI+ on commercial sites, but I'm not sure why. Maybe its a little esoteric... Yet, I know folks that do .NET Remoting, which seems much harder to me.
Maybe folks don't think its ready for prime time... Which is odd, as its actually really powerful once you get how it works.
If you've ever bother to look, several features on Dell.com have urls that are calling something called img.aspx, which is a GDI+ based image generation service that I wrote to build a lot of the whizzy images dynamically. Why? Partly because I could, but in truth it is a nightmare for our content authoring community to manage banners and button images in 40 languages (go figure!).
Here's an example:

Yesterday I put the finishing touches on a new feature in img.aspx that lets me generate "secret text" that we can use to verify that a human operator is using the page. Yahoo and Hotmail do much the same thing. It was great fun figuring out how to swirl the text (its a sine/cosine thing) and add "noise" that makes it hard for an automated bot to pick it apart whilst still keeping it readable. Lovely.

Maybe folks don't think its ready for prime time... Which is odd, as its actually really powerful once you get how it works.
If you've ever bother to look, several features on Dell.com have urls that are calling something called img.aspx, which is a GDI+ based image generation service that I wrote to build a lot of the whizzy images dynamically. Why? Partly because I could, but in truth it is a nightmare for our content authoring community to manage banners and button images in 40 languages (go figure!).
Here's an example:

Yesterday I put the finishing touches on a new feature in img.aspx that lets me generate "secret text" that we can use to verify that a human operator is using the page. Yahoo and Hotmail do much the same thing. It was great fun figuring out how to swirl the text (its a sine/cosine thing) and add "noise" that makes it hard for an automated bot to pick it apart whilst still keeping it readable. Lovely.

# posted 2/19/2004 09:31:29 AM |
Wednesday, February 18, 2004
Lordy, the weather has been great the past few days. A week ago it snowed, and we got to build a snowman in the yard. Now its up around 70F. Thats Texas for you.
Been thinking about iComic futures. I'm still considering a port to Windows – probably won't use Perl for plugins though. Probably be JavaScript, as that would let me expose app functionality to the script so I could control how the app connected to the Internet. iComic plugins in 3.x rely on a Perl script calling down to
I'd also love to make an iComic Palm Conduit to allow comics to be hotsynced to my Palm so I could carry them around... Maybe I'll get to do at least one of these things when the kiddies are away in Japan. Ah, to dream.
If, like me, you're currently constrained by the lousy 4GB you can fit into your server, you might be interested in Intel's 64-bit Extension technology which they finally announced yesterday. In a nutshell it lets you run lot and lots of 32-bit apps on a machine that has 64-bit memory addressing. Apple uses the same trick with their G5 processor to allow up to 16GB of memory on the box, even though MacOS X is still only 32-bit.
At the end of the day, very few of today's apps don't need to be 64-bit, but having access to a full 4GB of memory in each app would be great. Today apps only get a max of 2GB in Windows (or 3GB if you use the /3gb switch in boot.ini) and the OS get the remainder up to 4GB. With the 64-bit extensions, the OS gets the heck out of dodge and each app gets a full 4GB.
If nothing else, it should do wonders for the cost of 512MB SDRAM when everyone goes out and fills their systems with it!
Been thinking about iComic futures. I'm still considering a port to Windows – probably won't use Perl for plugins though. Probably be JavaScript, as that would let me expose app functionality to the script so I could control how the app connected to the Internet. iComic plugins in 3.x rely on a Perl script calling down to
curl. If you can do that, you could do far worse things too hideous to mention here.I'd also love to make an iComic Palm Conduit to allow comics to be hotsynced to my Palm so I could carry them around... Maybe I'll get to do at least one of these things when the kiddies are away in Japan. Ah, to dream.
If, like me, you're currently constrained by the lousy 4GB you can fit into your server, you might be interested in Intel's 64-bit Extension technology which they finally announced yesterday. In a nutshell it lets you run lot and lots of 32-bit apps on a machine that has 64-bit memory addressing. Apple uses the same trick with their G5 processor to allow up to 16GB of memory on the box, even though MacOS X is still only 32-bit.
At the end of the day, very few of today's apps don't need to be 64-bit, but having access to a full 4GB of memory in each app would be great. Today apps only get a max of 2GB in Windows (or 3GB if you use the /3gb switch in boot.ini) and the OS get the remainder up to 4GB. With the 64-bit extensions, the OS gets the heck out of dodge and each app gets a full 4GB.
If nothing else, it should do wonders for the cost of 512MB SDRAM when everyone goes out and fills their systems with it!
# posted 2/18/2004 09:08:16 PM |
Monday, February 16, 2004
Finished off Storm 3.1 today. In English that means Dell.com will get some new toys in a few weeks time once QA have finished with it. I apologize in advance for the inline flyout windows — but I did try to make them as cool as possible 
I also threw caution to the wind, and went down to Precision Camera here in Austin, and put a deposit down on the Nikon D70. I know, I'm bad... but some things just have to be done. The annoying thing is, I'd been checking Adorama's site almost every day to see if they were listing it yet... Nothing. In the end I decided I better just get on a list somewhere. And of course, when I got back to the office and checked Adorama, there it is.
Bollocks.

I also threw caution to the wind, and went down to Precision Camera here in Austin, and put a deposit down on the Nikon D70. I know, I'm bad... but some things just have to be done. The annoying thing is, I'd been checking Adorama's site almost every day to see if they were listing it yet... Nothing. In the end I decided I better just get on a list somewhere. And of course, when I got back to the office and checked Adorama, there it is.
Bollocks.
# posted 2/16/2004 09:13:54 PM |
Friday, February 06, 2004
Just got back from another trip to Microsoft, this time learning more about Yukon (SQL Server 2004) and Microsoft .NET 2.0 (codenamed "Whidbey").
Yukon turned out to be pretty kick ass. We were able to cobble together some utilities that shredded the Dell.com XML content files across a set of relational tables, with some pure XML content going into the new XML datatype that Yukon supports (yes, I know Oracle has had that for years!)
We also had XQuery expressions going against that to do stuff like "find all documents that have a keyword of 'OptiPlex'". Fast too.
MSDN dedicated a whole issue to Yukon, which will give you a pretty good idea of what it can do.
Yukon turned out to be pretty kick ass. We were able to cobble together some utilities that shredded the Dell.com XML content files across a set of relational tables, with some pure XML content going into the new XML datatype that Yukon supports (yes, I know Oracle has had that for years!)
We also had XQuery expressions going against that to do stuff like "find all documents that have a keyword of 'OptiPlex'". Fast too.
MSDN dedicated a whole issue to Yukon, which will give you a pretty good idea of what it can do.
# posted 2/06/2004 09:02:24 PM |



