wjcomeaux posted on Tuesday, November 07, 2006
The template that generates business objects from XML has an issue with Namespaces.
If you generate against the XML at the end of this message, and try to change the namespace on each object, only the first couple of namespaces get used. For instance, all my objects fall under EditableChild and ReadOnlyChildList. What should be an object under EditableRoot is placed under the EditableChild namespace (incorrectly).
I have verified that the proper templates are getting called as I have comments at the top of each template that outputs the template name so I know that the EditableRoot object is being generated against the correct template, but the namespace is incorrect.
In the template I have
//EditableRoot
<% if (objInfo.Namespace.Length > 0) { %>namespace <%= objInfo.Namespace %>
This only uses the correct namespace for the first and last objects in the XML file.
In the OutputSubTemplate function I am doing the following
subTemplate.SetProperty("ClassNamespace", _projectNamespace);
subTemplate.SetProperty("Namespace", _projectNamespace);
and I have verified that the namespace is correct at this point. It's when the code is actually generated that the objInfo.Namespace does not contain the correct value.
Thanks, Will
- <Object Access="public" Type="EditableChild" NameSpace="EditableChild" Name="Building">
- <Property Name="_ID" DbColumnName="_ID" Description="" Type="int" DataType="Int32" NativeType="int" SystemType="System.Int32" IsPrimaryKey="true" IsIdentity="true">
- <Property Name="_Name" DbColumnName="_Name" Description="" Type="string" DataType="AnsiString" NativeType="varchar" SystemType="System.String">
<StringMaxLength>50</StringMaxLength>
</ValidationRules>
</Property>
- <Property Name="_CompanyID" DbColumnName="_CompanyID" Description="" Type="EditableChild.Company" DataType="EditableChild.Company" NativeType="EditableChild.Company" SystemType="EditableChild.Company">
- <Property Name="_TimeStamp" DbColumnName="_TimeStamp" Description="" Type="byte[]" DataType="Binary" NativeType="timestamp" SystemType="System.Byte[]">
<Property Name="_Departments" DbColumnName="" Description="A collection of Departments" Type="ReadOnlyChildList.Departments" DataType="ReadOnlyChildList.Departments" NativeType="ReadOnlyChildList.Departments" SystemType="ReadOnlyChildList.Departments" />
</Properties>
<Relationship Parent="Company" />
</Object>
- <Object Access="public" Type="EditableRoot" NameSpace="EditableRoot" Name="Building">
- <Property Name="_ID" DbColumnName="_ID" Description="" Type="int" DataType="Int32" NativeType="int" SystemType="System.Int32" IsPrimaryKey="true" IsIdentity="true">
- <Property Name="_Name" DbColumnName="_Name" Description="" Type="string" DataType="AnsiString" NativeType="varchar" SystemType="System.String">
<StringMaxLength>50</StringMaxLength>
</ValidationRules>
</Property>
- <Property Name="_CompanyID" DbColumnName="_CompanyID" Description="" Type="EditableChild.Company" DataType="EditableChild.Company" NativeType="EditableChild.Company" SystemType="EditableChild.Company">
- <Property Name="_TimeStamp" DbColumnName="_TimeStamp" Description="" Type="byte[]" DataType="Binary" NativeType="timestamp" SystemType="System.Byte[]">
<Property Name="_Departments" DbColumnName="" Description="A collection of Departments" Type="EditableChildList.Departments" DataType="EditableChildList.Departments" NativeType="EditableChildList.Departments" SystemType="EditableChildList.Departments" />
</Properties>
</Object>
- <Object Access="public" Type="ReadOnlyChildList" NameSpace="ReadOnlyChildList" Name="Buildings">
- <Property Name="_ID" DbColumnName="_ID" Description="" Type="int" DataType="Int32" NativeType="int" SystemType="System.Int32" IsPrimaryKey="true" IsIdentity="true">
- <Property Name="_Name" DbColumnName="_Name" Description="" Type="string" DataType="AnsiString" NativeType="varchar" SystemType="System.String">
<StringMaxLength>50</StringMaxLength>
</ValidationRules>
</Property>
- <Property Name="_CompanyID" DbColumnName="_CompanyID" Description="" Type="int" DataType="Int32" NativeType="int" SystemType="System.Int32">
- <Property Name="_TimeStamp" DbColumnName="_TimeStamp" Description="" Type="byte[]" DataType="Binary" NativeType="timestamp" SystemType="System.Byte[]">
</Properties>
<Relationship Child="Building" Parent="Company" />
</Object>
</Objects>