XML Convert 2.2

Invoking the xml2flat Application from the Command Line

This page describes how to invoke the xml2flat application from the command line. XML Convert includes a public Java class, named xml2flat, which converts an XML document into a flat file. The xml2flat class contains a public static method named main(), so that the class can be invoked from the command line. The xml2flat application is also available as a Windows executable (xml2flat.exe) that is invoked from the MS-DOS command line.

NAME

xml2flat – converts an XML document into a flat file

SYNOPSIS

Using Sun's Java virtual machine:

java xml2flat [options] schema_file xml_file [flat_file]

Using Microsoft's Java virtual machine, which is included with Internet Explorer 4.0 and 5.0:

jview xml2flat [options] schema_file xml_file [flat_file]

Using the Windows executable (xml2flat.exe):

xml2flat [options] schema_file xml_file [flat_file]

DESCRIPTION

The xml2flat application converts an XML document into a flat file. The conversion process is driven by an XFlat schema. The xml2flat application verifies that the XML document conforms to the XFlat schema.

The following is a description of the command line arguments:

To run the Java application, you must have a Java 1.1.7 (or higher) virtual machine installed on your computer. See the installation instructions for information about installing Java virtual machine on your computer.

To run the xml2flat application using the java or jview command, you must first update your CLASSPATH environment variable, so that it includes the xflat.jar file. Please see the installation instructions for details about setting the CLASSPATH environment variable.

The xml2flat.exe program will run on a Windows 95/98/Me/NT/2000/XP PC on which the Microsoft Java Virtual Machine (supporting Java 1.1.7 or higher) has been installed. See the installation instructions for information about installing the Microsoft Java virtual machine on your PC.

You do not need to update your CLASSPATH environment variable in order to invoke the xml2flat.exe Windows executable. However, it will be easier to invoke xml2flat.exe if you first update the PATH environment variable to include the path name of the directory in which xml2flat.exe resides. Please see the installation instructions for details about setting the PATH environment variable on your PC.

OPTIONS

xml2flat accepts the following options:

-s    Suppress the startup message that xml2flat displays to standard output.

DIAGNOSTICS

If you get the following error message when you invoke the xml2flat Java application using Sun's java command, then your CLASSPATH environment variable probably doesn't contain the path name of the xflat.jar file:

Exception in thread "main" java.lang.NoClassDefFoundError: xml2flat

If you get the following error message when you invoke the xml2flat Java application using Microsoft's jview command, then your CLASSPATH environment variable probably doesn't contain the path name of the xflat.jar file:

ERROR: Could not execute xml2flat : The system cannot find the file specified.

For information about setting your CLASSPATH environment variable, please see the installation instructions.

If you get the "Bad command or file name" error message when you try to invoke the xml2flat.exe program, then you probably did not specify the correct path name of the executable, or you probably did not update your PATH environment variable to include the path name of the directory in which the executable resides.

If you get the following error message when you try to invoke the xml2flat.exe program, then you probably don't have the Microsoft Java Virtual Machine installed on your PC.

Error Starting Program
A required .DLL file, MSVCRT.DLL, was not found.

To confirm that you don't have the Microsoft Java Virtual Machine installed on your PC, type the "jview/?" command at the MS-DOS command prompt. If the command fails with an error message of "Bad command or file name", then you probably don't have the Microsoft Java Virtual Machine installed on your PC. See the installation instructions for information about installing the Microsoft Java Virtual Machine on your PC.

If you get the following error message when you try to invoke the xml2flat.exe program, then you probably have an old version of the Microsoft Java Virtual Machine that does not support Java 1.1.7 or higher.

The Microsoft virtual machine does not support this application.
No such interface supported

In this case, see the installation instructions for information about installing a version of the Microsoft Java Virtual Machine that supports Java 1.1.7.

If you get an error message stating that a standard Java class (e.g., java.io.FileReader) or method could not be found, then you are probably running a pre-1.1.7 version of the Java virtual machine. In this case, you will need to upgrade to a virtual machine that supports Java 1.1.7 or higher. XML Convert uses some of the classes and methods that were introduced in Java 1.1.7. See the installation instructions for information about installing a Java virtual machine that supports Java 1.1.7 or higher.

If the xml2flat Java application encounters any errors (e.g., an invalid XFlat schema, a well-formedness error in the XML input document, the XML input document does not conform to the XFlat schema, etc.), then the conversion is aborted and an error message is written to standard error. The error message will include a detailed description of the error.

The error message will also include the following information about the location of the error:

The file name is displayed as a system identifier (e.g., file:/c:/invoices.xml). The line number of the first line in the file is one. The column number of the first character in a line is one.

Note that if an error is found in the XML file, then the output file will contain a partial flat file. The partial flat file is useful for troubleshooting the error.

EXIT CODES

The xml2flat application will exit with one of the following two exit codes:

0  –  Success.

1  –  Failure.

EXAMPLES

The following ksh script invokes the xml2flat application using Sun's java command:

java xml2flat -s invoices.xfl invoices.xml invoices.txt
return_code=$?
if [ $return_code -ne 0 ] ; then
    exit 1
fi

The following MS-DOS batch program invokes the xml2flat application using Microsoft's jview command:

java xml2flat -s employees.xfl employees.xml employees.txt
if not errorlevel 1 goto next
echo Aborting batch program.
goto end
:next
send_flat.bat employees.txt
:end

The following MS-DOS batch program invokes invokes the xml2flat.exe Windows executable:

xml2flat -s employees.xfl employees.xml employees.txt
if not errorlevel 1 goto next
echo Aborting batch program.
goto end
:next
send_flat.bat employees.txt
:end