FOP
  1. FOP
  2. FOP-1122

[patch] allow some xsl-function calls with omitted args

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: trunk
    • Fix Version/s: None
    • Component/s: fo/unqualified
    • Labels:
      None
    • Environment:
      Operating System: other
      Platform: Other
    • External issue ID:
      38098

      Description

      This patch allows xsl-functions to be called without
      property name if the xsl spec 1.0 allows one optional
      arg and if omitted the arg is substituted with the
      property for which the expression is being evaluated.

      Description:
      If the PropetyParser dedects at the end of the parseArgs
      method, that only one arg is missing (compared with the
      expected count of args) and the function object
      allows padding with the function name for which the
      function is called it appends the function name to the
      arg list.

      Changes to Function.java:

      • expand the interface with the declaration for the
        padArgsWithPropertyName method.

      Changes to FunctionBase.java:

      • insert a default method body for the padArgsWithPropertyName
        method that returnes false which is the normal case (don't
        allow padding).

      Changes to FromParentFunction.java:

      • let the padArgsWithPropertyName method return true to
        indicate that filling up the number of args with the
        property name for which the expression is being evaluated.

      Changes to PropertyParser.java:

      • call the parseArgs method with the full function object
        insted only with the nbArgs counter.
      • expanded the parseArgs method as mentioned in the
        general describtion above.

      Open issues / questions:

      • should the arg created in the parseArgs method of the
        PropetyParser be a NCnameProperty instead of a
        StringProperty? The supplemented args are always
        property names and therefore NCNames but i didn't
        see an advantage and choosed the more general
        StringProperty but i am not shure whats better.

      Todo:

      • if the patch is acceptable than adjust the other functions
        who also allow padding with the property name - if i find
        corresponding classes :
      • system-font
      • inherited-property-value
      • (from-parent) done
      • from-nearest-specified-value
      • from-table-column
      • merge-property-values
      1. properties_omitted_propertyname.fo
        3 kB
        gerhard oettl
      2. exprPadWithPropName.patch
        6 kB
        gerhard oettl
      3. exprPadWithPropName.fo
        3 kB
        gerhard oettl
      4. exprPadWithPropName.patch
        4 kB
        gerhard oettl

        Activity

        gerhard oettl created issue -
        Hide
        gerhard oettl added a comment -

        Attachment exprPadWithPropName.patch has been added with description: the patch

        Show
        gerhard oettl added a comment - Attachment exprPadWithPropName.patch has been added with description: the patch
        Hide
        gerhard oettl added a comment -

        Attachment exprPadWithPropName.fo has been added with description: a fo-file to show the effect

        Show
        gerhard oettl added a comment - Attachment exprPadWithPropName.fo has been added with description: a fo-file to show the effect
        Hide
        Andreas L. Delmelle added a comment -

        Gerhard,

        Again, a nice little addition!

        To help you out a bit further with the TODO, and minimize the searching: all those functions reside in
        the package org.apache.fop.fo.expr (apart from system-font()). They have slightly different names, but
        easily recognizable. For example: from-nearest-specified-value = NearestSpecPropFunction. Come to
        think of it, maybe this should be renamed as a matter of style to FromNearestSpecValFunction or
        something like that...
        from-table-column() is currently unimplemented, but it shouldn't be particularly hard, given:
        a) that the column-numbers are all properly initialized
        and b) the limited number of properties applicable to table-columns.

        If you already know your way around the properties package well enough: the PropertyList for a
        TableColumn will, IIC, no longer be available at the time this function is called, so it may be possible to
        map it to a call to the appropriate method in fo.flow.TableColumn...
        example: "from-table-column(1, 'border-start-width')" would trigger a call to
        "((TableColumn) Table.getColumns().get(0)).getBorderWidth(CommonBorderPaddingBackground.START)"
        Either that, or references to the columns' PropertyLists need to be kept alive during the whole lifecycle
        of the Table object.

        Cheers,

        Andreas

        Show
        Andreas L. Delmelle added a comment - Gerhard, Again, a nice little addition! To help you out a bit further with the TODO, and minimize the searching: all those functions reside in the package org.apache.fop.fo.expr (apart from system-font()). They have slightly different names, but easily recognizable. For example: from-nearest-specified-value = NearestSpecPropFunction. Come to think of it, maybe this should be renamed as a matter of style to FromNearestSpecValFunction or something like that... from-table-column() is currently unimplemented, but it shouldn't be particularly hard, given: a) that the column-numbers are all properly initialized and b) the limited number of properties applicable to table-columns. If you already know your way around the properties package well enough: the PropertyList for a TableColumn will, IIC, no longer be available at the time this function is called, so it may be possible to map it to a call to the appropriate method in fo.flow.TableColumn... example: "from-table-column(1, 'border-start-width')" would trigger a call to "((TableColumn) Table.getColumns().get(0)).getBorderWidth(CommonBorderPaddingBackground.START)" Either that, or references to the columns' PropertyLists need to be kept alive during the whole lifecycle of the Table object. Cheers, Andreas
        Hide
        gerhard oettl added a comment -

        additional (resolving the todo of the first patch)

        Changes common to
        1) FromParentFunction.java:
        2) FromTableColumnFunction.java:
        3) InheritedPropFunction.java:
        4) NearestSpecPropFunction.java:

        • let the padArgsWithPropertyName method return true to
          indicate that filling up the number of args with the
          property name for which the expression is being evaluated.

        Changes common to
        1) MergePropsFunction.java:
        2) SystemFontFunction.java:

        • ATTENTION - NONEXISTENT!
          Though the PropertyParser calls does a call to
          "new MergePropsFunction()" and
          "new SystemFontFunction()"
          greping through the codebase i cannot find such classes.
        Show
        gerhard oettl added a comment - additional (resolving the todo of the first patch) Changes common to 1) FromParentFunction.java: 2) FromTableColumnFunction.java: 3) InheritedPropFunction.java: 4) NearestSpecPropFunction.java: let the padArgsWithPropertyName method return true to indicate that filling up the number of args with the property name for which the expression is being evaluated. Changes common to 1) MergePropsFunction.java: 2) SystemFontFunction.java: ATTENTION - NONEXISTENT! Though the PropertyParser calls does a call to "new MergePropsFunction()" and "new SystemFontFunction()" greping through the codebase i cannot find such classes.
        Hide
        gerhard oettl added a comment -

        Attachment exprPadWithPropName.patch has been added with description: patch 2 (considering the hints of Andreas L. Delmelle)

        Show
        gerhard oettl added a comment - Attachment exprPadWithPropName.patch has been added with description: patch 2 (considering the hints of Andreas L. Delmelle)
        Hide
        Simon Pepping added a comment -

        This is a fine patch. Can you supply a test case for each function for which you
        have implemented this?

        Simon

        Show
        Simon Pepping added a comment - This is a fine patch. Can you supply a test case for each function for which you have implemented this? Simon
        Hide
        gerhard oettl added a comment -

        Attachment properties_omitted_propertyname.fo has been added with description: testcase

        Show
        gerhard oettl added a comment - Attachment properties_omitted_propertyname.fo has been added with description: testcase
        Hide
        Simon Pepping added a comment -

        Patch and test file committed. Thanks. Simon

        Show
        Simon Pepping added a comment - Patch and test file committed. Thanks. Simon
        Hide
        Glenn Adams added a comment -

        batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed

        Show
        Glenn Adams added a comment - batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed

          People

          • Assignee:
            fop-dev
            Reporter:
            gerhard oettl
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development