Community articleencloseInstance method
Added by IBM contributorIBM on August 15, 2011
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.



Description

This method modifies one instance in the data model, either updating information or appending information. Note that the form must have an existing data model.
Call this method on the root node of the form or an XML instance node.
Note: Use caution when calling this method. It can be used to overwrite signed instance data.

Method

READING A FILE:
   public void encloseInstance(
      String theInstanceID,
      String theFile,
      int theFlags,
      String theScheme,
      String theRootReference,
      FormNodeP theNSNode,
      boolean replaceNode
   ) throws UWIException;

READING A STREAM:
   public void encloseInstance(
      String theInstanceID,
      java.io.InputStream theStream,
      int theFlags,
      String theScheme,
      String theRootReference,
      FormNodeP theNSNode,
      boolean replaceNode
   ) throws UWIException;

READING FROM THE READER:
   public void encloseInstance(
      String theInstanceID,
      java.io.Reader  theReader,
      int theFlags,
      String theScheme,
      String theRootReference,
      FormNodeP theNSNode,
      boolean replaceNode
   ) throws UWIException;


Parameters

Table 1. Method parameters
ExpressionTypeDescription
theInstanceIDStringThe ID of the instance node to create or replace. This is defined by the id attribute of that node, and is case sensitive.
To replace the root node of the form, set this parameter to null.
theFileStringThe path to the file on the local drive that contains the XML instance. Note that this file must be UTF-8.
theStream java.io.InputStreamThe input stream that will read the instance data. Note that the data must be UTF-8.
theReader java.io.Reader The Java Reader that will read the instance data. Note that this data must be UTF-8.
theFlagsintReserved. Must be 0.
theSchemeStringReserved. Must be null.
theRootReferenceStringA reference to the node you want to replace or append children to. This reference is relative to the instance node.
Use null to default to the instance node.
theNSNodeFormNodePA node that inherits the namespaces used in the reference. This node defines the namespaces for the method. Use null if the node that this method is operating on has inherited the necessary namespaces.
replaceNodebooleanIf true, the node specified by theRootReference is replaced with data. If false, the data is appended as the last child of the theRootReference node.


Returns

Nothing if call is successful or throws a generic exception (UWIException) if an error occurs.

Example

The following example shows a method that takes the root node of a form and updates the XML instance called "data".
   private static void updateDataInstance(FormNodeP theForm) throws Exception
   {
      theForm.encloseInstance("data", 
         "c:\Instance Files\Personnel\tempdata.dat", 0, null, null, null,
         true);
   }


Parent topic:
FormNodeP class