Re: Parametrized results in XSLT

> For instance, it would be nice to be able to:
>  * report which URI triggers errors with
> CONTENT_FORMAT_SUPPORT_AND_VALID_MARKUP, maybe completed with the mime
> type when relevant
>  * know the size of the page/of all the resources needed to load the
> page when getting an error in PAGE_SIZE
>
> Roland, how do you think we can best implement such a mechanism?
>  * have an additional parameter on the result template (e.g. "data" or
> "additionalInfo")
>  * have the messages in messages.properties.xml take parameters  
> directly
> through some syntax convention (e.g. $param1) and have the result
> template be  able to deal with those
>  * something else?
First question:
Are more dynamic infos needed,
or want we just to manipulate the messages?

If so, three solutions:
1.
Use the replace XST function with a regex:
<xsl:call-template name="result">
   <xsl:with-param name="search">PAGE_SIZE</xsl:with-param>
   <xsl:with-param name="replace">10000</xsl:with-param>
  ...
</xsl:call-template>
If the parameter search is filled, the "replace" [1]  function is  
used with the text from messages.properties.xml.

2.
The quick solution is define, one, two params, and use them also with  
a static replacement
$param1 is replaced with PLACEHOLDER_1
...

3.
If we want a pure XML/XSL solution, we could use:
<xsl:with-param name="args">
   <arg key="param1" value="value1"/>
   ...
</xsl:with-param>
This args will be transformed into a DOM with exslt.

Then we must change the messages:
<message id="...">FAIL: If the <param key="param1"/> ... </message>

No.3 is the most dynamic solution, No.2 the easiest.

Cheers,
  Roland

[1] http://www.w3.org/TR/xpath-functions/#regex-syntax

Received on Thursday, 18 October 2007 13:43:39 UTC