Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for xml2xpath.bat

(view source code of xml2xpath.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4.  
  5. :: A single mandatory command line argument
  6. IF     "%~1"=="" GOTO Syntax
  7. IF NOT "%~2"=="" GOTO Syntax
  8.  
  9. :: Command line arguments must be an XML file
  10. IF /I NOT "%~x1"==".xml" GOTO Syntax
  11.  
  12. :: File must exist
  13. IF NOT EXIST "%~f1" GOTO Syntax
  14.  
  15. :: XSL file must exist
  16. IF NOT EXIST "%~dpn0.xsl" GOTO Syntax
  17.  
  18. :: Saxon must be available; hard-coded path to executable may need to be modified to match your own system
  19. IF NOT EXIST "%ProgramFiles%\Saxon\bin\Transform.exe" IF NOT EXIST "%ProgramFiles(x86)%\Saxon\bin\Transform.exe" GOTO Syntax
  20.  
  21. SETLOCAL
  22.  
  23. IF EXIST "%ProgramFiles%\Saxon\bin\Transform.exe"      SET Transform="%ProgramFiles%\Saxon\bin\Transform.exe"
  24. IF EXIST "%ProgramFiles(x86)%\Saxon\bin\Transform.exe" SET Transform="%ProgramFiles(x86)%\Saxon\bin\Transform.exe"
  25.  
  26. %Transform% -s:"%~f1" -xsl:"%~dpn0.xsl" 2>NUL
  27.  
  28. ENDLOCAL
  29. GOTO:EOF
  30.  
  31.  
  32. :Syntax
  33. ECHO.
  34. ECHO XML2XPath.bat,  Version 1.00 for Windows 2000 and later
  35. ECHO Display an XML file as a list of XPath statements
  36. ECHO.
  37. ECHO Usage:  XML2XPATH  xmlfile.xml
  38. ECHO.
  39. ECHO Notes:
  40. ECHO Requires XML2XPath.xsl, located in the same directory as this batch file.
  41. ECHO XSL borrowed from Paul Gallagher:
  42. ECHO tardate.blogspot.com/2007/02/extracting-xpath-refs-from-xml-document.html
  43. ECHO Requires Saxon XSLT processor:  http://saxon.sourceforge.net/
  44. ECHO Hard-coded path to Saxon's Transform.exe may need to be modified.
  45. ECHO.
  46. ECHO Written by Rob van der Woude
  47. ECHO http://www.robvanderwoude.com
  48.  
  49. IF "%OS%"=="Windows_NT" COLOR 00
  50.  

page last modified: 2024-04-16; loaded in 0.0077 seconds