Ejen Logo
 
   <save>


Description
Save node provides a way to serialize current XML node with all child nodes. You may use optional attributes in order to customize encoding and indentation of XML serialization. There is also a way to plug in your own serializer and to get any kind of file output format (even binary).
 
...
<source uri="big-file.xml"/>
<save uri="big-file-clone.xml"/>
<foreach select="doc/item">
  <save uri="item-{@name}.xml"/>
</foreach>
...

In the above sample, a large XML file is loaded and its entire content is saved in a file named "big-file-clone.xml". Then, it is splitted, item by item, into smaller files names "item-{@name}.xml" (where {@name} is replaced by the value of a name attribute within each item node).
 
...
<source uri="hexa-data.xml"/>
<save serializer="org.ejen.transformers.binary.BinarySerializer" uri="binary.dat"/>
...

Here, the "hexa-data.xml" file is loaded and then saved into a "binary.dat" file (that contains binary data of any kind, based on hexadecimal bytes defined in input file). This feature may be used to output PDF content for example, if you have implemented a PDFSerializer that uses XML content as input.

Attribute Summary
 
NameDefault ValueOptionalAccepted Values
amount2true 
backuponetrueone | no | all
cachetruetruetrue | false
encodingiso-8859-1true 
indentnotrueno | yes
serializer true 
uri false 

Attribute Detail
 
amount
specifies amount of indentation. This attribute as no effect if the indent attribute is set to no. Value of this attribute must be a positive integer or 0. Default is 2.
backup
what should we do if output file already exists: overwrite it (no), create only one backup (one) or create an unique backup each time (all) ? If "one" is set (this is the default), existing file will be renamed to [name-of-the-file].bak (overwriting previous backup if any) ; if "all" is set, existing file will be renamed to [name-of-the-file].[system-time-in-milliseconds]. Note that even in this case, if system time has been manually changed, there is a risk of overwriting.
cache
this attribute is always relative to an uri attribute within the same node. It allows to enable or to disable cache use for specific protocols (http protocol for example, if you have implemented this protocol with cache support).
encoding
specifies encoding used when serializing XML content. Default is "iso-8859-1".
indent
should the output XML file be indended (yes) or not (no). Default is "no".
serializer
full name of a child class of org.ejen.transformers.BaseTransformer (DOM mode) or org.ejen.transformers.BaseTransformerHandler (SAX mode). You may pass parameters to BaseTransformer or BaseTransformerHandler implementations by using an URI-like query part: my.builder.XBuilder?name1=value1&amp;name2=value2&amp;... (refer to API documentation).If you want to create specialized BaseTransformer or BaseTransformerHandler, you should download Ejen sources and have a look at the org.ejen.transformers.binary.BinarySerializer and org.ejen.transformers.binary.BinarySerializerHandler classes.
uri
name of the file to be generated. this is a generic input or output attribute. It is used as a content reference, using a specific protocol: file, http, ftp and jar protocols are supported by default, but there is a way to plug in additional protocols (see option node). If no protocol is specified, file is used by default. An uri attribute, except if it is absolute, is always relative to a base URI (see ejen node). Note that all protocols are not supposed to allow both reading and writing.

Children
 
No.


SourceForge.net Logo