Uploaded image for project: 'Cocoon'
  1. Cocoon
  2. COCOON-1523

[PATCH] XSP expressions (attribute value/text interpolation)


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.8
    • Fix Version/s: None
    • Component/s: Blocks: XSP
    • Labels:
    • Environment:
      Operating System: other
      Platform: Other
    • Bugzilla Id:


      In [1] in we discussed an XSP expression syntax for attribute value and text
      expressions. This patch makes expressions available.

      In XSP, you now can write:
      <elem attrib="{#expression}" which will be expanded to:
      <elem>Hello #user.getFullName</elem>, which will be expanded to <elem>Hello

      Writing {##text} will prevent expansion and will be replaced by the text
      "{#text}". Inside expressions, write "##" to get "#" and "#}" to get "}".

      This works in XSPs as well as logicsheets. The '#' was chosen out of the
      discussed characters because it is IMO least likely to occur in an expression in
      the used languages.

      This feature is turned on by default and can be turned off by setting
      "attribute-value-interpolation" or "text-interpolation" to "false" in cocon.xconf:

          <xsp-language ... attribute-value-interpolation="false"

      It can be turned on or off on a per-XSP-/logicsheet-basis by setting attributes
      "attribute-value-interpolation" or "text-interpolation" of the top level element
      to true or false. Note that these attributes must belong to the
      "http://apache.org/xsp" namespace.

      How it works:

      New class XSPExpressionParser is a parser for the expressions. New class
      XSPExpressionFilter is a filter that gets SAX events with embedded expressions
      and generates SAX events for expanded expressions. This is used in LogicSheet to
      filter read logicsheers and in XSPMarkupLanguage to filter the XSP.

      Changes to existing code.

      LogicSheets need to know the namespace and uri of the markup language in order
      to replace expressions. Therefor AbstractMarkupLanguage needs to know this when
      reading logicsheets. This meant that I had to move this configuration
      information from parametrize to configure. It is unclear to me anyway, why
      AbstractMarkupLanguage used both methods at the same time (which are described
      as "incompatible" in the Avalon documentation).

      The old PreProcessFilter wraps text() nodes in <xsp:text> elements inside some
      tags (See [2]). It is unclear to me why this was done, and all XSPs I've tested
      worked without this. I got no reponse on the list, so I left this feature out of
      the new PreProcessFilter.

      If any of the above changes need further discussion, clarification or change,
      please tell me and I'll update the patch.

      This patch also should be applied to 2.2. If it does not work, again please tell
      me and I'll make a 2.2 patch available.

      [1] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=111693513631888&w=2

      [2] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=111778627925208&w=2




            • Assignee:
              werbung@kuhnle.net Jochen Kuhnle
            • Votes:
              1 Vote for this issue
              0 Start watching this issue


              • Created: