Programmer Guide/Command Reference/IREF: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
(spelling)
 
(36 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
The <code>IREF</code> command returns the current [[Programmer Guide/Concepts/IREF|internal reference]] (<code>IREF</code>) of the supplied XML [[Programmer_Guide/Shell_Items/File|file item]], or, if you provide additional element data, the internal reference for the respective element of the supplied XML file item. If this information is not available, or not applicable, the <code>IREF</code> command will return the empty string.
The <code>IREF</code> command returns the [[Programmer Guide/Concepts/IREF|internal reference]] (<code>IREF</code>) of the currently selected element of the supplied XML [[Programmer_Guide/Shell_Items/File|file item]], or, if you provide additional element data, the internal reference for the respective element of the supplied XML file item. If this information is not available, or not applicable, the <code>IREF</code> command will return the empty string.


  <var>var</var> := IREF <var>xmlfile</var> /Format [ /Attribute=<var>irefAttr</var> ] [ /Baseposition=<var>basePos</var> ] [ [[Programmer_Guide/Command_Reference_Options/Silent|/Ilent]] ]
== IREF of the currently selected element ==
The basic form of the <code>IREF</code> command retrieves the IREF of the currently selected element:
  <var>var</var> := IREF <var>xmlfile</var> /Format
            [ /Attribute=<var>irefAttr</var> ] [ /Baseposition=<var>basePos</var> ] [ [[Programmer_Guide/Command_Reference_Options/Silent|/Ilent]] ]
Note that the <code>/Format</code> option is mandatory.


  <var>var</var> := IREF <var>xmlfile</var> /Format <var>position</var> [ /Attribute=<var>irefAttr</var> ] [ /Baseposition=<var>basePos</var> ] [ [[Programmer_Guide/Command_Reference_Options/Silent|/Ilent]] ]
== IREF of an {{STX}} file position ==
When you supply an {{STX}} [[Programmer Guide/Concepts/File_position|file position]], <var>position</var>, the <code>IREF</code> command retrieves the IREF of the element whose position you supplied:
  <var>var</var> := IREF <var>xmlfile</var> /Format <var>position</var>
            [ /Attribute=<var>irefAttr</var> ] [ /Baseposition=<var>basePos</var> ] [ [[Programmer_Guide/Command_Reference_Options/Silent|/Ilent]] ]
In this case, the option <code>/Delete</code> will cause the {{STX}} position to be deleted. Note that here, too, the <code>/Format</code> option is mandatory.


  <var>var</var> := IREF <var>xmlfile</var> <var>table</var> <var>posfld</var> <var>reffld</var> [ /Delete /Tagged ] [ /Baseposition=<var>basePos</var> ] [ [[Programmer_Guide/Command_Reference_Options/Silent|/Ilent]] ]
== Bulk processing ==
 
If you need to retrieve the internal references for a larger number of file positions, you may supply the respective positions in an {{STX}} [[Programmer_Guide/Concepts/Extended_table|extended table item]]. In this case, the ''iref'' for each position will be stored in a different field of the same table:
  <var>var</var> := IREF <var>xmlfile</var> /Select [ <var>iref</var> | <var>position</var> ] [ /Nocase ] [ /Attribute=<var>irefAttr</var> ]
  <var>var</var> := IREF <var>xmlfile</var> <var>table</var> <var>posfld</var> <var>reffld</var>
            [ /Delete ] [ /Tagged ]  [ /Attribute=<var>irefAttr</var> ]
             [ /Baseposition=<var>basePos</var> ] [ [[Programmer_Guide/Command_Reference_Options/Silent|/Ilent]] ]
             [ /Baseposition=<var>basePos</var> ] [ [[Programmer_Guide/Command_Reference_Options/Silent|/Ilent]] ]


Returns the internal reference (<code>IREF</code>) to the selected element or an empty string.
Here, <var>table</var> is your extended table. Both <var>posfld</var> and <var>reffld</var> must be the names of fields (i.e., columns) in your table <var>table</var>, <var>posfld</var> containing your file positions. The <code>IREF</code> command will store the ''iref'' for each position in the corresponding <var>reffld</var> entry. Note that you maye use the same field for <var>posfld</var> and <var>reffld</var>, but that this will cause the file positions ''to be deleted'', making it a shortcut for the <code>/Delete</code> flag.
 
;<var>xmlfile</var>
 
 
 
:The id of an XML file item.
 
;<var>/Format</var>
 
:This option is mandatory.
 
;<var>/I</var>
 
:If set, errors are suppressed, and warnings are generated instead.
 
<code><var>var</var> := IREF <var>xmlfile</var> <var>pos</var> /Format /Delete [ /I ]</code>
 
Returns the internal reference to the element at the position <var>pos</var> or an empty string. If /Delete is specified, the position is also deleted.
 
;<var>pos</var>
 
:The position of an element in the XML file <var>xmlfile</var>.
 
;<var>/Delete</var>
 
:This option is mandatory.
 
See the commands above for a description of the other parameters and options.
 
<code>IREF <var>xmlfile</var> <var>table</var> <var>posFld refFld</var> /Format /Delete /All|Tagged [ /I ]</code>
 
Stores the internal references to the element found at the positions in the field <var>posFld</var> in the field <var>refFld</var>. If /Delete is specified, or <var>posFld</var> is the same as <var>refFld</var>, then the positions are also deleted.
 
;<var>table</var>
 
:The id of an extended table.
 
;<var>posFld</var>
 
:The name of the field where the element positions are stored.
 
;<var>refFld</var>
 
:The name of the field where the IREFs should be stored. If this is the same as <var>posFld</var>, then the positions are deleted before being overwritten.


;<var>/All|Tagged</var>
;<code>/Delete</code>: If this option is supplied, or if <var>posFld</var> is the same as <var>refFld</var>, then the file positions are deleted.
;<code>/All|Tagged</code>: If the <code>/All</code> option is used, ''all'' table entries are used, be they tagged or untagged (this is the default). If, on the other hand, the <code>/Tagged</code> option is supplied, then only the tagged entries are used.


:If /All is specified, all table entries are used (this is the default). If /Tagged is specified, then only the tagged entries are used.
== Selecting an element ==


See the commands above for a description of the other parameters and options.
The <code>IREF</code> may also be used for positioning in a file, more precisely: for selecting an XML element identified by either an ''iref'', or by a file position. Note that, since ''iref'' strings start with a slash, extraordinary measures are needed not to have {{STX}} misunderstand an ''iref'' as a (possibly invalid) command option (see below).


<code>IREF <var>xmlfile</var> <var>iref</var>|<var>pos</var> /Select [ /I ]</code>
IREF /Select [ /Nocase ] [ /Attribute=<var>irefAttr</var> ] [ /Baseposition=<var>basePos</var> ]
      [ [[Programmer_Guide/Command_Reference_Options/Silent|/Ilent]] ] [[Programmer_Guide/Command_Reference_Options/-|/-]] <var>xmlfile</var> <var>iref</var> | <var>pos</var>


Select the element at the specified position (<var>pos</var>) or internal reference (<var>iref</var>).
Select the element at the specified position (<var>pos</var>) or internal reference (<var>iref</var>).


;<var>iref</var>
;<var>iref</var>
 
:The internal reference of an existing element. Note that, since an ''iref'' starts with a slash, you must take care of {{STX}} not mixing it up with a command option. To exert this kind of care, either put the iref under single quotes - e.g. <code>'<var>iref</var>'</code> -, or ''after'' the options, separated from them by the "end of options" option, [[Programmer_Guide/Command_Reference_Options/-|/-]].
:The internal reference of an existing element.
 
;<var>pos</var>
;<var>pos</var>
:The position of an existing element.
:The position of an existing element.
 
;<code>/Select</code>
;<var>/Select</var>
 
:This option is mandatory.
:This option is mandatory.
;<code>/Nocase</code>
:ignore case (normally, ''iref'' strings are case-sensitive)


Please not that you must surround the ref argument with single quotes, otherwise it will be interpreted as an option.
== Common Options ==


<pre>
;<code>[[Programmer_Guide/Command_Reference_Options/Silent|/Ilent]]</code>: The [[Programmer_Guide/Command_Reference_Options/Silent|silent option]] causes mishaps to be reported as warnings, instead of errors.
<code>IREF '$#f' '$#aset' /Select</code>
;<code>[[Programmer_Guide/Command_Reference_Options/-|/-]]</code>: With the "[[Programmer_Guide/Command_Reference_Options/-|end of options]]" option, you tell {{STX}} that there are no further options in the respective line of code. This means that any further arguments will be considered, well, plain arguments, even if they should start with a slash.
</pre>
;<code>/Attribute=</code><var>irefAttributeName</var>: normally, the attribute storing the ''iref'' path components is called <var>ID</var>. With the <code>/Attribute=</code> option, you may specify a different such attribute.
;<code>/Baseposition=</code><var>positionOfIrefBaseElement</var>: normally, an ''iref'' is considered absolute, i.e., starting at the root element of the respective XML file. With the <code>/Baseposition=</code> option, you may specify the position of a different element to be considered the root for the ''iref'' path.

Latest revision as of 11:20, 19 April 2017

The IREF command returns the internal reference (IREF) of the currently selected element of the supplied XML file item, or, if you provide additional element data, the internal reference for the respective element of the supplied XML file item. If this information is not available, or not applicable, the IREF command will return the empty string.

IREF of the currently selected element

The basic form of the IREF command retrieves the IREF of the currently selected element:

var := IREF xmlfile /Format
            [ /Attribute=irefAttr ] [ /Baseposition=basePos ] [ /Ilent ]

Note that the /Format option is mandatory.

IREF of an STx file position

When you supply an STx file position, position, the IREF command retrieves the IREF of the element whose position you supplied:

var := IREF xmlfile /Format position
            [ /Attribute=irefAttr ] [ /Baseposition=basePos ] [ /Ilent ]

In this case, the option /Delete will cause the STx position to be deleted. Note that here, too, the /Format option is mandatory.

Bulk processing

If you need to retrieve the internal references for a larger number of file positions, you may supply the respective positions in an STx extended table item. In this case, the iref for each position will be stored in a different field of the same table:

var := IREF xmlfile table posfld reffld
            [ /Delete ] [ /Tagged ]  [ /Attribute=irefAttr ]
            [ /Baseposition=basePos ] [ /Ilent ]

Here, table is your extended table. Both posfld and reffld must be the names of fields (i.e., columns) in your table table, posfld containing your file positions. The IREF command will store the iref for each position in the corresponding reffld entry. Note that you maye use the same field for posfld and reffld, but that this will cause the file positions to be deleted, making it a shortcut for the /Delete flag.

/Delete
If this option is supplied, or if posFld is the same as refFld, then the file positions are deleted.
/All|Tagged
If the /All option is used, all table entries are used, be they tagged or untagged (this is the default). If, on the other hand, the /Tagged option is supplied, then only the tagged entries are used.

Selecting an element

The IREF may also be used for positioning in a file, more precisely: for selecting an XML element identified by either an iref, or by a file position. Note that, since iref strings start with a slash, extraordinary measures are needed not to have STx misunderstand an iref as a (possibly invalid) command option (see below).

IREF /Select [ /Nocase ] [ /Attribute=irefAttr ] [ /Baseposition=basePos ]
     [ /Ilent ] /- xmlfile iref | pos

Select the element at the specified position (pos) or internal reference (iref).

iref
The internal reference of an existing element. Note that, since an iref starts with a slash, you must take care of STx not mixing it up with a command option. To exert this kind of care, either put the iref under single quotes - e.g. 'iref' -, or after the options, separated from them by the "end of options" option, /-.
pos
The position of an existing element.
/Select
This option is mandatory.
/Nocase
ignore case (normally, iref strings are case-sensitive)

Common Options

/Ilent
The silent option causes mishaps to be reported as warnings, instead of errors.
/-
With the "end of options" option, you tell STx that there are no further options in the respective line of code. This means that any further arguments will be considered, well, plain arguments, even if they should start with a slash.
/Attribute=irefAttributeName
normally, the attribute storing the iref path components is called ID. With the /Attribute= option, you may specify a different such attribute.
/Baseposition=positionOfIrefBaseElement
normally, an iref is considered absolute, i.e., starting at the root element of the respective XML file. With the /Baseposition= option, you may specify the position of a different element to be considered the root for the iref path.

Navigation menu

Personal tools