Versions Compared

Key

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


Info

The censhare XPath queries are executed on server side.

cs:get-asset

Returns the asset XML of given asset defined by given asset ID, asset version (optional), asset current version (optional), transaction control number (optional). With given TCN the asset can be fetched from the embedded database without checking if it’s up to date.

The asset XML is only read from the server (can be viewed with the RMI protocol) if the local asset cache of the censhare client doesn‘t have this asset.

cs:get-asset(12345)
     returns the asset XML of the current version of the asset with ID 12345
 
cs

-new-markdownAudiencepublicVersionReleases/2020

:get-asset(12345, 0)
    returns the asset XML of the current version of the asset with ID 12345
 
cs:get-asset(12345, 3)
     returns the asset XML of version 3 of asset with ID 12345
 
cs:get-asset(12345, 0, -2)
    returns the asset XML of the checked-out version of the asset with ID 12345
 
cs:get-asset(12345, 0, 0, 17)
    returns the asset XML of the current version of the asset with ID 12345
    with at transactional control number >= (TCN) 17.

cs:get-asset-versions

Returns the asset XML of all versions of given asset defined by given asset ID. (Since censhare 4.4).

Example

cs:get-asset-versions(12345)
    returns the asset XML of all versions of the asset with ID 12345

cs:asset

Returns asset nodes of found assets as sequence defined by given search query.
Every searchable asset feature can be used with its key in the search query.
Results are always current versions. (Since censhare 4.6).

Optional string parameter (comma separated)

  • sql=true forces a query in the Oracle database instead of using the embedded database engine.
  • limit defines the maximal number of results, e.g. limit=10
  • offset defines the start index of the query result, e.g. offset=10

      Examples
     cs:asset('limit=20')[@censhare:asset.name = 'test']
        returns XML of the first 20 assets whose name is "test"
 
     cs:asset()[@censhare:asset.name like 'test*']
        returns XML of assets whose name starts with "test"
 
     cs:asset('sql=true,limit=10')[@ censhare:text.meta = 'test']
         returns XML searched in the Oracle database of the first 10 assets whose meta data contains "test"
 
     cs:asset()[@censhare:asset.type = 'picture.' and @censhare:text.meta = 'test']
        returns XML of assets whose type is picture and meta data contains “test”
 
cs:asset as an additional location step of a sequence of asset nodes or a sequence of asset IDs acts as an additional filter
 
     Examples
     asset/cs:asset()[@censhare:text.meta = 'test']
        returns a sequence of filtered asset nodes of current asset nodes whose meta data contains "test"
 
     (12345, 12346)/cs:asset()[@censhare:text.meta = 'test']
        returns a sequence of filtered asset nodes of assets with ID 12345 and 12346 whose meta data contains "test"
 
     cs:asset()[@censhare:asset.type = 'picture.']/cs:asset()[@censhare:text.meta = 'test']
         returns asset nodes whose type is picture and whose meta data contains "test".
 
     This example is possible, but more efficient would be
     cs:asset()[@censhare:asset.type = 'picture.' and @censhare:text.meta = ‘test’]”

XPath filters like [1] on cs:asset functions can result in unexpected results. Instead of cs:asset()[@censhare:text.meta = 'test'][1] the following syntax must be used: (cs:asset()[@censhare:text.meta = 'test'])[1] instead.

XSLT example using a query element:

< xsl:variable name = "query" >
   < query limit = "100" >
     < condition name = "censhare:asset.currversion" value = "0" />
   </ query >
</ xsl:variable >
< xsl:for-each select = "assets/asset" >
   < xsl:variable name = "assetid" select = "@id" />
   < xsl:variable name = "copy" >
     < xsl:copy-of select = "cs:asset($query)[@censhare:asset.id=$assetid]" />
   </ xsl:variable >
</ xsl:for-each >

cs:asset-id

This function queries for assets and works exactly the same as the existing function cs:asset (the query conditions are also provided by XPath predicates). Their only difference, is that cs:asset-id returns the asset IDs instead of the entire XMLs of the found assets. Even though the result is the same as when using (cs:asset(...)[...])/@id, as best practice for performance, we highly recommend using this function when only asset IDs are needed.

Optional string parameter (comma separated):

  • sql=true - It forces a query in the Oracle database instead of using the embedded database engine.
  • limit - It defines the maximal number of results, e.g. limit=10.
  • offset - It defines the start index of the query result, e.g. offset=10.

Examples:
     cs:asset-id()[@censhare:asset.name = 'test']
         This returns a sequence of the IDs of all the assets with name "test".
 
     cs:asset-id('limit=3')[@censhare:asset.name = 'test']
         This returns a sequence (e.g. 10000 10001 10002) of the first 3 IDs of the assets with name "test".
 
     cs:asset-id('sql=true')[@censhare:asset.type = 'picture.']
         This returns a sequence of the IDs of all the assets with type "picture." searched in the Oracle database.
 
cs:asset-id as an additional location step of a sequence of asset nodes or a sequence of asset IDs acts as an additional filter:
     It is possible as for cs:asset but it doesn't make sense here because the IDs are already given directly or can be received via attribute step.

cs:parent-rel

Returns asset nodes of parent related assets filtered by given search query for asset relation types. Source can be a sequence of asset nodes or a sequence of asset IDs. The relation type can be defined in the search query. Results are always current versions.

WARNING this performs a more or less expensive database query. Use standard XPath axis traversal if the asset XML is already known.

Examples
(12345, 12346)/cs:parent-rel()[@key = 'user.']
     returns a sequence of parent related (type "user") asset nodes of assets with IDs 12345 and 12346
 
/asset/cs:parent-rel()[@key = 'user.']
     returns a sequence of parent related (type "user") asset nodes of current asset nodes

cs:child-rel

Returns asset nodes of child related assets filtered by given search query for asset relation types. Source can be a sequence of asset nodes or a sequence of asset IDs. The relation type can be defined in the search query. Results are always current versions

WARNING: This performs an expensive database query. Use standard XPath axis traversal if the asset XML is already known!

Examples
(12345, 12346)/cs:child-rel()[@key = 'user.']
     returns a sequence of child related (type "user") asset nodes of assets with IDs 12345 and 12346
 
/asset/cs:child-rel()[@key = 'user.']
     returns a sequence of child related (type “user”) asset nodes of current asset nodes

cs:any-rel

Returns asset nodes of parent or child related assets filtered by given search query for asset relation types. Source can be a sequence of asset nodes or a sequence of asset IDs. The relation type can be defined in the search query.
Results are always current versions.

WARNING: This performs an expensive database query. Use standard XPath axis traversal if the asset XML is already known!

Examples
(12345, 12346)/cs:any-rel()[@key = 'user.']
     returns a sequence of parent and child related (type “user”) asset nodes of assets with ID 12345 and 12346
 
/asset/cs:any-rel()[@key = 'user.']
     returns a sequence of parent and child related (type “user”) asset nodes of current asset nodes

cs:order-by

Returns asset nodes of asset nodes out of a cs:asset, cs:parent-rel, cs:child-rel or cs:any:rel function ordered by given asset features.

Multiple sort asset features can be added comma separated. Descend sorting can be defined with a leading “-” at the asset feature.

Examples
asset/cs:child-rel()[@key='user.']/cs:order-by()[@censhare:asset.name]
     returns user child related asset nodes of current asset nodes ordered by the asset name
 
asset/cs:child-rel()[@key='user.']/cs:order-by()[@censhare:asset.type, -@censhare:asset.name]
     returns user child related asset nodes of current asset nodes ordered first by the ascending asset types and following ordered descending asset names

Complex exmaple for cs:parent-rel, cs:child-rel, cs:any-rel, cs:order-by

Example
/asset/cs:any-rel()[@key = 'user.author.']/cs:asset()[@censhare:asset.type = 'person.']/cs:child-rel()[@key = 'user.main-picture.']/cs:asset()[@censhare:asset.type = 'picture.']/cs:order-by()[@censhare:asset.name]
     returns master-image child related assets of type picture of assets of type author who are author parent or child related to the current asset nodes ordered by asset name

cs:feature-ref

Returns asset nodes of all assets which asset reference features references to the source assets. Source can be a sequence of asset nodes or a sequence of asset IDs.
The feature key can be defined in the filter part. Results are always current versions. (Since censhare 4.8).

Examples
(12345, 12346)/cs:feature-ref()[@key = 'censhare:input-form']
    returns a sequence of asset nodes whose asset feature with key 'censhare:input-form'reference to the assets with ID 12345 and 12346
 
/asset/cs:feature-ref()[@key = 'censhare:copy-template']
     returns a sequence of asset nodes whose asset feature with key 'censhare:copy-template' reference to the current asset nodes

cs:feature-ref-reverse

Returns asset nodes of all assets which are referenced by asset reference features from the source asset to other assets (reverse version of cs:feature-ref). Source can be a sequence of asset nodes or a sequence of asset IDs. The feature key can be defined in the filter part. Results are always current versions. (Since censhare 4.8)

Examples
(12345, 12346)/cs:feature-ref-reverse()[@key = 'censhare:input-form']
    returns a sequence of asset nodes who are referenced by the asset features with key 'censhare:input-form' from the assets with ID 12345 and 12346
 
/asset/cs:feature-ref-reverse()[@key = 'censhare:copy-template']
    returns a sequence of asset nodes who are referenced by the asset feature with key 'censhare:copy-template' from the current asset nodes

cs:count-assets

Returns the number of assets in the query result of the given query.
The query definitions are identical to cs:asset.

Example
cs:count-assets()[@censhare:asset.type = 'article.']
    returns the number of assets of type article.

cs:resource-asset

Returns asset nodes of found resource assets as sequence defined by the given search query.
The query definitions are identical to cs:asset, but the permission rules for the master data are applied to access resource assets. The results are always the assets’ current versions.

Optional string parameters (comma separated):

  • sql=true: forces a query in the Oracle database instead of using the embedded database engine.
  • limit: defines the maximal number of results, e.g. limit=10.
  • offset: defines the start index of the query result, e.g. offset=10

Example
cs:resource-asset()[@censhare:resource-key = 'censhare:workspace.page.default']
     returns the resource asset with the key 'censhare:workspace.page.default'

cs:count-resource-assets

Returns the number of assets in the query result of the given query.
The query definitions are identical to cs:asset, but the permission rules for the master data are applied to access resource assets.

Example
cs:count-resource-assets()[@censhare:asset.type = 'module.keyword.']
    returns the number of resource assets of type keyword.

cs:localized-master-data

This function is similar to cs:master-data but with additional locale parameter to get the master data in the given locale.

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

Parameters

  • Locale - lowercase two-letter ISO-639 language code (required)
  • Table name of master data (required)
  • Domain access list, (optional)

Examples
   cs:localized-master-data('en', 'asset_typedef')[@asset_type='article.']/@name
   returns "Article"
 
   cs:localized-master-data('de', 'asset_typedef')[@asset_type='article.']/@name
   returns "Artikel"

Important note: This function is not available on the client side, but can only be executed on the server.

cs:get-resource-asset

This function retrieves the full asset XML of an asset given its resource key.

cs:get-resource-asset(key)

Parameters:

  • Asset resource key

Example:
    cs:get-resource-asset('censhare:workspace.page.productSupplierItem')
    Returns the full asset XML of asset with resource key 'censhare:workspace.page.productSupplierItem'

Filexpath-queries



Page properties
hiddentrue


iconrelated-topics

Cs related topics