Archive for July 2008

10000 dagen

Vandaag ben ik 10000 dagen oud geworden. Het is weer eens een andere manier om naar je leeftijd te kijken. Op naar de 20000 dagen (wat op 14 december 2035 zal plaatsvinden).

LINQ to XSD versus XSD.exe (part 1)

While LINQ to XSD is still in alpha, it is always a good idea to look at the (new) possibilities of this new technology. Before LINQ to XSD I used the XSD.exe to generate source files based on a XML schema. By generating this code you can work with XML files on a typed safe manner.

I will try to compare the differents between LINQ to XSD and the XSD tool. I will look at the (generated) code needed to work with XML files and try to compare the performances of both techniques. Based on the Linq to XSD overview document I will use the following XML schema:

<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.example.com/Orders"
  xmlns="http://www.example.com/Orders"
  elementFormDefault="qualified">
   <xs:element name="Batch">
      <xs:complexType>
         <xs:sequence>
           <xs:element ref="PurchaseOrder" minOccurs="0" maxOccurs="unbounded"/>
         </xs:sequence>
       </xs:complexType>
     </xs:element>
   <xs:element name="PurchaseOrder">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="CustId" type="xs:string"/>
        <xs:element ref="Item" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
<xs:element name="Item">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="ProdId" type="xs:string"/>
        <xs:element name="Price" type="xs:double"/>
        <xs:element name="Quantity" type="xs:int"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Code generation difficulties

The XML Schema placed above is different than the one I start using by default (for the PageType XML Schema of the Aincha Web Framework). Because the Purchase orders schema is not that complex I would have implemented it this way:

<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.example.com/Orders"
  xmlns="http://www.example.com/Orders"
  elementFormDefault="qualified">
<xs:element name="Batch">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="PurchaseOrder" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="CustId" type="xs:string"/>
              <xs:element name="Item" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="ProdId" type="xs:string"/>
                    <xs:element name="Price" type="xs:double"/>
                    <xs:element name="Quantity" type="xs:int"/>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

This schema has the same definition as the previous one only the PurchaseOrder and Item are part of the complexType parts. Although this schema’s are both valid and they look the same, when using this schema with the XSD tool, different code is generated.

The first schema will generate the classes:

  • Batch
  • PurchaseOrder
  • OrderItem

While the second schema will generate classes:

  • Batch
  • BatchPurchaseOrder
  • BatchPurchaseOrderItem

Which is in my opinion not the names you would expect. If the schema is way more complex, you get even bigger names. And I know for sure that programmers don’t want to work with this unusual names.

At first, I though that this was a limitation of the XSD tool. But using the second schema within LINQ to XSD, the class names are also different and generated as private classes of the Batch object. With LINQ to XSD you get the following:

  • Batch
  • Batch.PurchaseOrderLocalType
  • Batch.PurchaseOrderLocalType.ItemLocalType

So it is important to keep it mind that different code will be generated bases on the structure of the XSD. Even when both schemas are valid.

What’s next?

In the next part of this comparison research I will investigate the following things:

  • amount of code used to work with XML data (based on the generated schema code);
  • time to load/parse the XML data (with different sizes);
  • time to print all the items inside the purchase orders to the console;
  • time to calculate the total purchase orders batch value and time to calculate the purchase order value for each customer;
  • CPU and Memory consumptions;

If you have other suggestions? Don’t hesitate to post them as a comment to this blog item.

Ik had nog zo gezegd: Geen bommetje!

Jong geleerd…

…is oud gedaan

Searching for a webbased diagram editor

I really like the Google Docs application. Working together with a team on a spreadsheet is really useful for status overviews. Love to see that this is working without browser plugins. I was really surprised to see the direct updates when a colleague was editing a cell of the shared spreadsheet.

Working together with web based collaboration tools makes it easy to share information directly to each other. At work we use Drupal to share information. Adding new content is easy and you can do it anywhere you want without installing software. Only an Internet connection is required.

When it comes to software development, I miss the functionality of creating diagrams within the web based collaboration tools. For example the steps I have to take to show an UML diagram within the webpage document:

  1. Create an UML diagram with an external application (Enterprise Architecture for example)
  2. Copy and paste the content of the diagram to an application which can save it as an image (Photoshop or MSPaint)
  3. Save the image
  4. Within the webbased collaboration tool use the browser upload functionality.
  5. Finally add the image to the document.

What if i made a mistake or want to update these diagrams? Or what if a colleague wants to update them?

It should be possible to make such an editor. UML can for example be converted to XMI which makes it possible to use for a webbased diagram editor to work with. I tried searching for such a web based tool but at this moment could not find anything useful. Do they exist? Or should i try to create a proof of concept to see if it is possible?

BTW: besides creating diagrams online, I also want to see the functionality of pasting an image within the webdocument. Clipboard functionality is limited inside a browser (because of security reasons). Would this be possible by the use on a Firefox plugin? The website should have some (AJAX) method implemented which accept a BASE64 encoded string containing the image data. This image data was stored on the clipboard. Don’t see any security risks because the user triggers the paste operation and websites only implements these methods on parts for which the user is logged in. So another research topic: is a FireFox plugin capable of making access to the clipboard?

Using LINQ to XSD, XML and SQL

Last year I started working on the Aincha Web Framework. This ASP.Net framework should make it possible to create websites with the use of widgets as building blocks. The configuration of the website is done by the use of XML.

With the use of XML configuration files, different page types can be defined which will be used to put different widgets inside the template placeholders. The same widget can be used by different page types.

I the first (proof of concept) version of the Aincha Web Framework I used XSD.exe to generate C# code which make it possible to deserialize XML files against these code generated classes. XSD.exe has some limitations when it comes to complex XML schemas. With the release of .Net 3.5 you can use LINQ (Language Integrated Query) which makes it possible to make use of datasources (like SQL, XML) directly from within the source code.

To continue with the Aincha Web Framework, to get a basic useful framework, I will do a little research on the use of LINQ to XSD and LINQ to XML for the XML configuration files. I will post the results on my blog.

Vakantie: Best of the West

Nog een aantal weken voordat het september is en dan gaan we op vakantie naar Amerika voor 3 weken. Hieronder de route welke we gaan volgen.


Grotere kaart weergeven

Niet vergeten: andere layout zoeken

Buiten een andere layout moet deze website natuurlijk gaan draaien op het Aincha Web Framework (http://www.codeplex.com/aincha). Nog veel werk te doen.