require('uxp').xmp.XMPUtils
Since: v7.2.0
XMPUtils()
This class provides additional utility functions for the XMP Toolkit, layered upon the functionality of the XMPMeta object. It has only static functions, you cannot create an instance.
Path-composition functions such as composeArrayItemPath(), provide support for composing path expressions to deeply nested properties, which you can then pass to the accessor functions in XMPMeta object, such as xmpmetaobj-getProperty.
Higher-level functions such as xmputils-duplicateSubtree allow you to manipulate the metadata tree in an XMPMeta object.
appendProperties(source, dest, [options])
Copies properties from a source XMPMeta object and appends them to a destination XMPMeta object.
number0Example
XMPUtils.appendProperties(source, dest, options)
catenateArrayItems(xmpObj, schemaNS, arrayName, [separator], [quotes =], [options])
Concatenates a set of array item values into a single string. The resulting string can be separated back out into array items using separateArrayItems().
Returns: string - the concatenated string.
stringstring";"stringnumber0Example
XMPUtils.catenateArrayItems(xmpObj, schemaNS, arrayName, separator, quotes, options)
composeArrayItemPath(schemaNS, arrayName, itemIndex)
Creates and returns a string containing the path expression for an item in an array, using the registered prefix for the namespace, in the form: schemaNS:arrayName[itemIndex]
Returns: string - a string containing the path expression for an item in an array.
stringnumberExample
XMPUtils.composeArrayItemPath(schemaNS, arrayName, itemIndex)
composeFieldSelector(schemaNS, arrayName, fieldNS, fieldName, fieldValue)
Creates and returns a string containing the path expression to select an alternate item by a field’s value, using the registered prefixes for the namespaces, in the form: schemaNS:arrayName[fieldNS:fieldName='fieldValue']
Returns: string - a string containing the path expression to select an alternate item by a field’s value.
stringstringstringstringExample
XMPUtils.composeFieldSelector(schemaNS, arrayName, fieldNS, fieldName, fieldValue)
composeLangSelector(schemaNS, arrayName, locale)
Creates and returns a string containing the path expression to select an alternate item in an alt text array by language, using the registered prefix for the namespace, in the form: schemaNS:arrayName[@xml:lang='langName']
Returns: string - a string containing the path expression to select an alternate item in an alt text array by language.
Note: Do not use this in place of getLocalizedText() or setLocalizedText(). Those functions provide extra logic to choose the appropriate language and maintain consistency with the x-default value. This function provides a path expression for an explicit language, and only for that language.
stringstringExample
XMPUtils.composeLanguageSelector(schemaNS, arrayName, locale)
composeStructFieldPath(schemaNS, structName, fieldNS, fieldName)
Creates and returns a string containing the path expression for a field in a structure, using the registered prefixes for the namespaces, in the form: schemaNS:structName/fieldNS:fieldName
Returns: string - a string containing the path expression for a field in a structure.
stringstringstringExample
XMPUtils.composeStructFieldPath(schemaNS, structName, fieldNS, fieldName)
composeQualifierPath(schemaNS, propName, qualNS, qualName)
Creates and returns a string containing the path expression for a qualifier attached to a property, using the registered prefix for the namespace, in the form: schemaNS:propName/?qualNS:qualName
Returns: string - a string containing the path expression for a qualifier attached to a property.
stringstringstringExample
XMPUtils.composeQualifierPath(schemaNS, propName, qualNS, qualName)
duplicateSubtree(source, dest, sourceNS, sourceRoot, destNS, [destRoot], [options])
Copies properties in the specified subtree from a source XMPMeta object and adds them into a destination XMPMeta object.
stringstringnumber0Example
XMPUtils.duplicateSubtree(source, dest, sourceNS, sourceRoot, destNS, destRoot, options)
removeProperties(xmpObj, [schemaNS], [propName], [options])
Removes multiple properties from an XMPMeta object.<br></br><br></br> If both the namespace and property name are supplied, removes the property if it is external, even if it is an alias.<br></br> If it is internal, removes it if the option XMPConst.REMOVE_ALL_PROPERTIES is specified.<br></br><br></br> If the namespace is supplied and the property name is not, removes all external properties in the namespace,<br></br> and optionally all internal properties. Removes aliases only if the option XMPConst.REMOVE_INCLUDE_ALIASES is specified.<br></br><br></br> If neither the namespace nor the property name are supplied, removes all external properties, and optionally all internal properties.<br></br> Aliases are handled implicitly, because the associated actual is removed.
stringstringnumber0Example
XMPUtils.removeProperties(xmpObj, schemaNS, propName, options)
separateArrayItems(xmpObj, schemaNS, arrayName, [arrayOptions], concatString)
Updates individual array item strings in the XMPMeta object from a concatenated string returned by catenateArrayItems(). Recognizes a large set of separator characters, including semicolons, commas, tab, return, linefeed, and multiple spaces.
stringnumber0stringExample
XMPUtils.separateArrayItems(xmpObj, schemaNS, arrayName, arrayOptions, concatString)