tags:

views:

61

answers:

5

I have about 50 XSD files that are really badly formatted.

I know if I open them all in Visual Studio, I can beautify them one by one.

My question is: Is there a way to command line beautify them or some way I can do this in bulk?

+2  A: 

Not sure about the commandline program; but I think PowerCommands 10.0 can help you.

Format document on save / Remove and Sort Usings on save:

The Format document on save option formats the tabs, spaces, and so on of the document being saved. It is equivalent to pointing to the Edit menu, clicking Advanced, and then clicking Format Document. The Remove and sort usings option removes unused using statements and sorts the remaining using statements in the document being saved.

Note: The Remove and sort usings option is only available for C# documents.

Note: Format document on save and Remove and sort usings both are initially defaulted OFF.

KMan
PowerCommands is only available for 2010, right?
Raj More
Here's a link to PowerCommands for VS2008: http://visualstudiogallery.msdn.microsoft.com/en-us/df3f0c30-3d37-4e06-9ef8-3bff3508be31
Brian Schroer
A: 

You could use XSD.exe to generate classes from your XSDs, build an assembly of your classes, then use XSD.exe again against your new DLL to regen your XSDs.

You can also use SvcUtil.exe to do the same.

CkH
+1  A: 

Another option would be to use a tool like HTMLTidy (http://tidy.sourceforge.net/). This offers a command line tool, so you could easily write a .bat file to format a bunch of files at once.

Joe
+1  A: 

if you have perl installed you can use the xmlpp script

example:

c:\> perl xmlpp.pl yada.xml
<xml>
  <yada>asd</yada>
  <da>
    <bla>ada</bla>
    <bla>adaa</bla>
  </da>
</xml>

c:\>

and then use the for loop in command line to prettyfy your xml by:

c:\> for %X in (*.xml) do (perl xmlpp.pl %X > %X.pretty)
shil88
+1  A: 

The XMLStarlet "Swiss Army Knife" for XML can pretty print XML as well. It's command line and thus scriptable to batch process all your files. See http://xmlstar.sourceforge.net/ (Windows version downloadable here.)

Cumbayah