srcml2src

Section: User Commands (1)
Updated: Sun Nov 12 19:47:07 EST 2006
Index Return to Main Contents
 

NAME

srcml2src - translates the XML source-code representation srcML into source code and provides utility features for the srcML format  

SYNOPSIS

srcml2src [-nizcgv ] [--language ] [--filename ] [--directory ] [--encoding ] [--src-encoding encoding] [input-srcML-file] [output-source-code-file]  

DESCRIPTION

The program srcml2src translates from the XML source-code representation srcML into source code. The srcML format allows for XML addressing, querying, and transformation of source code.

The combination of src2srcml and srcml2src allows for full round-trip transformation of source-code files without any loss of comments, white space, and preprocessing statements.

Conversion from the srcML format to source code is relatively straightforward. All XML tags are removed and escaped characters are unescaped. In addition, the special srcML element for a formfeed is converted back to a form-feed character (form-feed characters are not allowed in XML, even escaped).

In addition to conversion, srcml2src provides various srcML utilities such as extracting metadata, extracting individual parts of compound srcML files, and extracting metadata from individual parts of compound srcML files.

Using the character - in the place of an input source-code filename uses standard input, and in place of an output srcML file uses standard output.  

OPTIONS

-h, --help
Output the help and exit.
-V, --version
Output the version of srcml2src and exit.
-t, --src-encoding=encoding
Sets the encoding used for the output text source-code files to encoding. The default is ISO-8859-1.
-U, --unit=number
Refers to a specific nested unit in a compound srcML file. The numbering starts at 1. If the number is outside of the range of nested units then the command is ignored. In combination with the attribute flags, outputs the attribute of that particular unit. In combination with the --xml outputs the unit in xml (not as text as is the default).
-a, --extract-all
Extracts all units from a compound srcML file back into source-code files. The directory and filename used is based on that stored in the directory and filename attributes. Any necessary subdirectories are created and the file itself is created. Any existing file with the same path will be overwritten.
-X, --xml
Output is in srcML format. Used in combination with the --unit option to output a particular nested unit in XML. The output unit has attributes formed by the merger of the attributes of the individual unit and the overall unit.
-z, --compress
Output is in compressed gzip format. Only available in the libxml2-enabled version.
--no-xml-declaration
No output of the default XML declaration. Only applies to XML output. Useful when the output of the translator is to be placed inside another XML document.
--no-namespace-decl
No output of namespace declarations. Only applies to XML output. Useful when the output of the translator is to be placed inside another XML document.
-v, --verbose
Verbose output to standard error. Especially useful in --input-file mode.
 

METADATA OPTIONS

This set of options allows access to the metadata stored in the srcML document.
-l, --language
Output the language of the srcML file as stored in the attribute language in the unit element on standard output. The language is the value of the attribute of the root element unit, unless a particular unit is specified with the --unit option.
-d, --directory
Output the directory of the srcML file as stored in the attribute dir in the unit element on standard output. The directory is the value of the attribute of the root element unit, unless a particular unit is specified with the --unit option.
-f, --filename
Output the filename of the srcML file as stored in the attribute filename in the unit element on standard output. The filename is the value of the attribute of the root element unit, unless a particular unit is specified with the --unit option.
-s, --src-version
Output the version of the srcML file as stored attribute version in the unit element on standard output. The version is the value of the attribute of the root element unit, unless a particular unit is specified with the --unit option.
-p, --prefix=uri
Output the prefix of the namespace given by uri. The name of the prefix is output with a newline character. The default namespace is a blank line. If the URI does not match a namespace declaration then no line is output.
-n, --nested
Output the number of nested units in a compound srcML file on standard output. Result is 0 if the srcML file is not compound.
-i, --info
Output most of the metadata of the srcML file. Each individual piece of data, i.e., namespaces, encoding, language, directory, filename, and version, is on a separate line. The form of the information is that same as that of the full flag option to src2srcml to form it, without the leading "--". This information is very fast to access and only requires examination of the start of the root element unit.
-l, --longinfo
Output the metadata of the --info option along with the count of the nested units in a compound srcML document. This information requires the examination of the entire srcML document.
 

USAGE

To translate the srcML file main.cpp.xml into the C++ source-code file main.cpp:

srcml2src main.cpp.xml main.cpp

To extract the language of the srcML file main.cpp.xml:

srcml2src --language main.c.xml

To extract the directory of the srcML file main.cpp.xml:

srcml2src --directory main.c.xml

To extract the filename of the srcML file main.cpp.xml:

srcml2src --filename main.c.xml

To extract the version of the srcML file main.cpp.xml:

srcml2src --version main.c.xml

To extract the xml encoding of the srcML file main.cpp.xml:

srcml2src --encoding main.c.xml  

RETURN STATUS

0: Normal

1: Error

2: Problem with input file

3: Unknown option

4: Unknown encoding

5: Libxml2-only feature (not libxml2 enabled)

11: Text encoding option specified, but value missing

13: Unit option specified, but value missing

14: Unit option value is not valid

15: Invalid combination of options

16: Incomplete output due to termination  

CAVEATS

Line endings are normalized in XML and in the srcML format.  

BUGS

There may be some parts of XML (e.g., comments) unused in the srcML format (i.e., not generated by src2srcml) which are not preserved in the output with the --xml option.  

SEE ALSO

src2srcml(1)  

AUTHOR

Written by Michael L. Collard and Huzefa Kagdi


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
METADATA OPTIONS
USAGE
RETURN STATUS
CAVEATS
BUGS
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 00:47:07 GMT, November 13, 2006