Generating code with XSLT from a DataSet

One of the great things about a DataSet, from a code generation perspective that is, is that it is defined in an XML Schema with some added features for TableAdapters and such. I wrote a very simple code generator that takes a DataSet definition and an XSLT stylesheet and generates a code file. I also made it possible to call an XSLT stylesheet for each table in the DataSet so I could create Data Transfer Objects and such from the table definition. I had some trouble to get it going though because of a namespace issue. The namespace that you expect to be the default namespace isn’t in actual fact as I’ll explain with the following fragment:

<xs:schema id=”TrackingTracingDataSet”
attributeFormDefault=”qualified” elementFormDefault=”qualified”>
<xs:appinfo source=”urn:schemas-microsoft-com:xml-msdatasource”>

From the above fragment you would think that the default namespace is, because the default namespace is declare with the statement xmlns=” The actual default namespace is however defined in the source attribute of xs:appinfo element, so the default namespace is urn:schemas-microsoft-com:xml-msdatasource.

Leave a Reply

Your email address will not be published. Required fields are marked *

− 6 = 4