You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

This topic contains some example

Jackrabbit supports a subset of XPath 2.0 which is a subset of XQuery1.0.

queries that can be used in the [JCR browser]. See also JCR Browser for complete information and other examples.

  • All templates:
    //element(*, wm:template)
    
  • Template with ID = X:
    //element(*, wm:template)[@wm:templateid=1190]
    
  •  Siteworks object with ID = X:
    //element(*)[@wm:id=72430]
    
  • All objecttypes:
    //wm:webmanager//element(*, wm:objecttypeinfo)
    
  • Webpage item with Siteworks name 'Queries':
    //wm:webmanager/wm:websites/wo:webpage_item[@wm:name = 'Queries']
    
  • Webpage item with reference to node Siteworks object of objecttype itemtype and name '370eea2b4dcbba2700212ab636f5':
    wm:webmanager/wm:websites/wo:webpage_item/jcr:deref(@wo:itemtype, '370eea2b4dcbba2700212ab636f5')
    
  • JCR item with UUID '8d38de7b-cec9-4fd6-a714-65e1a61b5bba':
    //*[@jcr:uuid='8d38de7b-cec9-4fd6-a714-65e1a61b5bba']
    
  • All SiteWorks tasks:
    //element(*, wo:wm_taskmanager_task)
    
  • All pages, in descending name order
    //element(*, wo:ss_mastersection) order by @wm:name descending
    
  • All objects for given objecttype
    //element(*)[@jcr:primaryType='wo:personalization_expression']
    
  • All paragraph elements with text 'XX'
    //element(*, wo:ss_element_text ) [@wo:text='XX']
    
  • All objects of type X with property Y:
    //element(*, X)[@Y]
    
  • All objects of type X without property Y:
    //element(*, X)[not(@Y)]
    
  • Find nodes containing a property with value 'XX'
    //* [jcr:contains(@*,'XX')]
    
  • If you wish to find all elements - that use wo:text to save their data (rich text, paragraph, etc.) - containing 'XX'
    //* [jcr:contains(@wo:text,'*XX*')]
    
  • To see a list of WebManager language labels in the edit environment use the following query:
    //element(*, wo:wm_edit_language)
    
  • To see a list of all webinitiatives
    //element(*, wo:wm_webinitiatif)
    
  • To see a list of ss_element_external_content where "last X days" > 100 use the following query:
    //element(*, wo:ss_element_external_content) [@wo:lastxdays>100]
    
  • When comparing date properties, use the xs:dateTime function. Caution: JackRabbit only accepts a fully specified date, including the time in milliseconds:
    //element(*, wo:wm_content_info)[@wo:lastmodified < xs:dateTime('2008-01-01T00:00:00.000Z')]
    
  • Retrieving the meta data of a media item
    1. Get the exact type of the mediaitem: //wm:components
    2. Hex-code the first number in the media item contentid (e.g. for mediaitem 202209, encode '2' into 0032 via the [http://www.easycalculation.com/ascii-hex.php] site)
    3. Retrieve the meta data using //<exact-type>/allContainerNode/_x<hex>_restofnumber (e.g. //nl.gx.elsevier.elseviermediaitems.AbonneeMediaItemVersionImpl/allContainerNode/_x0032_02209
    
  • Find an link which refers to a page of nu.nl
    //element(*, wo:ss_element_internal_externallink)[jcr:like(@wo:URL,'http://www.nu.nl/%')]
  • Find pages which have a link that refers to a page of nu.nl
    //element(*, wo:ss_section)[jcr:like(wo:related/wo:URL,'http://www.nu.nl/%')]
  • Find articles (element holders) which have a link that refers to a page of nu.nl
    //element(*, wo:wm_element_holder)[jcr:like(wo:related/wo:URL,'http://www.nu.nl/%')]
  • Find page versions which have an preload form attribute

    //element(*, wo:ss_section)[@wo:preload_form]
  • All page versions containing an element containing the text 'XX'

    //element(*, wo:ss_section)[jcr:contains(wo:element/@wo:text,'*XX*')]
  • Find all pages which contain a specific element

    //element(*,wo:ss_section)[wo:element/@jcr:primaryType = 'mywcb:element']

     

Even though Jackrabbit uses the XQuery grammar, it only implements the set of XPath features required by JCR-170 (and some
extras, like predicates on location steps).

For more information about XPath see the documentation and software resources page

  • No labels