damn it...every single avenue I go down for adding a variable value from an
extension element is a dead end (and I'm pullin' some crazy hacks at this
stage).
this seems like a pretty big deficiency in the extension element framework...I
have an open source library that does some pretty cool stuff scheduled for
release, however the only limitation is that for two of the new elements, I
can't add variables to the stack from an extension element.
Is there anyway we can get this into the next release of Xalan, I'm happy to
code it up myself and submit a patch if someone can give architectural guidance?
My perfect world scenario would be for something like this:
<xsl:variable name="somename">
<my:extensionElement someattr="value"/>
</xsl:variable>
And have the method of the extension element somehow supply an XObject back to
the parent.
This may be a simple as adding a method to the ElemVariable class that is
something like setChildDrivenSelect(XPath p) and modify the getValue() method
so that if that method is called during child evaluation, it returns the
evaluation of the supplied XPath rather than returning the XRTreeFrag from the
child.
That way if we wanted to do this functionality we could code our extension
elements thus:
public void extensionElement(XSLProcessorContext ctx, ElemExtensionCall elem){
Object myValue = ...do some stuff...
ElemVariable varElement = (ElemVariable)elem.getParent();
varElement.setChildDrivenSelect(new XPath(new XObject(myValue)));
}
How does everyone feel about that change? It's quick, easy and offers some
pretty spectacular functionality for very little modification. We'd just have
to replace the line in ElemVariable.getValue()
var = new XRTreeFrag(df, xctxt, this);
with
if(childPopulatedXPath == null) var = new XRTreeFrag(df, xctxt, this);
else var = childPopulatedXPath.execute(xctxt, sourceNode, this);
Thoughts/Comments?
Doing this allows for some pretty cool extension elements to be built which
would really take Xalan to another level.
Cheers
Adam
--- On Sat, 14/11/09, [email protected] <[email protected]> wrote:
> From: [email protected] <[email protected]>
> Subject: Re: Advanced Extension Element Question
> To:
> Cc: [email protected], [email protected]
> Received: Saturday, 14 November, 2009, 8:29 AM
> > Can anyone tell me
> if there's any way to add an
> object (not node or
>
> > tree fragment) variable to the variable stack from an
> extension element?
>
>
>
> From an extension _element_... I
> don't think so.
>
>
>
>
>
> From an extension _function_, yes. If
> the returned
> value is not an instanceof one of the types called out in
> the mapping table
> (http://xml.apache.org/xalan-j/extensions.html#ext-functions),
> it will be returned as an object reference. Generally you
> can't do much
> with those except store them in variables and/or pass them
> as parameters
> to other extensions.
>
>
>
> If your returned value *is* an
> instanceof one of those
> types... The best suggestion I can give you is to set up a
> wrapper object
> which does not implement those types, return the wrapper,
> and have whoever
> is using the value unwrap it again before accessing
> it.
__________________________________________________________________________________
Win 1 of 4 Sony home entertainment packs thanks to Yahoo!7.
Enter now: http://au.docs.yahoo.com/homepageset/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]