LoadFromRecord (XmlDoc/XmlNode subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(19 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Template:XmlDoc/XmlNode:LoadFromRecord subtitle}}
{{Template:XmlDoc/XmlNode:LoadFromRecord subtitle}}
This subroutine adds to an <var>XmlDoc</var> object a subtree that contains the fields and
fieldgroups from the current record. Among other things, the result <var>XmlDoc</var> can be used to copy a record, using the <var>[[AddToRecord (XmlDoc subroutine)|AddToRecord]]</var> subroutine.


This subroutine adds to an <var>XmlDoc</var> object a subtree that contains the fields and
fieldgroups from the current record.
This record extraction is the
This record extraction is the
same operation that is performed by the <var>[[NewFromRecord (XmlDoc function)|NewFromRecord]]</var> shared function and by the <var>[[Record class|Record]]</var> class <var>[[ToXmlDoc (Record function)|ToXmlDoc]]</var> function.
same operation that is performed by the <var>[[NewFromRecord (XmlDoc function)|NewFromRecord]]</var> shared function and by the <var>[[Record class|Record]]</var> class <var>[[ToXmlDoc (Record function)|ToXmlDoc]]</var> function, as is further described below in [[#Usage notes|"Usage notes"]].


==Syntax==
==Syntax==
Line 38: Line 38:
</ul>
</ul>
   
   
This argument must be <var>False</var> if the <var>XmlDoc</var> is to be used as the method object of the <var>[[#AddToRecord subroutine in XmlDoc class|AddToRecord]]</var> subroutine.</td></tr>
This argument must be <var>False</var> if the <var>XmlDoc</var> is to be used as the method object of the <var>AddToRecord</var> subroutine.</td></tr>


<tr><th><var>AttributeNames</var></th>
<tr><th><var>AttributeNames</var></th>
Line 78: Line 78:
The advantage of using <code>CodepageTable=False</code> is that it will allow you to readily modify the <var>XmlDoc</var> directly (that is, with the <var>[[AddElement (XmlDoc/XmlNode function)|AddElement]]</var> and <var>[[AddAttribute (XmlNode function)|AddAttribute]]</var> methods). Those operations will use the standard Unicode translation tables; there is no way to perform them using the base codepage translation tables.</td></tr>
The advantage of using <code>CodepageTable=False</code> is that it will allow you to readily modify the <var>XmlDoc</var> directly (that is, with the <var>[[AddElement (XmlDoc/XmlNode function)|AddElement]]</var> and <var>[[AddAttribute (XmlNode function)|AddAttribute]]</var> methods). Those operations will use the standard Unicode translation tables; there is no way to perform them using the base codepage translation tables.</td></tr>


</table>
<tr><th><var>Base64Encode</var></th>
<td>This name required argument is a <var>Boolean</var> value.
<p>The default is <var>True</var>, which indicates that before storing a field's value in the <var>XmlDoc</var>, the value is base64 encoded <b>if needed</b>. See [[ToXmlDoc (Record function)#casEnc|this ToXmlDoc usage note]] which describes the conditions that would require base64 encoding.</p>
<p>If <var>Base64Encode</var> is <var>False</var>, field values are not base64 encoded. This means: </p>
<ul>
<li>Control and uninvertible characters are translated to their Unicode counterparts.
<li>X'00' (if the <var>AllowNull</var> argument is not <var>True</var>) and untranslatable characters can cause request cancellation, unless they are mapped by the <var>CharacterMap</var> argument.
(An unmapped untranslatable character actually throws a <var>[[CharacterTranslationException class|CharacterTranslationException]]</var> exception, which results in cancellation if not caught.)
</ul>
<p>
<var>Base64Encode</var> is available as of <var class="product">Model 204</var> version 7.5.</p> </td></tr>


==Usage notes==
<tr><th><var>CharacterMap</var></th>
Whether to use <var>ToXmlDoc</var>, <var>NewFromRecord</var>, or <var>LoadFromRecord</var> depends on what is
most convenient for your application.
<td>This name required argument is a <var>[[CharacterToUnicodeMap class|CharacterToUnicodeMap]]</var> value. If a non-null value is provided, then the specified map is used to translate non-<var>UTF8</var>/<var>16</var> field values from EBCDIC to Unicode before storing in the <var>XmlDoc</var>.
If you are already using a <var>Record</var> object that references the desired record,
using <var>ToXmlDoc</var> may be more convenient; if not, then either
<p>Also, if a non-null value is provided, then the <var>Base64Encode</var> argument is forced to the value <var>True</var>, and the processing indicated by that is performed.</p>
<var>NewFromRecord</var> or <var>LoadFromRecord</var> (both of which require that the method be
contained in a &ldquo;record loop&rdquo;) may be more convenient.
<p><var>CharacterMap</var> is available as of <var class="product">Model 204</var> version 7.5.</p> </td></tr>
You must use <var>LoadFromRecord</var> if you want to add the record's content as a
subtree to a non-empty <var>XmlDoc</var>;
in other cases, the <var>NewFromRecord</var> &ldquo;factory method&rdquo; may be your choice.
Since <var>NewFromRecord</var> and <var>ToXmlDoc</var> create new <var>XmlDoc</var> objects, they have the
<var>AllowNull</var> argument for setting the created <var>XmlDoc</var>'s <var>[[allowNull (XmlDoc property)|AllowNull]]</var>
property. <var>LoadFromRecord</var> does not have the <var>AllowNull</var> argument.
As stated, both
<var>NewFromRecord</var> and <var>LoadFromRecord</var> must be
contained in a &ldquo;record loop&rdquo; (for example, an <var>FRN</var> block), and they may not be
invoked within a fieldgroup context.
Except for these considerations, <var>ToXmlDoc</var>, <var>NewFromRecord</var>, and <var>LoadFromRecord</var>
all perform the same operation and have the same arguments.
The discussion of the &ldquo;extract from record to <var>XmlDoc</var>&rdquo; operation
generally uses <var>LoadFromRecord</var>, except where one of these considerations
is relevant to the discussion.


==Examples==
</table>
====Copying from multiple source records====
Since <var>LoadFromRecord</var> can
extract from a record into a subtree of an <var>Element</var> node in an <var>XmlDoc</var>,
you can use it, together with <var>AddToRecord</var>, to combine multiple
source records into one target record.
As a simple example, you can put the fields from two records
&ldquo;side by side&rdquo; into a target record:
<p class="code">FRN %x
  %doc = %doc:NewFromRecord
End For
%top = %doc:SelectSingleNode('*')
FRN %y
  %top:LoadFromRecord
End For
Store Record
End Store
%rn = $CurRec
FRN %rn
  %doc:AddToRecord
End For
</p>
The <var>XmlDoc</var> that is input to <var>AddToRecord</var> would have a structure
similar to the following:
<p class="code"><nowiki><Record ...>
  <field ...>
  ... first field from record %x
  </field>
  ...
  <field ...>
  ... first field from record %y
  </field>
  ...
</Record>
</nowiki></p>
Of course, you could also accomplish this particular objective by
using two <var>XmlDoc</var> objects:
<p class="code"><nowiki>FRN %x
  %doc1 = %doc1:NewFromRecord
End For
FRN %y
  %doc2 = %doc2:NewFromRecord
End For
Store Record
End Store
%targ = $CurRec
FRN %targ
  %doc1:AddToRecord
  %doc2:AddToRecord
End For
</nowiki></p>
You can also use <var>LoadFromRecord</var> to modify the fieldgroup structure
within a record (using V7R2 of <var class="product">Model 204</var>).
For example, you could take the &ldquo;outer&rdquo; fields of one
record and move them to be fieldgroup members in the target
record:
<p class="code"><nowiki>In SRCFILE FRN %x
  %doc = %doc:NewFromRecord
End For
%fg = %doc:SelectSingleNode('*/fieldgroup[@name="GRP"]')
In SRCFILE FRN %y
  %fg:LoadFromRecord
End For
In TARGFILE Store Record
End Store
%rn = $CurRec
In TARGFILE FRN %rn
  %doc:AddToRecord
  PAI
End For
</nowiki></p>
The use of a separate source and target file above (which in
general is a typical usage of the record copying methods) is
more or less required here, because the fields in <code>SRCFILE</code> are
defined as outer fields, but in <code>TARGFILE</code> they are defined as members of fieldgroup
<code>GRP</code> (or they would need to be &ldquo;FIELDGROUP *&rdquo; fields).
So, for example, definitions for <code>SRCFILE</code> might include:
<p class="code"><nowiki>DEFINE FIELD FOO
DEFINE FIELDGROUP GRP
</nowiki></p>
and definitions for <code>TARGFILE</code> might include:
<p class="code"><nowiki>DEFINE FIELDGROUP GRP
DEFINE FIELD FOO WITH FIELDGROUP GRP
</nowiki></p>
And the <var>XmlDoc</var> that is input to the above <var>AddToRecord</var> subroutine
may look like:
<p class="code"><nowiki><Record ...>
  <fieldgroup name="GRP" ...>
      <field name="FOO">
        value of foo
      </field>
  </fieldgroup>
</Record>
</nowiki></p>
And the corresponding output of the above <code>PAI</code> would be:
<pre>
    \GRP = 1
    FOO = value of foo
    /GRP = 1
</pre>
 
{{Template:XmlDoc/XmlNode:LoadFromRecord footer}}


==Usage notes==
==Usage notes==
Line 220: Line 110:
using <var>ToXmlDoc</var> may be more convenient; if not, then either
using <var>ToXmlDoc</var> may be more convenient; if not, then either
<var>LoadFromRecord</var> or <var>NewFromRecord</var> (both of which require that the method be
<var>LoadFromRecord</var> or <var>NewFromRecord</var> (both of which require that the method be
contained in a &ldquo;record loop&rdquo;) may be more convenient.
contained in a record loop, for example, <var>For Each Record</var>) may be more convenient.
You must use <var>LoadFromRecord</var> if you want to add the record's content as a
You must use <var>LoadFromRecord</var> if you want to add the record's content as a
subtree to a non-empty <var>XmlDoc</var>;
subtree to a non-empty <var>XmlDoc</var>;
in other cases the <var>NewFromRecord</var> &ldquo;factory method&rdquo; may be your choice.
in other cases the <var>NewFromRecord</var> virtual constructor may be your choice.
<p>  
<p>  
Since <var>NewFromRecord</var> and <var>ToXmlDoc</var> create new <var>XmlDoc</var> objects, they have the
Since <var>NewFromRecord</var> and <var>ToXmlDoc</var> create new <var>XmlDoc</var> objects, they have the
<var>AllowNull</var> argument for setting the created <var>XmlDoc</var>'s <var>AllowNull</var>
<var>AllowNull</var> argument for setting the created <var>XmlDoc</var>'s <var>[[allowNull (XmlDoc property)|AllowNull]]</var>
poperty; <var>LoadFromRecord</var> does not have the <var>AllowNull</var> argument.</p>
poperty; <var>LoadFromRecord</var> does not have the <var>AllowNull</var> argument.</p>
<p>  
<p>  
As stated, both
As stated, both
<var>NewFromRecord</var> and <var>LoadFromRecord</var> must be
<var>NewFromRecord</var> and <var>LoadFromRecord</var> must be
contained in a &ldquo;record loop&rdquo;, for example, an <var>FRN</var> block, and they may not be
contained in a record loop, for example, an <var>FRN</var> block, and they may not be
invoked within a fieldgroup context.</p>
invoked within a fieldgroup context.</p>
<p>  
<p>  
Except for these considerations, <var>ToXmlDoc</var>, <var>NewFromRecord</var>, and <var>LoadFromRecord</var>
Except for these considerations, <var>ToXmlDoc</var>, <var>NewFromRecord</var>, and <var>LoadFromRecord</var>
all perform the same operation and have the same arguments.
all perform the same operation and have the same arguments.
</p>
</p>  
<li>All fields are copied to the <var>XmlDoc</var> by <var>LoadFromRecord</var>.
 
<li>In versions of <var class="product">Model 204</var> prior to 7.5, the effect of the <var>Base64Encoding</var>=<var>False</var> argument can be accomplished by post-processing the <var>XmlDoc</var> and replacing values which have an <code>encoding="base64"</code> attribute with the base 64 decoded value translated to Unicode.
<li>See the [[#AddToRecord subroutine in XmlDoc class|AddToRecord subroutine description]] for an example of extracting a record to an <var>XmlDoc</var> for record copying, and see the <var>[[ToXmlDoc (Record function)#Examples|ToXmlDoc]]</var> function for other examples using the method arguments.
 
<li>UTF8 and UTF16 fields are copied directly to the <var>XmlDoc</var>; there is no translation (either automatic or using the <var>CharacterMap</var> argument) nor base64 encoding involved for them.
<li>The <var>Base64Encode</var>=<var>False</var> argument can be used to disable any base64 encoding of field values. Alternatively, the <var>CharacterMap</var> argument (with a non-null value) can be used to disable any base64 encoding of field values, and to specify translations, which can avoid request cancellation due to X'00' and/or untranslatable characters in field values.
 
<li>See the additional comments in the <var>ToXmlDoc</var> [[ToXmlDoc (Record function)#othusage|Usage notes]], which apply equally to <var>NewFromRecord</var> and <var>LoadFromRecord</var>. The topics discussed there are:
<ul>
<li>Invalid characters in field names
<li>Using <var>AllowUnreversible</var> for lowercase or invalid field name characters
<li>Base64 encoding of field values
<li>Field level security
<li>LOB fields
<li>Record locks
</ul>
 
<li><var>LoadFromRecord</var> was actually introduced in version 7.6 of
<li><var>LoadFromRecord</var> was actually introduced in version 7.6 of
the <var class="product">Sirius Mods</var>, but the <var>XmlNode</var> class <var>LoadFromRecord</var> implementation prior to version 7.8 required that the <var>XmlDoc</var> be empty.
the <var class="product">Sirius Mods</var>, but the <var>XmlNode</var> class <var>LoadFromRecord</var> implementation prior to version 7.8 required that the <var>XmlDoc</var> be empty.
</ul>
</ul>


==Examples==
==Examples==
In addition to the examples in the following section, see the following examples in the <var>ToXmlDoc</var> description, both of which apply equally to <var>LoadFromRecord</var> and <var>NewFromRecord</var>:
<ul>
<li>The [[ToXmlDoc (Record function)#AttributeValues, AttributeNames, and NamesToLower arguments|"AttributeValues, AttributeNames, and NamesToLower arguments"]] example
<li>The [[ToXmlDoc (Record function)#Getting record lock|"Getting record lock"]] example
</ul>
====Copying from multiple source records====
====Copying from multiple source records====
Since <var>LoadFromRecord</var> subroutine can
Since <var>LoadFromRecord</var> can
extract from a record into a subtree of an <var>Element</var> node in an <var>XmlDoc</var>,
extract from a record into a subtree of an <var>Element</var> node in an <var>XmlDoc</var>,
you can use it, together with <var>AddToRecord</var>, to combine multiple
you can use it, together with <var>AddToRecord</var>, to combine multiple
Line 254: Line 164:
As a simple example, you can put the fields from two records
As a simple example, you can put the fields from two records
&ldquo;side by side&rdquo; into a target record:
&ldquo;side by side&rdquo; into a target record:
<p class="code"><nowiki>FRN %x
<p class="code">FRN %x
   %doc = %doc:NewFromRecord
   %doc = %doc:NewFromRecord
End For
End For
Line 267: Line 177:
   %doc:AddToRecord
   %doc:AddToRecord
End For
End For
</nowiki></p>
</p>
   
   
The <var>XmlDoc</var> that is input to <var>AddToRecord</var> would have a structure
The <var>XmlDoc</var> that is input to <var>AddToRecord</var> would have a structure
Line 300: Line 210:
   
   
You can also use <var>LoadFromRecord</var> to modify the fieldgroup structure
You can also use <var>LoadFromRecord</var> to modify the fieldgroup structure
within a record (using V7R2 of <var class="product">Model 204</var>).
within a record (using V7R5 of <var class="product">Model 204</var>).
For example, you could take the &ldquo;outer&rdquo; fields of one
For example, you could take the &ldquo;outer&rdquo; fields of one
record and move them to be fieldgroup members in the target
record and move them to be fieldgroup members in the target
Line 344: Line 254:
</nowiki></p>
</nowiki></p>
And the corresponding output of the above <code>PAI</code> would be:
And the corresponding output of the above <code>PAI</code> would be:
<pre>
<p class="code">\GRP = 1
    \GRP = 1
FOO = value of foo
    FOO = value of foo
/GRP = 1
    /GRP = 1
</p>
</pre>


 
{{Template:XmlDoc/XmlNode:LoadFromRecord footer}}
{{Template:XmlDoc:LoadFromRecord footer}}

Latest revision as of 16:58, 4 September 2015

Load fields and fieldgroups from current record (XmlDoc and XmlNode classes)

[Requires Janus SOAP]

This subroutine adds to an XmlDoc object a subtree that contains the fields and fieldgroups from the current record. Among other things, the result XmlDoc can be used to copy a record, using the AddToRecord subroutine.

This record extraction is the same operation that is performed by the NewFromRecord shared function and by the Record class ToXmlDoc function, as is further described below in "Usage notes".

Syntax

nr:LoadFromRecord[( [AttributeValues= boolean], [AttributeNames= boolean], - [NamesToLower= boolean], [AllowUnreversible= boolean], - [CodepageTable= boolean], [Base64Encode= boolean], - [CharacterMap= characterToUnicodeMap])] Throws CharacterTranslationException


Syntax terms

nrLoadFromRecord is in both the XmlDoc and XmlNode classes. When the method object is an XmlDoc, or refers to the Root node of an XmlDoc:
  • The XmlDoc must not contain any nodes except the Root node.
  • A "Record" element is added as the top level element of the XmlDoc. Children are added to the Record element, representing the outer fields and fieldgroups of the record.

When the method object is an XmlNode not referring to the Root node of an XmlDoc:

  • The node must be an Element node.
  • Children are added to that element, representing the outer fields and fieldgroups of the record.

"Structure of XmlDoc for AddToRecord" in the AddToRecord method page describes in detail the XmlDoc created by LoadFromRecord.

AttributeValues This name required argument is a Boolean value that indicates whether a field value will be stored as “XML text” or as an XML attribute (belonging to its field, which is an XmlDoc element).

For example, <APSUBUND>COMM</APSUBUND> is text format, and <APSUBUND value="COMM"/> is attribute value format.

The default value is False, which produces text format. In this format, the value of a field will be converted to base64 in the XmlDoc if the field contains a byte that is:

  • Equal to X'00', if the AllowNull property of the XmlDoc is False.
  • Between X'00' and X'3F'.
  • Not translatable from EBCDIC to Unicode, using either the standard Unicode translation table or the base codepage translation table, as determined by the CodepageTable argument of LoadFromRecord.
  • Not invertible when translating from EBCDIC to Unicode and back to EBCDIC using the standard Unicode translation table, if the CodepageTable argument is False.
This argument must be False if the XmlDoc is to be used as the method object of the AddToRecord subroutine.
AttributeNames This name required argument is a Boolean value that indicates whether each field name is to be stored in the XmlDoc as an element name or as the value of a "name" attribute.

For example, <APSUBUND>COMM</APSUBUND> is element-name format, and the following is name-as-attribute format:

<field name="APSUBUND"> COMM </field>

The default value as of Sirius Mods version 7.6 (and maintenance back to version 7.3) is True, which produces name-as-attribute format. Formerly, the default value was False.

The name-as-attribute format from the True option is better suited to operations on the XmlDoc, particularly a record copying operation. The element-name format from the False option produces more compact output when the XmlDoc is serialized.

This argument must be True if the XmlDoc is to be used as the method object of the AddToRecord subroutine.
NamesToLower This name required argument is a Boolean value that indicates whether field names are stored in all lowercase characters. The default value is False, which does not translate uppercase name characters to lowercase.

If the XmlDoc is to be used for record copying, this argument should probably be False.

AllowUnreversible This name required argument is a Boolean value that indicates whether a request is cancelled if a field name would be changed irreversibly by lowercasing or by replacing with a period the characters that would be invalid in an XML document.

The default value is False, which allows request cancellation to alert you about unreversible field names.

If the XmlDoc is to be used for record copying, this argument should probably be False.
CodepageTable This name required argument is a Boolean value; if True, the translations defined by the base Unicode codepage are used when translating from EBCDIC to Unicode for storing in the XmlDoc.

This argument is for the unusual case where you anticipate that the XML document is to be used later by AddToRecord, and the standard Unicode translation tables in place when AddToRecord is invoked may differ from those in place when the record was copied to the XmlDoc.

The default value is False, which uses the standard Unicode translation tables, including any modifications specified in UNICODE Trans or UNICODE Map commands.

The advantage of using CodepageTable=False is that it will allow you to readily modify the XmlDoc directly (that is, with the AddElement and AddAttribute methods). Those operations will use the standard Unicode translation tables; there is no way to perform them using the base codepage translation tables.
Base64Encode This name required argument is a Boolean value.

The default is True, which indicates that before storing a field's value in the XmlDoc, the value is base64 encoded if needed. See this ToXmlDoc usage note which describes the conditions that would require base64 encoding.

If Base64Encode is False, field values are not base64 encoded. This means:

  • Control and uninvertible characters are translated to their Unicode counterparts.
  • X'00' (if the AllowNull argument is not True) and untranslatable characters can cause request cancellation, unless they are mapped by the CharacterMap argument. (An unmapped untranslatable character actually throws a CharacterTranslationException exception, which results in cancellation if not caught.)

Base64Encode is available as of Model 204 version 7.5.

CharacterMap This name required argument is a CharacterToUnicodeMap value. If a non-null value is provided, then the specified map is used to translate non-UTF8/16 field values from EBCDIC to Unicode before storing in the XmlDoc.

Also, if a non-null value is provided, then the Base64Encode argument is forced to the value True, and the processing indicated by that is performed.

CharacterMap is available as of Model 204 version 7.5.

Usage notes

  • Whether to use ToXmlDoc, NewFromRecord, or LoadFromRecord depends on what is most convenient for your application. If you are already using a Record object which references the desired record, using ToXmlDoc may be more convenient; if not, then either LoadFromRecord or NewFromRecord (both of which require that the method be contained in a record loop, for example, For Each Record) may be more convenient. You must use LoadFromRecord if you want to add the record's content as a subtree to a non-empty XmlDoc; in other cases the NewFromRecord virtual constructor may be your choice.

    Since NewFromRecord and ToXmlDoc create new XmlDoc objects, they have the AllowNull argument for setting the created XmlDoc's AllowNull poperty; LoadFromRecord does not have the AllowNull argument.

    As stated, both NewFromRecord and LoadFromRecord must be contained in a record loop, for example, an FRN block, and they may not be invoked within a fieldgroup context.

    Except for these considerations, ToXmlDoc, NewFromRecord, and LoadFromRecord all perform the same operation and have the same arguments.

  • In versions of Model 204 prior to 7.5, the effect of the Base64Encoding=False argument can be accomplished by post-processing the XmlDoc and replacing values which have an encoding="base64" attribute with the base 64 decoded value translated to Unicode.
  • UTF8 and UTF16 fields are copied directly to the XmlDoc; there is no translation (either automatic or using the CharacterMap argument) nor base64 encoding involved for them.
  • The Base64Encode=False argument can be used to disable any base64 encoding of field values. Alternatively, the CharacterMap argument (with a non-null value) can be used to disable any base64 encoding of field values, and to specify translations, which can avoid request cancellation due to X'00' and/or untranslatable characters in field values.
  • See the additional comments in the ToXmlDoc Usage notes, which apply equally to NewFromRecord and LoadFromRecord. The topics discussed there are:
    • Invalid characters in field names
    • Using AllowUnreversible for lowercase or invalid field name characters
    • Base64 encoding of field values
    • Field level security
    • LOB fields
    • Record locks
  • LoadFromRecord was actually introduced in version 7.6 of the Sirius Mods, but the XmlNode class LoadFromRecord implementation prior to version 7.8 required that the XmlDoc be empty.

Examples

In addition to the examples in the following section, see the following examples in the ToXmlDoc description, both of which apply equally to LoadFromRecord and NewFromRecord:

Copying from multiple source records

Since LoadFromRecord can extract from a record into a subtree of an Element node in an XmlDoc, you can use it, together with AddToRecord, to combine multiple source records into one target record.

As a simple example, you can put the fields from two records “side by side” into a target record:

FRN %x %doc = %doc:NewFromRecord End For %top = %doc:SelectSingleNode('*') FRN %y %top:LoadFromRecord End For Store Record End Store %rn = $CurRec FRN %rn %doc:AddToRecord End For

The XmlDoc that is input to AddToRecord would have a structure similar to the following:

<Record ...> <field ...> ... first field from record %x </field> ... <field ...> ... first field from record %y </field> ... </Record>

Of course, you could also accomplish this particular objective by using two XmlDoc objects:

FRN %x %doc1 = %doc1:NewFromRecord End For FRN %y %doc2 = %doc2:NewFromRecord End For Store Record End Store %targ = $CurRec FRN %targ %doc1:AddToRecord %doc2:AddToRecord End For

You can also use LoadFromRecord to modify the fieldgroup structure within a record (using V7R5 of Model 204). For example, you could take the “outer” fields of one record and move them to be fieldgroup members in the target record:

In SRCFILE FRN %x %doc = %doc:NewFromRecord End For %fg = %doc:SelectSingleNode('*/fieldgroup[@name="GRP"]') In SRCFILE FRN %y %fg:LoadFromRecord End For In TARGFILE Store Record End Store %rn = $CurRec In TARGFILE FRN %rn %doc:AddToRecord PAI End For

The use of a separate source and target file above (which in general is a typical usage of the record copying methods) is more or less required here, because the fields in SRCFILE are defined as outer fields, but in TARGFILE they are defined as members of fieldgroup GRP (or they would need to be “FIELDGROUP *” fields). So, for example, definitions for SRCFILE might include:

DEFINE FIELD FOO DEFINE FIELDGROUP GRP

and definitions for TARGFILE might include:

DEFINE FIELDGROUP GRP DEFINE FIELD FOO WITH FIELDGROUP GRP

And the XmlDoc that is input to the above AddToRecord subroutine may look like:

<Record ...> <fieldgroup name="GRP" ...> <field name="FOO"> value of foo </field> </fieldgroup> </Record>

And the corresponding output of the above PAI would be:

\GRP = 1 FOO = value of foo /GRP = 1