
ospam Command in Linux
The ospam command in Linux is SGML/XML markup stream editor. It is part of the OpenSP toolset, which provides tools for working with SGML (Standard Generalized Markup Language) and XML documents. It specifically reads an SGML/XML document and writes the output with modifications or additional markup as specified.
Table of Contents
Here is a comprehensive guide to the options available with the ospam command −
- Installation of ospam Command
- Syntax of ospam Command
- ospam Command Options
- Examples of ospam Command in Linux
Installation of ospam Command
The ospam command is a part of the OpenSP toolset, to use it, the OpenSP must be installed on Linux.
To install OpenSP on Ubuntu, Kali Linux, Debian, and other Debian-based distributions, use the following command −
sudo apt install opensp
To install it on Arch Linux, use the command given below −
sudo pacman -S opensp
To install it on CentOS, use −
sudo yum install opensp
To install it on Fedora, use the following command −
sudo dnf install opensp
To verify the installation, check the version of ospam command −
ospam --version

Or check the binary path, using the which command −
which ospam

Syntax of ospam Command
The syntax of ospam command is as follows −
ospam [options] [file]
In the above syntax, the [options] field is used to specify the various options to modify the command's behavior. The [file] is used to specify files that need to be processed.
ospam Command Options
The options of ospam command are listed below −
Flags | Options | Description |
---|---|---|
-a name | --activate= name | Activate doctype or linktype name |
-A architecture | --architecture= architecture | Parse with respect to architecture |
-b bctf | --bctf= bctf | Use bctf for output |
-c sysid | --catalog= sysid | Use catalog file sysid |
-C | --catalogs | Use catalogs as in onsgmls |
-D directory | --directory= directory | Search directory for system identifiers. |
-e | --open-entities | Include open entities in error messages. |
-E max_errors | --max-errors= max_errors | Stop after max_errors errors |
-f file | --error-file= file | Redirect errors to file |
-h | --hoist-omitted-tags | Hoist omitted tags from internal entities |
--help | Display help and exit | |
-i name | --include= name | Include name (same as in onsgmls) |
-l | --lowercase | Convert added names to lowercase |
-m markup_option | --markup-option= markup_option | Modify markup (omittag, shortref, net, emptytag) |
-n | --error-numbers | Show error numbers |
-o name | --output-entity= name | Output entity name instead of the document |
-p | --output-prolog | Include SGML declaration and prolog |
-r | --raw | Skip RS/RE conversions in output |
-R | --restricted | Restricted mode (as in onsgmls) |
-v | --version | Print version number |
-wtype | --warning=type | Control warnings by type |
-x | --expand-references | Expand entity references (twice for all references with tags) |
Examples of ospam Command in Linux
This section demonstrates the usage of the ospam command in Linux with examples −
Activating a Doctype and Adding Omitted Tags
To activate the HTML doctype, use the following command −
ospam -ahtml -momittag file.sgml
Or −
ospam --activate=html --markup-option=omittag file.sgml
In the above command -ahtml activates the HTML doctype, and -momittag adds the omitted tags.

Including SGML Declaration and Prolog in the Output
To ensure that the SGML declaration and prolog are included in the output, use the -p or --output-prolog option with the ospam command −
ospam -p file.sgml

By default, it is omitted from the output.
Displaying Error Numbers in Error Messages
To display the error numbers in the error messages, use the -n or --error-numbers option −
ospam -n file.sgml

Displaying Help
To display help related to ospam command, use the following command −
ospam --help
Controlling Warnings
To control warnings by type, use the -w or --warning option with the ospam command. Some common warning types are xml, mixed, duplicate, all, empty, net, unused-map, or entity-ref. For example, to display a warning about duplicated entity references, use the ospam command in the following manner −
ospam -wduplicate file.sgml
Conclusion
The ospam command is a part of the OpenSP toolset, designed for working with SGML and XML documents by modifying and adding markup as specified. It offers a variety of options, such as activating doctypes, including SGML declarations, controlling error messages, and managing warnings.
To use ospam, OpenSP must be installed on the system. It is beneficial for parsing and modifying SGML/XML documents with various customization options.
In this tutorial, we explained the ospam command, its installation, syntax, options, and usage in Linux with examples.