Revision [1869]
This is an old revision of SerializationOptions made by DavidLee on 2012-10-31 20:04:49.
Serialization and Parsing options
There are several global (shell scope) options that control serialization and parsing. These control default parameters used whenever plain text is parsed into XML , and when XML is serialized to text.
Most commands (where noted) can also accept these options which override the shell options for just that command.
Parsing Options
The following global parsing options may be set by the set command.
-text-encoding encoding | The default encoding any time that text is read or written and otherwise the encoding is not known. Defaults to the java file.encoding property. Sets both -input-text-encoding and -output-text-encoding |
-input-text-encoding encoding | The default encoding any time that text is read and the encoding is not known. Defaults to the java file.encoding property. |
-encoding encoding | sets both the text-encoding and xml-encoding option |
-supports-dtd | indicates if the parser should support DTD validation |
-input-xml-encoding encoding | Default encoding used for parsing xml |
Serializing Options
The following global serialization options may be set by the set command. These may be overwritten by specific commands.
-omit-xml-declaration | Omit the leading xml declaration. |
-indent | Indent text serialized xml for more human friendly output |
-xml-encoding encoding | Default encoding used for parsing and serializing xml |
-output-xml-encoding encoding | Default encoding used for serialized xml |
-content-type type | specifies the content type |
-method output-method | specifies the output method, must be one of (text,html,xml,xhtml) |
-sequence-sep string | specifies the sequence seperator string used when serializing sequences to text default is LF |
-sequence-term string | specifies the sequence terminator string used when serializing sequences to text default is LF |
Examples
Indentation
Indentation is controlled with the -indent option. Default is indentation.Example
xecho <[ <foo><bar/></foo> ]>
Results
<foo> <bar/> </foo>
Example
xecho +indent <[ <foo><bar/></foo> ]>
Result
<foo><bar/></foo>
Example of setting +indent globally using the set command
set +indent xecho <[ <foo><bar/></foo> ]>
Result
<foo><bar/></foo>
Serialization