Show All Projects
This is a script that will generate a class to represent an object from either serialized XML, a DTD file, or an XSD file. It requires the xsd.exe utility which is included with Visual Studio and the Windows Platform SDK. Java is required if converting DTD. Original batch script rewritten in Powershell to be more robust and an exercise to learn Powershell.

  • XML-DTD-XSD-To-Class.cmd - Original batch script.
  • XML-DTD-XSD-To-Class.ps1 - More robust version written in Powershell.
  • XML-DTD-XSD-To-Class.ps1.cmd - Runs the powershell version more conveniently, overcoming a few obstacles.

How It Works
Drag and drop a file on to either of the cmd files, or from the command line, pass a path to an xml, dtd, or xsd file. The Powershell version takes an optional second parameter to set the output language. The output language can be 'CS', 'VB', 'JS', 'VJS', 'CPP' or any "fully-qualified name for a class implementing System.CodeDom.Compiler.CodeDomProvider."

As a first step, XML or DTD will be converted to XSD.
DTD is converted to XSD by Trang (included), which requires that Java is installed.
XML is converted to XSD by xsd.exe. The Powershell version should find xsd.exe automatically if installed, while the batch script checks static paths which would will need to be updated for newer versions.

XSD is then converted to code using xsd.exe.

Note that the xsd.exe can sometimes produce code where there is an array of arrays where there should only be an array. Code may need to be checked for this.


Timeline

Files

  BENCHMARKS  
Loading Time: Base Classes  0.0200
Controller Execution Time ( Project / Id )  0.0509
Total Execution Time  0.0725
  GET DATA  
No GET data exists
  MEMORY USAGE  
1,049,584 bytes
  POST DATA  
No POST data exists
  URI STRING  
project/id/82/XML-DTD-XSD_To_Class
  CLASS/METHOD  
project/id
  DATABASE:  smkprojects (Project:$db)   QUERIES: 5 (0.0033 seconds)  (Hide)
0.0006   SELECT *
FROM `ProjectResources`
WHERE `ProjectID` = '82' 
0.0005   SELECT *
FROM `Projects`
WHERE `ProjectID` = '82' 
0.0004   SELECT *
FROM `ProjectTags`
WHERE `ProjectID` = '82' 
0.0010   SELECT TagCOUNT(1) AS cnt
FROM 
`ProjectTags`
WHERE `Tag` != 'Private'
GROUP BY `Tag`
HAVING COUNT(1) >
0.0008   SELECT TagCOUNT(1) AS cnt
FROM 
`ProjectTags`
WHERE `Tag` != 'Private'
GROUP BY `Tag`
HAVING COUNT(1) > 
  HTTP HEADERS  (Show)
  CONFIG VARIABLES  (Show)