Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

cs

-new-markdown

:decode-base64

Returns decoded string of given Base64 encoded string.

cs:decode-base64($arg as xs:string) as xs:string

Example:

:cs:decode-base64('VGhpcyBpcyBhIHRlc3Q=')
-> "This is a test"

cs:encode-base64

Returns Base64 encoded string of given string.

cs:encode-base64($arg as xs:string) as xs:string

Example:

:cs:encode-base64('This is a test')
-> "VGhpcyBpcyBhIHRlc3Q="

cs:encode-base64-url

Returns Base64 encoded string of result of given resource URL.

cs:encode-base64-url($url as xs:string, $maxlength as xs:long?) as xs:base64Binary

Example:

cs:encode-base64-url('censhare:///service/resources/icon/add-to-basket/file')
-> "iVBORw0KGgoAAAAN..."

cs:equal-values

If all values of arg1 are equal, returns true, otherwise returns false
If all values of arg1 are equal, return this single value, otherwise returns arg2.
If all values of arg1 are equal, returns arg2, otherwise returns arg3.

cs:equal-values($arg1 as xs:anyAtomicType*) as xs:boolean
cs:equal-values($arg1 as xs:anyAtomicType*, $arg2 as xs:anyAtomicType) as xs:anyAtomicType*
cs:equal-values($arg1 as xs:anyAtomicType*, $arg2 as xs:anyAtomicType, $arg2 as xs:anyAtomicType) as xs:anyAtomicType*

Example:

cs:equal-values(('a', 'a'))
-> true
cs:equal-values(('a', 'a'), 'different')
-> "a"
cs:equal-values(('a', 'a'), 'equal', 'different')
-> "equal"

cs:escape-html

Escape characters to be HTML conform (e.g. “&” will be replaced by “&”).

cs:escape-html($arg as xs:string?) as xs:string

Example:

cs:escape-html(‘Look&Feel’)
-> Look&Feel

cs:evaluate

Parse and evaluate xpath expression, parameters are available as variables $p1 … $pn.

cs:evaluate($xpath as xs:string [, $paramN as item()*]*) as item()*

Example:

cs:evaluate('1+1')
-> 2
cs:evaluate('current-dateTime() + xs:dayTimeDuration(''P1D'')')
-> 2016-05-07T09:49:28.347Z

cs:format-date

Format date (with time) using Java SimpleDateFormat with given pattern or format date (with time) using a format name:

  • Date: none, short, long, relative-short, relative-long
  • Time: none, short, long

Compare with http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

cs:format-date($value as xs:dateTime, $format as xs:string) as xs:string
cs:format-date($value as xs:dateTime, $dateFormat as xs:string, $timeFormat as xs:string) as xs:string

Example:

cs:format-date(xs:dateTime('2013-12-31T19:20:00'), 'EEE, d MMM yyyy HH:mm:ss Z’)
-> “Di, 31 Dez 2013 20:20:00 +0100”
cs:format-date(xs:dateTime('2012-01-08T19:20:00'), 'relative-short', ‘short’)”
-> “Yesterday, 8:20 PM” (assuming that was yesterday)

cs:format-number

Format number using Java NumberFormat or Java DecimalFormat. Compare with http://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html

cs:format-number($value as xs:anyAtomicType, $format as xs:string?) as xs:string

Example:

cs:format-number(123.12345, ‘#,###0.00’)
-> "123,12"

cs:localized-format-number

Similar to cs:format-number. It adopts the decimal and thousand separators of the value based on the defined languageCode.

cs:localized-format-number($languageCode as xs:string, $value as xs:anyAtomicType, $format as xs:string?) as xs:string

Example:

cs:localized-format-number('en', $assetFeature/@value_double, '#,##0.0') )
-> 12.3
cs:localized-format-number('de', $assetFeature/@value_double, '#,##0.0') )
-> 12,3

cs:localized-format-date

Returns a formatted string of a given dateTime with a given pattern in the given language.

cs:localized-format-date($languageCode as xs:string, $value as xs:dateTime, $format as xs:string) as xs:string
cs:localized-format-date($languageCode as xs:string, $value as xs:dateTime, $dateFormat as xs:string, $timeFormat as xs:string) as xs:string

Parameters:

Example:
   cs:localized-format-date('de', xs:dateTime('2013-12-31T19:20:00'), 'EEE, d MMM yyyy HH:mm:ss Z')
       returns: "Di, 31 Dez 2013 20:20:00 +0100"

cs:has-asset-permission

This function can be used to check the access permissions of the current user on a set of assets.

The function returns true if for all given assets the current user has at least one of the required permissions.

Note that the given permissionKeys are checked on an “OR” basis. This means, only one (any) of the given permissions is required. This allows to query for “hierarchical” permissions, like ('app_layout_editor_all', 'app_layout_editor_readonly').

Additionally, note that the global admin permission “all” (“God” permission) is always checked by this method. Hence, it is not necessary to specify the permission “all” explicitly in the permission keys parameter.

(Since censhare 2017.5.0)

Syntax:

cs:has-asset-permission($assetIDs as xs:integer*, $permissionKeys as xs:string*) as xs:boolean
cs:has-asset-permission($assets as node()*, $permissionKeys as xs:string*) as xs:boolean

Examples:

Check if the current user has the permission to open (check-out) the asset with ID 10000:

cs:has-asset-permission(10000, 'asset_checkout')

Check if the current user has the right to use the Layout Editor at least in read-only mode on all the assets given as IDs:

cs:has-asset-permission((10000, 10001, 13002), ('app_layout_editor_all', 'app_layout_editor_readonly'))

Check if the current user has the right to open all the assets returned by the XPath selector ‘/asset’ at least in read-only mode:

cs:has-asset-permission(/asset, ('asset_checkout', 'asset_checkout_readonly'))

Check if the current user has the right to export the meta data of all the assets, which are given in the variable $assets. The variable may contain a list of asset XML nodes or asset IDs:

cs:has-asset-permission($assets, ('asset_export_all', 'asset_export_metadata'))

cs:hash

Creates hash of given string with given algorithm, default algorithm is ‘MD5’.

cs:hash($arg as xs:string, $algorithm as xs:string?) as xs:hexBinary

Example:

cs:hash('This is a test')
-> "CE114E4501D2F4E2DCEA3E17B546F339"
cs:hash('This is a test', 'MD5')
-> "CE114E4501D2F4E2DCEA3E17B546F339"
cs:hash('This is a test', 'SHA-1')
-> "A54D88E06612D820BC3BE72877C74F257B561B19"

cs:make-filename

Normalize a string so that it is a valid file name. Strips leading, trailing and double white space, non printable characters, replaces illegal characters with “_” and limits length.
(Since censhare 4.10.0).

cs:make-filename($arg as xs:string, $len as xs:integer) as xs:string

Example:

cs:make-filename('<This is *a: //test//', 128)
-> "_This is _a_ __test__"

cs:master-data

The function cs:master-data can be used to access master data (cached table entries) according to a given table name. The returned XML contains locale independent attributes names (e.g. “name” instead of “name_de”) and values corresponding to the current locale of the logged in user. Additionally, the entries can be filtered by a given list of alternating domains (domain and 2. domain).
(Since censhare 4.5.0).

cs:master-data($tableName as xs:string) as node()*
cs:master-data($tableName as xs:string, $domainList as xs:string*) as node()*

Examples:

cs:master-data('party')
    Returns all entries in the party table (not filtered) as node list.
cs:master-data('party')[@id=100]
    Returns the party record with ID 100. Should do a lookup by primary key.
cs:master-data('party')[@name='Smith']
    Returns all parties with name "Smith" (as node list).
cs:master-data('party')[@name='Smith' and @firstname='John']
    Returns all parties with name "Smith" and first name "John" (as node list).
cs:master-data('party', ('root.a.', 'root.b.'))
    Returns all entries in the party table as node list, filtered by domain1 "root.a." and domain2 "root.b.".
cs:master-data('party', ('root.a.', 'root.b.', 'root.c.', 'root.d.'))[@name='Smith']
    Returns all entries in the party table with name "Smith", filtered by domain1 "root.a." and "root.c." and domain2 "root.b." and "root.d.".
cs:master-data('party', (asset/@domain, asset/@domain2))
    Returns all entries in the party table, filtered by domain1 "asset/@domain" and domain2 "asset/@domain2".
cs:master-data('party', cs:user-domains(140))
    Returns all entries in the party table, filtered by the domains of user with id 140.

  • Domain filtering in detail

The cs:master-data function can contain a list of pairs of domains (alternating domain1 and domain2) as second argument. If more than one pair of domains is given, then the returned table records have to match only one such pair. That means, cs:master-data(n, ((d1, d2), (e1, e2))) and cs:master-data(n, (d1, d2)) union cs:master-data(n, (e1, e2)) are returning the same records (where n is the name of the table, d1 and e1 the domain1 strings and d2 and e2 domain2 strings).

Furthermore it is important to know, that the returned records of cs:master-data(n, (d1, d2)) always match the domain1 d1 and match the domain2 d2. In general (general rule), “matching the domain” means, the domain of the record is exactly the given domain or it is a domain above (any ancestor in the domain tree) . For example, the record r matches the domain1 root.a.b.c., iff the domain1 of r is root.a.b.c., root.a.b., root.a. or root.

There are, however, master data tables where a special filtering is applied. The decision if a record matches the given domain, is then more complex. In the following all exception rules are listed in detail.

workflow step: a workflow step matches the domain d, if the workflow, where the step belongs to (defined by wf_id), matches d according to the general rule.

party: if a domain filtering is applied (a domain pair argument is given), all party records are filtered out which are inactive (isactive=false). From the remaining party records, these are returned, which have an arbitrary party_role (party_role with corresponding party_id) matching the given domains (according to the general domain matching rule). Additionally, the group parties (isgroup=true) are returned of which the main_domain/main_domain2 is matching (according to general rule) the given domains.

domain: for a given domain pair argument (d1, d2), a record r of table domain is returned, if r is exactly the domain d1 or if r is an ancestor of d1 or if r is a descendent of d1. For example, for domain d1=root.a.b. the domains root.a.b., root.a., root., root.a.b.c are returned but not the domain root.a.x.c.

domain2: analog to domain table (d2 is considered from domain pair (d1, d2)).

user_param: if a domain filtering is applied, first of all the user_param records are filtered according to the general domain filtering rule. From these remaining records then the following records are returned: all records which have no party_id (party_id=null) and all records which are “related to the current user”. A user_param r is related to the current user u, if the party_id of r is equal to the id of the current user or if a party p exists which has the current user as child and its id is equal to party_id (r.party_id = u.id or (u is child of p and r.party_id = p.id)).

feature_value: if a domain filtering (d1, d2) is applied, first of all the feature_value records are filtered according to the general domain filtering rule. From these remaining records then the records are filtered out, which belong to a non-matching (according to general rule) feature. Furthermore, from these remaining records the hierarchical records (is_hierarchical=true) are filtered out, which have any parent feature_values with corresponding non-matching (according to general rule) feature.

cs:parse-dateTime

Returns value of type xs:dateTime of given string parsed by given format.

Compare with http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

cs:parse-dateTime($value as xs:dateTime, $format as xs:string) as xs:string
 
Example:
:cs:parse-dateTime('2016-04-16', 'yyyy-MM-dd')
-> 2016-04-15T22:00:00Z

cs:user-domains

The function cs:user-domains can be used for receiving all domains (domain and 2. domain) of a user (party) according to a given party id. An alternating list of domains is returned (e.g. root.a., root.b., root.a.aa., root.b.bb. for domain root.a. and root.a.aa. and 2. domain root.b. and root.b.bb.).
(Since censhare 4.5.0).

cs:user-domains($partyId as xs:integer) as node()*
 
Example:
cs:user-domains(100)
-> [root.a, root.b, ...]
cs:user-domains(fn:system-property('censhare:party-id'))
    Returns all domains of the current user.

cs:current-time-millis

Returns current time in milliseconds (since 1.1.1970 00:00:00 UTC). Useful for performance measurements.

cs:current-time-millis() as xs:long
 
Example:
cs:current-time-millis()
-> 1462528535968

cs:nano-time

Return the current value of the most precise available system timer, in nanoseconds.

cs:nano-time() as xs:long
 
Example:
cs:nano-time()
-> 1462528595819710000

cs:match-asset-rel-type

Evaluates allowance of given relation type between given assets
Returns “true” if given asset relation type is allowed between given assets

Parameters

  • Asset relation type as string
  • Parent asset as XML node (if null then only child asset is evaluated)
  • Child asset as XML node (if null then only parent asset is evaluated). (Since censhare 4.5).

Example:
match-asset-rel-type('user.author.', $parentAsset, $childAsset)
    returns “trueif asset relation of type “user.author.” is allowed between parent asset of variable $parentAsset and child asset of variable $childAsset

cs:get-asset-resources

The function cs:get-asset-resources can be used to query entries of the master data table “resource_asset”. Records of resource assets, which can be applied to given source and target asset, are returned as result. The parameter “source asset” is required. The second parameter “target asset” is optional. (Note: If you want to query resource assets without providing a source asset, you can use function cs:master-data instead.)
(Since censhare 4.7.6).

The following conditions are used to filter the result:

  • Domain visibility: Only entries, which are either in the same domain as the source asset or in a domain above, are returned.
  • If a source filter is specified on a resource asset, it must accept the given source asset.
  • If a target filter is specified on a resource asset, it must accept the target asset if given.

cs:get-asset-resources($sourceAsset as node() [, $targetAsset as node()]) as node()*

Filters

The function can be followed by an optional XPath filter predicate, e.g. @type=‘module.transformation.’.

The following filter attributes are accepted:

  • @censhare:resource-usage: Filter by resource usage
  • @censhare:resource-key: Filter by resource key (same as @key)
  • @censhare:asset.type: Filter by asset type (same as @type)
  • @attrName: Filter by column “attrName” of table resource_asset, e.g. “@type”, “@key”

Only simple “And” expressions in the following form are supported: predicate

Examples

cs:get-asset-resources(asset)[@censhare:resource-usage='censhare:article-editor-asset-search']
    Gets all resource assets with usage "Article editor asset search".
cs:get-asset-resources(asset)[@type='module.transformation.']
    Gets all resource assets of type "transformation".
cs:get-asset-resources(asset)/.[@type='module.transformation.' and xmldata/target-formats/format/@mimetype='application/vnd.adobe.incopy-icml']
    Gets all transformations, which produce "ICML".

AudiencepublicVersionReleases/2019Filexpath-cs-extensions



Page properties
hiddentrue


iconrelated-topics

Cs related topics