LoadFromRecord (XmlDoc/XmlNode subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Created page with "{{Template:XmlDoc:NewFromRecord subtitle}} {{Template:XmlDoc:NewFromRecord footer}}")
 
mNo edit summary
Line 1: Line 1:
{{Template:XmlDoc:NewFromRecord subtitle}}
{{Template:XmlDoc:LoadFromRecord subtitle}}


==Syntax==
{{Template:XmlDoc:LoadFromRecord syntax}}




===Syntax terms===
<table class="syntaxTable">
<tr><th>%doc</th><td><var>LoadFromRecord</var> returns a new <var>XmlDoc</var> object.</td></tr>
<tr><th><var>%(XmlDoc)</var></th>
<td>The class name in parentheses denotes a shared method and is one way to invoke <var>LoadFromRecord</var>. You can also use an object expression whose type is <var>XmlDoc</var> (even if the value of the expression is null).</td></tr>
<tr><th><var>AttributeValues</var></th>
<td>This [[Methods#Named parameters|name required]] argument is a <var>[[Enumerations#Using Boolean enumerations|Boolean]]</var> value that indicates whether a field value will be stored as &ldquo;XML text&rdquo; or as an XML attribute (belonging to its field, which is an <var>XmlDoc</var> element).
For example, <code><APSUBUND>COMM</APSUBUND></code> is text format, and <code><APSUBUND value="COMM"/></code> is attribute value format.
The default value is <var>False</var>, which produces text format. In this format, the value of a field will be converted to base64 in the <var>XmlDoc</var> if the field contains a byte that is:
<ul>
<li>Equal to X'00', if the <var>[[AllowNull (XmlDoc property)|AllowNull]]</var> property of the <var>XmlDoc</var>
is <var>False</var>.
<li>Between X'00' and X'3F'.
<li>Not translatable from EBCDIC to Unicode, using either the standard [[Unicode#Support for the ASCII subset of Unicode|Unicode translation table]] or the base codepage translation table, as determined by the <var>CodepageTable</var> argument of <var>LoadFromRecord</var>.
<li>Not invertible when translating from EBCDIC to Unicode and back to EBCDIC using the standard Unicode translation table, if the <var>CodepageTable</var> argument is <var>False</var>.
</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>


<tr><th><var>AttributeNames</var></th>


{{Template:XmlDoc:NewFromRecord footer}}
<td>This name required argument is a <var>Boolean</var> value that indicates whether each field name is to be stored in the <var>XmlDoc</var> as an element name or as the value of a "name" attribute.
For example, <code><APSUBUND>COMM</APSUBUND></code> is element-name format, and the following is name-as-attribute format:
<p class="code"><nowiki><field name="APSUBUND">
  COMM
</field>
</nowiki></p>
The default value as of <var class="product">Sirius Mods</var> version 7.6 (and maintenance back to version 7.3) is <var>True</var>, which produces name-as-attribute format. Formerly, the default value was <var>False</var>.
The name-as-attribute format from the <var>True</var> option is better suited to operations on the <var>XmlDoc</var>, particularly a record copying operation. The element-name format from the <var>False</var> option produces more compact output when the <var>XmlDoc</var> is serialized.
This argument must be <var>True</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>NamesToLower</var></th>
<td>This name required argument is a <var>Boolean</var> value that indicates whether field names are stored in all lowercase characters. The default value is <var>False</var>, which does not translate uppercase name characters to lowercase.
If the <var>XmlDoc</var> is to be used for record copying, this argument should probably be <var>False</var>.
</td></tr>
 
<tr><th><var>AllowUnreversible</var></th>
 
<td>This name required argument is a <var>Boolean</var> 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 <var>False</var>, which allows request cancellation to alert you about unreversible field names.
If the <var>XmlDoc</var> is to be used for record copying, this argument should probably be <var>False</var>.</td></tr>
 
<tr><th><var>CodepageTable</var></th>
 
<td>This name required argument is a <var>Boolean</var> value; if <var>True</var>, the translations defined by the '''base''' Unicode codepage are used when translating from EBCDIC to Unicode for storing in the <var>XmlDoc</var>.
This argument is for the unusual case where you anticipate that the XML document is to be used later by <var>AddToRecord</var>, and the standard [[Unicode#Support for the ASCII subset of Unicode|Unicode translation tables]] in place when <var>AddToRecord</var> is invoked may differ from those in place when the record was copied to the <var>XmlDoc</var>.
The default value is <var>False</var>, which uses the standard Unicode translation tables, including any modifications specified in <code>UNICODE Trans</code> or <code>UNICODE Map</code> [[Unicode#Update forms of UNICODE|commands]].
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>
 
<tr><th><var>AllowNull</var></th>
 
<td>The value of this name required <var>Boolean</var> argument, which defaults to <var>False</var>, is copied to the <var>[[AllowNull (XmlDoc property)|AllowNull]]</var> property of the <var>XmlDoc</var> created by <var>LoadFromRecord</var>. The <var>XmlDoc</var>'s <var>AllowNull</var> property, in turn, determines whether field values that contain the X'00' character are stored in the <var>XmlDoc</var> with base64 encoding. Such values are base64 encoded if the <var>AllowNull</var> property is <var>False</var> (the default). For an example, see [[#Handling records with null characters|"Handling records with null characters"]], below.
</td></tr>
</table>
 
==Usage notes==
<ul>
<li>Whether to use <var>ToXmlDoc</var>, <var>[[NewFromRecord]]</var>, or <var>[[LoadFromRecord]]</var> depends on what is
most convenient for your application.
If you are already using a <var>Record</var> object which references the desired record,
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
contained in a &ldquo;record loop&rdquo;) may be more convenient.
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.
<p>
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>
poperty; <var>LoadFromRecord</var> does not have the <var>AllowNull</var> argument.</p>
<p>
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.</p>
<p>
Except for these considerations, <var>ToXmlDoc</var>, <var>NewFromRecord</var>, and <var>LoadFromRecord</var>
all perform the same operation and have the same arguments.
</p>
</ul>
==Examples==
 
 
 
{{Template:XmlDoc:LoadFromRecord footer}}

Revision as of 19:13, 2 June 2011

Template:XmlDoc:LoadFromRecord subtitle

Syntax

Template:XmlDoc:LoadFromRecord syntax


Syntax terms

%docLoadFromRecord returns a new XmlDoc object.
%(XmlDoc) The class name in parentheses denotes a shared method and is one way to invoke LoadFromRecord. You can also use an object expression whose type is XmlDoc (even if the value of the expression is null).
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.
AllowNull The value of this name required Boolean argument, which defaults to False, is copied to the AllowNull property of the XmlDoc created by LoadFromRecord. The XmlDoc's AllowNull property, in turn, determines whether field values that contain the X'00' character are stored in the XmlDoc with base64 encoding. Such values are base64 encoded if the AllowNull property is False (the default). For an example, see "Handling records with null characters", below.

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”) 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 “factory method” 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.

Examples

Template:XmlDoc:LoadFromRecord footer