An XSP Logicsheet that's bundled with the Cocoon distribution (see also BuiltInLogicsheets)

It provides an XML syntax which is essentially a simple wrapper around session context provided by the session framework (session-fw block). See the official Session context documentation.


The namespace declaration of this logicsheet is: xmlns:xsp-session-fw="http://apache.org/xsp/session-fw/1.0"

Currently there is just one tag in the logicsheet: <xsp-session-fw:getxml>

<xsp-session-fw:getxml>

This tag allows read contexts data.

Attributes

  • context : The name of the context where the data resides.
  • path: describes the source of the data inside the context and consists of an XPath expression. All path values must be absolute and only nodes and attributes can be accessed.
  • as: It can have 3 values: string, object and xml. Default value: string.
    *as="string" (default) - returns the value of the given path as a String.
    *as="object" returns the value of the given path as an Object of type org.w3c.dom.DocumentFragment.
    *as="xml" returns the value of the given path as an org.w3c.dom.DocumentFragment. The root of the returned DocumentFragment is <xsp-session-fw:xml>

The idea of the default as="string" is to let you add easily inside your XSP some strings. i.e: to show the user name in a welcome page:

<p>Hi <xsp-session-fw:getxml
         context="authentication"
         path="/authentication/data/full_name"/>, welcome back to the System
</p>

In this example the path attribute always exists, so we don't need to test if the path really exists in the given session context.

If you need to test if the path exists, then use as="object", get the object and if the object is null, then there is nothing. Else the path exists so you can get it using as="string".

  • No labels