Phrases expressions

6 views
Skip to first unread message

argherna

unread,
Jul 6, 2010, 2:34:30 PM7/6/10
to Cernunnos Discussion
Is there an obvious way to implement phrases that take more than 1
reagent/argument? For example, I'd like to implement a Phrase that's
invoked like this:

'${com.andy.MyMultiArgPhrase(arg1, arg2)}'

The code for the MyMultiArgPhrase would define regents like ARG1 and
ARG2 that would be used to execute the phrase and get whatever value I
want back. Thoughts on this?

Andrew Wills

unread,
Jul 7, 2010, 11:33:54 AM7/7/10
to cernunnos-...@googlegroups.com
Andy,

I agree we need to provide this capability.

Right now I think the only example of a Phrase that does (something
like) this is ${attributeNode}, which takes a "key=value" expression.

Originally I had thought (hoped I guess) that context -- attributes on
the stack -- could provide any additional info we needed.

Have you thought about a format for passing additional arguments? I
know ${phrase-name(arg1, ar2)} probably feels the most
natural/familiar. Is there any precedent for
${phrase-name(arg1)(ar2)}?

drew

> --
> You received this message because you are subscribed to the Google Groups "Cernunnos Discussion" group.
> To post to this group, send email to cernunnos-...@googlegroups.com.
> To unsubscribe from this group, send email to cernunnos-discus...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cernunnos-discussion?hl=en.
>
>

Andy Gherna

unread,
Jul 7, 2010, 11:44:30 AM7/7/10
to cernunnos-...@googlegroups.com
On Wed, Jul 7, 2010 at 10:33 AM, Andrew Wills <wills...@gmail.com> wrote:
> Andy,
>
> I agree we need to provide this capability.
>
> Right now I think the only example of a Phrase that does (something
> like) this is ${attributeNode}, which takes a "key=value" expression.
>

Right, but that's really only 1 value as it is emitted as "key=value"
in a Document Node.

> Originally I had thought (hoped I guess) that context -- attributes on
> the stack -- could provide any additional info we needed.
>

That's how I'm implementing it now for some of our custom phrases. It
works and it's sometimes the right thing to do. But I have come
across a use case where you really need to express it as 2 arguments.
That said, the context is great in the cases that are already in
Cernunnos--it feels like an environment variable or a System property
and it feels right such as in <append-node>, ${parseXml()}, etc..

> Have you thought about a format for passing additional arguments?  I
> know ${phrase-name(arg1, ar2)} probably feels the most
> natural/familiar.  Is there any precedent for
> ${phrase-name(arg1)(ar2)}?
>

I've not seen any function call or markup like
${phrase-name(arg1)(arg2)}, but maybe someone on the list has.
Perhaps the implementation of Phrase should be reviewed and reworked
so that it knows how to deal with multiple arguments (such as reading
a portlet preference value using a Phrase) vs. single arguments (such
as reading SQL). It's tricky for sure. I'm happy to help contribute
ideas/implementations for this. But I've come to a point where it'd
be great to have that.

--
Andy Gherna
argh...@gmail.com

Andrew Wills

unread,
Jul 7, 2010, 11:49:17 AM7/7/10
to cernunnos-...@googlegroups.com
On Wed, Jul 7, 2010 at 8:44 AM, Andy Gherna <argh...@gmail.com> wrote:
> Perhaps the implementation of Phrase should be reviewed and reworked
> so that it knows how to deal with multiple arguments (such as reading
> a portlet preference value using a Phrase) vs. single arguments (such
> as reading SQL).  It's tricky for sure.  I'm happy to help contribute
> ideas/implementations for this.  But I've come to a point where it'd
> be great to have that.
>

I'm game for this.

The code that parses XML attributes that contain phrases is due for an
overhaul anyway. It could be improved for speed and also accuracy.

drew

Reply all
Reply to author
Forward
0 new messages