[ http://issues.apache.org/jira/browse/COCOON-1523?page=all ]

Ralph Goers updated COCOON-1523:
--------------------------------

    Bugzilla Id:   (was: 35228)
      Component: Blocks: XSP
                     (was: Blocks: (Undefined))
    Description: 
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><xsp:attribute
name="attrib"><xsp:expr>expression</xsp:expr><xsp:attribute></elem>
or
<elem>Hello #user.getFullName</elem>, which will be expanded to <elem>Hello
<xsp:expr>user.getFullName</xsp:expr></elem>

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:

<markup-languages>
    <xsp-language ... attribute-value-interpolation="false"
text-interpolation="false">
        ...
    </xsp-language>
</markup-language>

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

  was:
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><xsp:attribute
name="attrib"><xsp:expr>expression</xsp:expr><xsp:attribute></elem>
or
<elem>Hello #user.getFullName</elem>, which will be expanded to <elem>Hello
<xsp:expr>user.getFullName</xsp:expr></elem>

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:

<markup-languages>
    <xsp-language ... attribute-value-interpolation="false"
text-interpolation="false">
        ...
    </xsp-language>
</markup-language>

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


> [PATCH] XSP expressions (attribute value/text interpolation)
> ------------------------------------------------------------
>
>          Key: COCOON-1523
>          URL: http://issues.apache.org/jira/browse/COCOON-1523
>      Project: Cocoon
>         Type: Bug
>   Components: Blocks: XSP
>     Versions: 2.1.8-dev (Current SVN)
>  Environment: Operating System: other
> Platform: Other
>     Reporter: Jochen Kuhnle
>     Assignee: Cocoon Developers Team
>  Attachments: xsp-expressions.patch
>
> 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><xsp:attribute
> name="attrib"><xsp:expr>expression</xsp:expr><xsp:attribute></elem>
> or
> <elem>Hello #user.getFullName</elem>, which will be expanded to <elem>Hello
> <xsp:expr>user.getFullName</xsp:expr></elem>
> 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:
> <markup-languages>
>     <xsp-language ... attribute-value-interpolation="false"
> text-interpolation="false">
>         ...
>     </xsp-language>
> </markup-language>
> 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

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to