save [--format|:F html|xml] [--xinclude|:x]
[--file|:f filename |
--pipe|:p filename |
--string|:s |
--print|:r ]
[--subtree|:S]
[--indent|:i | --no-indent|:I]
[--skip-dtd|:d | --no-skip-dtd|:D]
[--skip-empty-tags|:t | --no-skip-empty-tags|:T]
[--skip-xmldecl|:x]
[--encoding|:e encoding]
document
This takes a given document, serializes it to XML or HTML and either saves the result to its original file or another file (default), pipes it to an external command, prints it on standard output, or simply returns it. Without arguments it simply saves current document to its original file.
--file|:f
option
may be used to specify an output file-name.
By default, the original document's file-name
is used.
--pipe|:p
option
specifies, that the output should be
piped to an external command
specified as the option's argument.
--print|:r
option
specifies, that the output should
be printed on standard output.
--string|:s
option specifies, that the output
should be returned by the command
as a string. In this case, the result is
always in UTF8, regardless on which
encoding is specified in the document
or using --encoding
option.
The above four options are mutually exclusive.
--format
option may be used
to specify the output format. It's argument
should be either xml
,
html
or an expression
evaluating to one of these. If not specified,
XML output is assumed.
Note, that a document should be saved as HTML only if it
actually is a HTML document, otherwise the result would be
an invalid XML instance. Note also, that the optional
encoding parameter only forces character conversion; it is
up to the user to declare the document encoding in the
appropriate HTML <META> tag, if needed.
--xinclude
automatically implies XML format and
can be used to force XSH2 to save all already expanded
XInclude sections back to their original files while
replacing them with <xi:include> tags in the main
XML file. Moreover, all material included within
<include> elements from the
http://www.w3.org/2001/XInclude
namespace is saved to separate files too according to the
href
attribute, leaving only empty
<include> element in the root file. This feature may
be used to split the document to a new set of XInclude fragments.
If the --subtree
(:S
)
flag is used, only the subtree of the
specified node is saved instead of the complete document
(this flag cannot be used
with --html
format).
--indent
(:i
)
and
--no-indent
(:n
)
may be used to enforce/suppress
indentation, overriding current global setting
of indent.
--skip-dtd
(:d
)
and
--no-skip-dtd
(:D
)
may be used to enforce/suppress
skipping DTD declaration and internal subset
on output, overriding current global setting
of skip-dtd.
--empty-tags
(:t
)
and
--no-empty-tags
(:T
)
may be used to override current global setting
of empty-tags.
--no-empty-tags
instructs XSH2
to serialize elements with no child nodes
as start-tag/end-tag pair
<element></element>
instead of using a short empty-tag form
<element/>
.
--skip-xmldecl
(:x
)
instructs XSH2 to omit the XML declaration
from the saved document. Note however, that XML declaration
is obligatory for XML documents. It usually looks like
<?xml version="1.0" ...?>
.
--backup
(:b
)
and
--no-backup
(:B
)
can be used to enforce/suppress
creation of a backup file if target file
already exists. Using these options
overrides current global setting of backups.
--encoding
followed by a encoding
instructs XSH2 to save the document in the specified
encoding. In case of XML output, the <?xml?>
declaration is automatically changed accordingly.
Example 48. Use save to preview current HTML document in Lynx
save --format html --pipe 'lynx -stdin'