Saving a File Back to Berkeley DB XML

You save a file to Berkeley DB XML as you would save a file to any other file system - click File > Save. If the document is not well-formed, Berkeley DB XML will not write it to the container.

Tip

 

Use the Stylus Studio well-formedness checker to check your XML documents before saving them to Berkeley DB XML.

Saving and Containers

By default, File > Save saves the file back to the same container from which it was read. Additionally, you can

  • Save the file to any container you choose, provided that you have specified it (and its database environment) in the BerkeleyDBXML.xml file.
  • Create a new container on the fly by specifying it in the URL. See Creating Containers with Stylus Studio.

In any case, in order to save any work back to Berkeley DB XML, you must have previously configured the BerkeleyDBXML.xml file. See Configuring the BerkeleyDBXML.xml File.

Validating Documents

If you are using Berkeley DB XML Version 2.0.7 or 2.0.9, you can optionally have Sleepycat validate XML documents before saving them to the database. You do this using the validate attribute, which you can set in the <dbxml>, <dbenv>, and <dbdir> nodes in the BerkeleyDBXML.xml file, as shown in the following example:

<dbxml validate="true">
               
   <dbenv path="c:\dbenv1" validate="false">
               
      <dbdir path="d:\datadir1"/>
               
      <dbdir path="e:\datadir2" validate="true"/>
               
   </dbenv>
               
   <dbenv path="c:\testenv" validate="true">
               
      <dbdir path="c:\testdata"/>
               
   </dbenv>
               
</dbxml>
               

            

The syntax for the validate attribute is validate=["true" | "false"]. By default, this attribute is not specified and validation is not performed.

Validation occurs at the container level; each container, specified as a node in the BerkeleyDBXML.xml file, can have its own settings for the validate attribute. A child node inherits the validate attribute from its parent; similarly, you can override settings for child nodes, as shown in the following example:

<dbxml>
               
   <dbenv path="c:\dbenv1" validate="true">
               
      <dbdir path="d:\datadir1"/>
               
      <dbdir path="e:\datadir2" validate="false"/>
               
   </dbenv>
               
</dbxml>
               

            

Here, the validate setting of the <dbenv> node overrides the (implicit) default of "false" of its parent, <dbxml>. The first child of <dbenv> inherits the validate="true" setting, and its second child overrides it.

Note

 

The set_database_dir entries read from the DB_CONFIG file do not contain any validate settings. To validate database directories established by the DB_CONFIG file, enter them in the BerkeleyDBXML.xml file.

Schema requirements

In order for Sleepycat to validate an XML document, the XML document must have its schema defined in an internal DTD. If the document does not contain a DTD, or references an external XML Schema, the document is not validated and will be saved if it is well-formed.

Changing settings

Each time Stylus Studio starts, it reads the BerkeleyDBXML.xml configuration file and uses its settings for the entire session. If you want to change the validate attribute for a container, you must exit Stylus Studio, change the BerkeleyDBXML.xml file, and then restart Stylus Studio.

Tip

 

Remember to validate the BerkeleyDBXML.xml file in Stylus Studio any time you edit it.

 
Free Stylus Studio XML Training: