s1kd-uom(1) s1kd-tools s1kd-uom(1) NAME s1kd-uom - Convert units of measure in quantity data SYNOPSIS s1kd-uom [-dflqv,.h?] [-D ] [-F ] [-u -t [-e ] [-F ] ...] [-s |-S ...] [-U ] [-p [-P ]] [...] DESCRIPTION The s1kd-uom tool converts between specified units of measure in quan‐ tity data, for example, to automatically localize units of measure in data modules. OPTIONS -D, --duplicate-format Specify a custom format for duplicating quantities (-d). The '%' character acts as a placeholder for the duplicate quantity value. The default format for -d is equivalent to -D ' (%)'. -d, --duplicate When converting, instead of overwriting the original quantity, include the converted quantity after the original in parenthe‐ sis. For example, "200 mm" when converting mm to in would be‐ come "200 mm (7.87 in)". -e, --formula Specify the formula for a conversion, given as an XPath expres‐ sion. -F, --format Specify the format for quantity values. When used before -u, this specifies the default format for all conversions. Other‐ wise, this specifies the format for each individual conversion. Formats specified for individual conversions override the de‐ fault format set for all conversions. -f, --overwrite Overwrite input CSDB objects. -h, -?, --help Show help/usage message. -l, --list Treat input (stdin or arguments) as lists of filenames of CSDB objects to list references in, rather than CSDB objects them‐ selves. -P, --uomdisplay Use a custom .uomdisplay file. -p, --preformat Preformat quantity data to the specified decimal format. The built-in formats are: · SI - comma for decimal separator, space for grouping · euro - comma for decimal separator, full-stop for grouping · imperial - full-stop for decimal separator, comma for grouping -q, --quiet Quiet mode. Errors are not printed. -S, --set Apply a set of conversions defined in an XML file. -s, --preset Apply a set of predefined conversions. The available presets are: · SI - convert imperial/US customary units to SI units. · imperial - convert SI units to British imperial units. · US - convert SI units to US customary units. -t, --to Unit of measure to convert to. -U, --uom Use a custom .uom file. -u, --from Unit of measure to convert from. -v, --verbose Verbose output. -,, --dump-uom Dump the default .uom file. -., --dump-uomdisplay Dump the default .uomdisplay file. --version Show version information. CSDB objects to convert quantities in. In addition, the following options allow configuration of the XML pars‐ er: --dtdload Load the external DTD. --huge Remove any internal arbitrary parser limits. --net Allow network access to load external DTD and entities. --noent Resolve entities. --parser-errors Emit errors from parser. --parser-warnings Emit warnings from parser. --xinclude Do XInclude processing. --xml-catalog Use an XML catalog when resolving entities. Multiple catalogs may be loaded by specifying this option multiple times. .uom file This file contains the rules for converting units of measure. If no specific conversions are given with the -u and -t options, this file also acts as a list of all conversions to perform. By default, the program will search the current directory and parent directories for a file named .uom, but any file can be specified by us‐ ing the -U option. Example of a .uom file: The tool contains a default set of rules for common units of measure. This can be used to create a default .uom file by use of the -, option: $ s1kd-uom -, > .uom To select only certain common rules when generating a .uom file, the -u and -t options can be used: $ s1kd-uom -, -u in -t cm -u degF -t degC > .uom This will generate a .uom file containing rules to convert inches to centimetres, and degrees Fahrenheit to degrees Celsius. The same file format is used with the -S option to specify a set of conversions to perform. In this case, the attribute formula is option‐ al, as the default formula or the formula in the .uom file will be used if it is not specified. Conversion formula variables (-e) When specifying a formula for conversion, the following variables can be used: $pi The constant π $value The original quantity value For example, the formula to convert degrees to radians can be given as follows: $value * ($pi div 180) Preformatting UOMs (-p) and the .uomdisplay file The tool can also convert semantic quantity data to presentation quan‐ tity data. The -p option specifies which conventions to use for for‐ matting quantity values. For example: Tighten the 6.35 bolt. $ s1kd-uom -p SI Tighten the 6,35 cm bolt. This can also be combined with UOM conversions: $ s1kd-uom -u cm -t in -p imperial Tighten the 2.5 in bolt. Custom formats for values or UOMs can be defined in the .uomdisplay file. By default, the tool will search the current directory and par‐ ent directories for a file named .uomdisplay, but any file can be spec‐ ified by using the -P option. Example of a .uomdisplay file: cm cm2 $ CAD £ GBP Units of measure and currencies that are not defined will be presented as their name (e.g., "cm2") separated from the value by a space. More complex UOM display, such as pluralization of units of measure, can be accomplished with embedded XSLT in the .uomdisplay file: inch inches foot feet The context for the embedded XSLT is the unit of measure attribute on the value, tolerance or group. XSLT elements in the element will be processed for all units of measure, while XSLT elements in elements will only apply to an individual unit of measure. The tool contains a default set of formats and displays. These can be used to create a default .uomdisplay file by use of the -. option: $ s1kd-uom -. > .uomdisplay EXAMPLES Common units of measure Input: 15 Command: $ s1kd-uom -u cm -t in Output: 5.91 Using a custom formula and format Input: 10.00 Command: $ s1kd-uom -u CAD -t USD -e '$value div 1.31' -F '0.00' Output: 7.36 UOM FILE SCHEMA UOM Markup element: Attributes: · format (O), the number format for all rules. Child elements: · Conversion rule The element defines a rule to convert one unit of measure to another. Markup element: Attributes: · format (O), the number format for this specific rule. · formula (M), the expression used to convert the quantity value. · from (M), unit of measure to convert from. · to (M), unit of measure to convert to. Child elements: · None UOMDISPLAY FILE SCHEMA UOM display Markup element: Attributes: · None Child elements: · · · · · Quantity value format Markup element: Attributes: · name (M), the name of the format · decimalSeparator (M), the decimal separator · groupingSeparator (M), the grouping separator Child elements: · None Group type prefixes The element specifies prefixes which are added for specific group types. Markup element: Attributes: · None Child elements: · , text placed before a nominal group. · , text placed before a minimum group. · , text placed before a minimum group that is followed by a maximum group to specify a range. · , text placed before a maximum group. · , text placed before a maximum group that is preceded by a minimum group to specify a range. Wrap into element Markup element: Attributes: · None Child elements: The element contains one child element of any type, which quantities will be wrapped in to after formatting. Units of measure Markup element: Attributes: · None Child elements: · The element may also contain arbitrary XSLT elements which will be processed for all units of measure. Display of a unit of measure Markup element: Attributes: · name (M), the name of the UOM. Child elements: The element may contain mixed content, which will be used for the display of the unit of measure. This can include XSLT elements, which allows for handling complex cases of UOM display, such as pluraliza‐ tion. Currencies Markup element: Attributes: · None Child elements: · The element may also contain arbitrary XSLT elements which will be processed for all currencies. Display of a currency Markup element: Attributes: · name (M), the name of the currency. Child elements: · , text placed before the currency value. · , text placed after the currency value. The child elements of may contain mixed content, which will be used for the display of the unit of measure. This can include XSLT elements, which allows for handling complex cases of currency display. AUTHORS khzae.net. 2021-04-16 s1kd-uom(1)