Geeks With Blogs
Paul's development blog Tidbits from Smart Client, Windows Forms, C#, .NET 2.0, XML, and related toys...

In order to implement server-side XSD validation against an InfoPath form submission, I had to pull the XSD from the InfoPath document archive (XSN file) and use that to update an embedded resource in a SharePoint solution project (including automated checkout/checkin in TFS). I was able to do it using a batch file.

Pretty specialized need, but maybe somebody could make use of it someday ;).

@echo off

rem ***********************************************************
rem This batch file is used to extract the XSD files from each of the InfoPath forms, and copy them into the source tree
rem Download and install the Microsoft CAB SDK from http://support.microsoft.com/kb/310618 to c:\cabsdk
rem ***********************************************************

rem IMPORTANT: Set these values to your system. Do not include trailing slashes, and include values in quotes if necessary

set CABSDK_PATH=c:\cabsdk\bin
set ROOT=C:\projects\projectname
set TFS_USERNAME="domain\user.name"
set TFS_PASSWORD=password

rem These should be relatively fixed
set FORMS_ROOT=%ROOT%\Project.Namespace\12\TEMPLATE\Layouts\infopathForms
set XSD_ROOT=%ROOT%\Project.Namespace\12\Resources
set TF_PATH=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE

echo.
echo ********* InfoPath Form 1 *********
echo.
set FORM_PATH=%FORMS_ROOT%\Form 1\Form1.xsn
set XSD_PATH=%XSD_ROOT%\Form1.xsd
set RETURN=FINISH
goto UPDATE_SCHEMA

:FINISH
goto FINISH_BATCH

:UPDATE_SCHEMA
echo Checking file out...
"%TF_PATH%\tf.exe" edit "%XSD_PATH%" /login:%TFS_USERNAME%,%TFS_PASSWORD% /noprompt >/nil

echo Extracting file...
del myschema.xsd
"%CABSDK_PATH%\extract.exe" "%FORM_PATH%" myschema.xsd >/nil

echo Replacing file...
copy myschema.xsd "%XSD_PATH%" >/nil

echo Checking file in...
"%TF_PATH%\tf.exe" checkin "%XSD_PATH%" /login:%TFS_USERNAME%,%TFS_PASSWORD% /noprompt /comment:"Automated checkin from XsdExtractor script" >/nil

goto %RETURN%

:FINISH_BATCH

Posted on Monday, April 14, 2008 1:43 PM | Back to top


Comments on this post: Synchronize XSD from an InfoPath document with a SharePoint project for server-side XSD validation.

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Paul Whitaker | Powered by: GeeksWithBlogs.net