Serialization


Commands that produce XML and output to text format require Serialization. Serialization is controlled via Serialization Options

These options are global to the shell, and can also be specified on a per-command basis for most commands.




Examples


It is not always obvious when parsing or serialization occurs, for example depending on the participants in a pipeline and the xpipe setting, there may or may not be serialization and parsing in a pipeline.

Example: The xcat command will serialize to text then xml2csv will parse text to XML
xcat *.xml | xml2csv


Example: This uses an internal event oriented StAX pipeline and does NOT serialize or parse text XML
set -xpipe
xcat *.xml | xml2csv


Also depending on what technology individual commands use they may be outputing as 'pure XML' or as text.
Even with xpipe set, the external "cat" command requires text input so the xml is serialized and the xpipe is ignored.
set -xpipe
xcat *.xml | cat



How redirection is specified may also affect if XML is serialized or parsed.

For example, the following will serialize to text
xslt -f stylesheet.xsl -i input.xml > file.xml


But this command will NOT serialize to text, but rather construct an XML variable which was never serialized.
It is the TinyTree representation which saxon produces directly from the xslt without a copy or serialization.
xslt -f stylesheet.xsl -i input.xml >{VAR}


Similary the following may not ever produce or parse a text format depending on the implementation of "command".
var=$<(command)



Bare Attributes


Bare attribute values cannot be serialized without loosing information. They can be placed into a variable and used as arguments to commands,
but they when serialized they are converted to the string value of the attribute (losing the attribute the name).

To create a bare attribute you can use <[ ]> syntax and use any xquery expression which produces an attribute node.
This value value can be assigned to a variable or passed as an argument to a command that accepts attributes (such as xed

When any attempt is made to serialize an attribute it is converted to a string (the value part of the attribute).

Example
a=<[ <foo a="b" /> ]>
echo <[ $a/@a ]>

Result
b

There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki