You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Adam Jenkins (JIRA)" <xa...@xml.apache.org> on 2009/11/16 20:44:39 UTC

[jira] Created: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
-------------------------------------------------------------------------------------

                 Key: XALANJ-2510
                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
             Project: XalanJ2
          Issue Type: Improvement
      Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects.  Anybody can view the issue.)
          Components: Xalan-extensions
    Affects Versions: The Latest Development Code
            Reporter: Adam Jenkins
             Fix For: The Latest Development Code




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Adam Jenkins (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788750#action_12788750 ] 

Adam Jenkins commented on XALANJ-2510:
--------------------------------------

this is getting <censored> ridiculous...2 pages of architectural filibusturing for the simplest patch I've ever submitted anywhere, ever.  Discussions about how something "feels", I mean come on.

But here goes, one last try at this complete freakin' insanity.

>>If there are indeed several writers of such extension elements, then it would be possible to do the very same process I suggested inside Xalan itself.

Why not just use the structure that's already there!?  I don't understand...why do you want to create 2 xpath contexts, one outside of xalan and one inside.  Also, don't give me generic architectural concepts in your answer...give me java file names...where do you want to extend from, how do you intend to interact with the current processor.  Is this external processor also supposed to use XObject...what about the ElemVariable preprocessing where indexes are assigned, how do we fit in with that so that our external variables are usable from within xpaths in our XSLT?.

>>in particular if you consider that documents from insecure sources might use this mechanism to suddenly refer to objects in a way the writer of the stylesheet never intend. So there is a security risk there. So this should be carefully thought through, maybe by using random keys instead of sequential indexes, so guessing valid object elements becomes infeasible. 

I'm sorry to ask it...but are you high?!  Security risk?  Inside an XSLT...what!  You're proposing people randomly load XSLT into their organisations from insecure sources and you're worried that MY patch "feels" odd?!?  Seriously, if someone can inject random XSLT transformations into your organisations you've got waaay bigger problems than what they're going to be doing in XSLT.  I can tell you now, if I can put random XSLT into an organisations integration platform, then I already have all the security access I need to do pretty much anything I want.  This is a complete red herring and has no bearing on this issue at all.

>>After rewriting a bunch of projects from scratch, and a few more in the queue, I've learned the value of a good concept before I start to code. Beeing rash to get the first features out will likely hinder later development if the underlying concepts are not sound and flexible enough. 

Refactoring, by Martin Fowler....buy it, read it.   The days of BDUF (Big Design Up Front) have been dead in our industry for many years now.  And when you say bunch of projects...what are we talking here, $4mill, $12mill??  Or are these just your own projects?  Because I can tell you from experience that some of the biggest and most high profile projects in the last 5 years have been written exactly the opposite to how you suggest, hell Thoughworks have made a multinational business out of it.  Agile (XP, Scrum, FDD) is our fastest growing area of training and has been that way for quite a few years....none of those 3 methodologies do BDUF.  In fact, BDUF is generally seen as a risk factor for project failure.

>>I'd rather wait a bit longer to think about possible concepts, and then implement some concept that will allow a smooth ride from the first feature to the final full-featured improvement, without hacks at every corner and without breaking compatibility in between. 

You make so many assumptions here....that because you don't have a BDUF, it's a 'hack'....go tell Kent Beck that all his very successful projects were hacks...and who says even if something is a hack it's going to break compatibility??  Isn't that what a unit test is for??  All through projects, all over the world (including Xalan) there is code comments with things like "this is a bit of a hack, could be done better in the future" which has been working fine for years.  If everything that's written has to fit your arbitrary "feel good" rule, I'd hate to see how much code is going to actually make it into production.  Just writing this patch I stumbled across 3 places in Xalan that had comments talking about how the author would have liked a better solution but he chose to do the pragmatic thing and get the functionality out there in a timely fashion.

And who is going to do this BDUF you speak of...who is going to sit down and think of a gazillion scenarios and then code for them....and what are the companies that rely on these changes and future innovation meant to do in the mean time....I can tell you what they're going to do, move to Saxon, because I see it every day.  Xalans too slow, Xalan doesn't have XSLT 2.0, Xalan won't accept my patches...that's what I hear from clients, every day.

>>So if there is a way to simply have an extension element return an object of class FooBar

It does that currently!  Look at the code!  You return an object, and it turns it into a text node and injects it into the result document.  As you would expect.  This is about those times when you want to set a variable for use later rather than having it injected into the output results.  

Have you written any extension elements?  Because it sounds like you're talking from an XSLT point of view, you don't seem to be making many references to where...specifically in the code you would like these changes to occur.  If you haven't written any extension elements, then what are you doing even commenting here...you don't know what you're talking about and you're just confusing the issue.  If you have, then tell me where you want this 'new object' type (again, does it subclass XObject...is it being passed as an XPath reference or a java object?) to be integrated back into the Xalan variable stack.

>>I'm not a committer to Xalan-J (yet),
God help us if you ever become one mate...the complexity you've bought to this very simple addition of functionality is incredible.  You talk about 'feeling' that this is a hack...come on, seriously?'

Finally, you seem hell set on this XML placeholder replacement approach, even suggesting that would be my way to expedite acceptance of my bug.  You know how I read that...."I don't like how you did it, but if you do it exactly how I want it done, we'll let it through".  Now project that into the future...is that your strategy for managing outsider patches?....as long as it "feels right" for me (which means basically something you design) it'll go through...otherwise don't botther.  Anyone still wondering why this project has a committer level problem??

You're placeholder design takes a very simple solution and turns it into an incredibly complex one, requiring multiple processing of the same segment of code, the use of a placeholder variable and both an extension element and a function.  And isn't your suggestion of handling it inside the ElemVariable.java just before assignment EXACTLY WHAT MY PATCH DOES?  It just does it as an XPath object, referencing the exact XObject rather than bothering to write it to an intermediary XML and then cast it back.

Gotta say guys, this is ridiculous.....laughable almost if it wasn't so serious.  In 12 years I've never hit so much sheer conjecture, stonewalling and filibustering for a contribution to a OS project.  I had to contributed some XQuery stuff to Michael over at Saxon once....he looked at the work, asked me a couple of questions, suggested some modifications (giving exact files, rather than random generalised statements) and helped me make the mods, then thanked my for my work....whole process took about 2 days AND HE WAS ON HOLIDAYS AT THE TIME!   And generally that's what I've gotten elsewhere....I totally live in fear of ever having to post to these mailing list because I always hit this same type of architectural filibustering...this project reminds me of the bad old days when you had to be really nice to a sys admin or he wouldn't give you an email address.

Anyway, accept it/reject it...who cares at this stage, if this is what people have to go through to have an input to this so called "Open Source" project.  

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788112#action_12788112 ] 

Henry Zongaro commented on XALANJ-2510:
---------------------------------------

Hi, Adam.

I wouldn't reject the enhancement request outright; it's an interesting idea.  I think the concerns that Martin and I have both expressed revolve around the patch designed to meet that enhancement request.  I don't think it solves the problem in a way that is well integrated with the rest of the XSLT language - it does one thing in an xsl:variable, but another in an xsl:with-param or in a named template called from an xsl:variable.

Jira provides us only with a mechanism for rejecting bugs and improvement requests - but I don't have strong concerns about the improvement request itself, so I don't intend to reject that.  If the concerns I've raised about the patch aren't addressed, I don't plan to apply it myself.

Thanks,
Henry

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Dave Brosius (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788816#action_12788816 ] 

Dave Brosius commented on XALANJ-2510:
--------------------------------------

I'm an observer and lover of xalan too, and have pushed a few trivial patches myself, but other than that, no real knowledge. The xalan project tends to be very conservative as to change, partly because of lack of bodies (which, adam, i agree you have a point), and perhaps also because of the unclear relationship with sun's default implementation (i guess). I think your suggestion of forking xalan while not perfect, is probably better than the current course. Of course, if forking, you may just want to just try using a more actively developed processor such as the aforementioned saxon. Curious as to why that isn't a tact you are pursuing. I certainly see the alure of adding functionality to the defacto processor, but it's unlikely a fork will do that anyway.

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12789350#action_12789350 ] 

Henry Zongaro commented on XALANJ-2510:
---------------------------------------

Adam, I feel very sorry this has degenerated to this point.  I have to admit that the extension function and extension element support in the Xalan-J interpreter is not the part of the processor that I'm most familiar with.  In fact, at this stage, I'm sure you know it better than I do.  That's the biggest reason why I have expressed my concerns in terms of the XSLT language, and haven't been able to give you specific detailed suggestions about improvements to your patch at the implementation level or directed you to individual files that I think you should change.

My main concern continues to be about the way this integrates with the rest of the language.  The xsl:with-param issue is one part of it.  The bigger part is I don't feel it's reasonable to expect that a user of a programming language will use a feature in only one way.  If I as a user can write,

<xsl:variable name="foo">
  <my:extension/>
</xsl:variable>

I would expect to be able to use control flow in the body of the variable, to select which of several extension elements I want to use:

<xsl:variable name="foo">
  <xsl:choose>
     <xsl:when test="some-condition">
       <my:extension/>
    </xsl:when>
    <xsl:otherwise>
      <some:other-extension/>
    </xsl:otherwise>
  <xsl:choose>
</xsl:variable>

and I would expect to be able to use named templates for modularity, if appropriate:

<xsl:variable name="foo">
  <xsl:call-template name="do-extension"/>
</xsl:variable>

<xsl:template name="do-extension">
  <my:extension/>
</xsl:template>

and in all those cases, I would expect to have the same value assigned to the variable foo, based on the way existing language features interact with one another.  I don't feel these are bizarre or even unreasonable usage scenarios.  I do have a penchant for creating tests that expose very dark corners of language specifications that I know would never, ever be tripped across by a real user, but I don't think these examples fall into that category.

Changing the behaviour of the feature incrementally to match (what I think is) the expected behaviour runs the risk that some of your users will come to depend on those differences in behaviour - i.e., they might write stylesheets that expect your extensions to behave one way when the extension element is a child of an xsl:variable and a different way when it's the child of an xsl:if that is itself the child of an xsl:variable.  Later changing to the "correct" behaviour means breaking any stylesheets that expected the older behaviour.  In turn that means such users will experience some pain in migrating, or you'll need to introduce backwards compatibility options to be able to select between the two behaviours.

You asked earlier, "Is there an escalation strategy at Xalan...who makes the final calls on these things?"  The Xalan PMC makes the final call on what gets into a release, and also has the authority to reject any contribution (by a 75% majority vote of the PMC).  For ordinary contributions that aren't being considered for an actual release, all you need to do is convince a committer to commit your change - which you're admittedly finding to be a very high hurdle.

In any event, I was thinking - before I saw your post about forking the code - that the right way forward might be to create a branch and add your contribution there.  Then people can extract and build the code, play with it, make further contributions to address the concerns.  After that, we could fold it back onto the main trunk.  Let me know how you feel about that suggestion.

Thanks

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Closed: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Adam Jenkins (JIRA)" <xa...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adam Jenkins closed XALANJ-2510.
--------------------------------

    Resolution: Won't Fix

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Michael Glavassevich (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788785#action_12788785 ] 

Michael Glavassevich commented on XALANJ-2510:
----------------------------------------------

Henry politely offered you constructive critcism for your patch. If you're not interested in continuing that is certainly your choice, but the tone of your responses isn't helping your case. Whatever your disagreements keep it to a technical discussion. Lets be civil.

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12781586#action_12781586 ] 

Henry Zongaro commented on XALANJ-2510:
---------------------------------------

Sorry - I was just getting caught up on the e-mail thread associated with this.  You wrote, "nope, they can't...trust me :)

It's a very advanced extension library with significant nested structure...to represent it as a sequence of nested function calls would be too complex and difficult to read/maintain...if it could be done at all.

The example I gave was an extremely simple use case to get across what I want to do, rather than get bogged down in the particulars of each use case.  I understand the use of functions, my extension library has a whole bunch of extension functions (I think it's up to about 30)...but also has about 40 extension elements for structures that are just too complex to be represented as extension functions.  Some of these extension elements have return values that don't suit being turned into a node set."

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Martin von Gagern (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12787413#action_12787413 ] 

Martin von Gagern commented on XALANJ-2510:
-------------------------------------------

Changes to behaviour depending on element context feel like a really bad idea to me. This is because what the user intends and how the element interprets the situation might be quite different things. For example if I as an innocent user of that library were to use some conditional like Henry suggested, and ended up accidentially setting some global entity manager, I might become quite unhappy.

So from the user perspective, I would wish for the behaviour of elements to not depend on context. Instead I'd prefer some attribute to change behaviour where appropriate, e.g. defaultManager="yes|no" or output="object|stderr" or whatever.

As for the implementation, how about using placeholder elements? The custom elements could return <placeholder xmlns="some-internal-namespace" index="42"/> and keep track of the association from the index 42 to the actual object in some kind of auxiliary data structure available for the whole process, e.g. through an Object-valued xslt variable set by the caller. The fact that you already have a global default manager suggests you know a suitable way to get such per-transformation variables. Functions dealing with the objects represented by such placeholders could then inspect whether the node (list) they are given is a placeholder, maybe with some whitespace around it, and if so, retrieve the associated object and use that.

The benefit would be that all of this could be implemented in the extension library, without any modifications to xalan itself. It would therefore be much easier to deploy, and much easier to port to other processors. Furthermore there'd be much less corner cases to deal with, e.g. what would happen when arbitrary objects end up getting serialized to xml. And with the use of placeholder elements instead of opaque object variables, users would have all the power of xslt at their disposal; not only conditionals and template invocations, but arbitrary third party extensions as well.

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Adam Jenkins (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12787735#action_12787735 ] 

Adam Jenkins commented on XALANJ-2510:
--------------------------------------

Ok, first thing that I ask, is don't get hung up on a particular example that may be given.  I'm picking these examples at random, there are heaps and heaps of different extension elements and delving into the exactly perfect architectural design for each one is a bit of a red herring for this issue.  I don't expect the Xalan crew to take ownership of SXE.dev.java.net as it's an extension and will never be part of xalan because it doesn't fit the use case of Xalan.  So if you wish to discuss whether the entity manager should be global="yes/no", I think that conversation is best served for the mailing list at SXE.dev.java.net.

As for maintaining a seperate variable stack...my response to that would be "why?"....there is a perfectly valid way of managing and resusing variables and parameters in XSLT...should everyone writing an extension element have to create what is essentially their own interpreter and variable context??  If that's the case, why aren't they forced to do that from extension functions?

Your post has a lot of "what if" scenarios...what if someone serializes an object to XML?  Well, they can do that currently....have you ever used document() and loaded the wrong document, or used any extension functions to load an object?   Should we design our software for every possible contingence...if so, are we likely to ever get anything done??   And as for making it portable across processors...it's almost impossible that it would actually be portable even if I did what you suggest, the extension element framework is just too closely linked to the xalan code...to make it portable I would have to extract an interface for every piece of commonality between Saxon and Xalan and code to that interface, which would require a far bigger change to the Xalan base than I'm currently proposing.

I could come up an infinite number of reasons why a change like this is both a good and a bad idea.  As I could for any other change to any other system....there is no right or wrong way to implement a solution whos constraints are almost entirely virtual (and I say this with 12 years enterprise architecture experience and a SCEA, SCWCD, SCBCD and SCJP ticket)...sooner or later someone just has to make a call as to wether the supplied value outweighs the impact to existing system.  There is obviously a pretty good case that it does, otherwise why would extension functions already have the functionality?

I guess I fail to understand why allowing a simple 5 line change to one component (ElemVariable) to allow extension elements to do something that is already allowed in extension functions warrants such concern or objection.  Especially when the impact to existing transformations is exactly zero.

Anyway, this very simple, very low impact patch has been sitting here for a few weeks now....can someone either approve it or reject it so I can get to porting my extensions over to Saxon if I need to.

Cheers
Adam

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Martin von Gagern (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788714#action_12788714 ] 

Martin von Gagern commented on XALANJ-2510:
-------------------------------------------

> should everyone writing an extension element have to create what is essentially their own interpreter and variable context

If there are indeed several writers of such extension elements, then it would be possible to do the very same process I suggested inside Xalan itself. The upside is ease of use for extension writers, a possibility to replace its implementation inside Xalan at some later point in time without impact on existing extensions, and of course it avoids code duplication. On the downside we'd reserve a namespace for Xalan internal use, which should be perfectly legal but feels bad nevertheless, in particular if you consider that documents from insecure sources might use this mechanism to suddenly refer to objects in a way the writer of the stylesheet never intend. So there is a security risk there. So this should be carefully thought through, maybe by using random keys instead of sequential indexes, so guessing valid object elements becomes infeasible.

> Isn't the whole point of open source to grow slowly over time with user need, patch by patch? Isn't the whole reason that agile methodologies have taken off because they do only what is needed to solve the current problem rather than thinking up every possible solution...

After rewriting a bunch of projects from scratch, and a few more in the queue, I've learned the value of a good concept before I start to code. Beeing rash to get the first features out will likely hinder later development if the underlying concepts are not sound and flexible enough.

A bunch of patches, each requiring adjustments not only to Xalan but to the extension elements as well, until the concept finally integrates fully with xslt, i.e. behaves the way writers of xslt stylesheets would expect it to, seems to me an indication of bad design. So even if the patch does fix your current problem, and if future problems could be addressed in subsequent patches, I'd rather wait a bit longer to think about possible concepts, and then implement some concept that will allow a smooth ride from the first feature to the final full-featured improvement, without hacks at every corner and without breaking compatibility in between.

>From the point of view of an extension writer, I would wish for my extension element to simply return an object of arbitrary type, instead of performing some kind of unintuitive set-value callback. That's what the current Xalan-J online documentation would suggest to me, too. So if there is a way to simply have an extension element return an object of class FooBar, and an extension function accepting an argument of class FooBar, and if we could link the two using an xslt variable on the Xalan side, then I believe we should implement this way. xml placeholders go part of the way, but 

> Using a placeholder xml [...] would require post processing of the transformation

How so? There are three possible points where you could turn placeholder xml back to objects:
1. inside the extension functions dealing with such objects, as I suggested for an extension-only implementation
2. inside the xsl:variable et al. upon assignment
3. just before calling extension functions, i.e. when preparing the argument list
None of them feels like a lot of post-processing, but instead like a single lookup in a single place at the time an object is needed, for a given definition of "needed". As neither objects nor placeholders are intended for serialization, 

> If I make the same changes to xsl:with-param and resubmit the patch, will it go through?
> I'm happy to code, use, do anything that gives me the ability to set a variable from an extension element...

I'm not a committer to Xalan-J (yet), so I can't give you authoritative answers here. If I were, I'd tell you that I've got the feeling your implementation is a hack, that a more proper solution that integrates more naturally should be possible. The "what if" scenarios are not only concerns about your patch failing to address these, but an indication of a concept in need of improvement, as is the fact that a simple change to function return type for extension element implementations doesn't do the trick.

I'd furthermore ask you that if you want the code in Xalan (as opposed to your own lib), then I'd suggest you try out the replacement element approach, so we get a better idea about its impact on exported API, performance, affected locations in the source code, security issues, integration with xsltc and so on. If I were a committer, I'd see good chances that I'd eventually commit a patch along these lines. If you come up with an even better idea, I'd be happy to hear it.

> someone just trying to understand a big code base with no assistance

I feel the same myself.

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Adam Jenkins (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788380#action_12788380 ] 

Adam Jenkins commented on XALANJ-2510:
--------------------------------------

sorry for the grumpy post, you hit me before my morning coffee :)

I asked for architectural guidance on this on the dev mailing list before doing this and go no assistance, except an email telling me to use extension functions...so I do heaps (and I mean heaps) of investigation into the codebase as to what is the best way to implement this (including debugging through the variable pre processor and indexing component) and write what looks to be the best solution with my limited knowledge and no guidance.  I then post a problem description, with a working solution, and again get told to use functions....then get hit by a whole bunch of what if scenarios, with no again no architectural guidance as to how you guys, the experts, would like me, someone just trying to understand a big code base with no assistance, to solve it...this is all incredibly frustration for a few lines of optional code that doesn't modify existing behaviour one bit (and I spent a _lot_ of time making sure that whatever solution I came up with would satisfy those criteria
 ).

very very frustrating

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Adam Jenkins (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12783208#action_12783208 ] 

Adam Jenkins commented on XALANJ-2510:
--------------------------------------

Just a quick check to see where this is at...did you require any further information from me Henry?  We're hoping to release our open source extension element/function library the end of next week on dev.java.net, just wondering whether this is likely to be in by then?

Cheers
Adam

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Adam Jenkins (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12804350#action_12804350 ] 

Adam Jenkins commented on XALANJ-2510:
--------------------------------------

after a month diving through Xalan I'm convinced that implementing things the way you want is not possible with the current architecture without explicitely setting an override variable in either the ElemVariable or the TransformerImpl to temporarily stop serializing and look for an object instead.  Both of these strategies you've hinted at being unacceptable so I'm going to close this issue.


> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12781581#action_12781581 ] 

Henry Zongaro commented on XALANJ-2510:
---------------------------------------

Adam, could I ask you elaborate on the motivation for this change?  It's not clear to me why using an extension function instead wouldn't work.  Having an extension element return something other nodes feels odd to me for XSLT 1.0.

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Adam Jenkins (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12783833#action_12783833 ] 

Adam Jenkins commented on XALANJ-2510:
--------------------------------------

Hi Henry,

Yep, you're correct re xsl:param and xsl:variable.  I didn't really consider xsl:with-param or func:result, as I guessed that if people want to do that, they can just create a variable first and pass that to the with-param.  I only chose to modify ElemVariable so as to keep my impact on Xalan base minimal.

As for a sample, it depends on the use case and there are a lot of use cases :)

Usually I first test the parent thus:

    protected boolean setVariableIfPossible(Object variable, ElemExtensionCall thisElement){
        if(thisElement.getParentElem() instanceof ElemVariable){
            ElemVariable varElement = (ElemVariable)thisElement.getParentElem();
            varElement.overrideChildDocument(new XPath(new XObject(variable)));
            return true;
        }
        return false;
    }

if this returns false, the action is different for each extension element.  For instance, I have an element that configures a JPA entity manager that is used thus:

      <xsl:variable name="entityManager">
          <jpa:entityManager persistenceUnit="myPU">
                <jpa:property name="flush" value="true"/>
           </ejb:entityManager>
      </xsl:variable>

Now, if that isn't inside a variable element, it sets up a default entityManager for the entire transformation.  However, I have another JPA element called query that is used thus:

     <xsl:variable name="customers">
        <jpa:query name="customer/name" location="customer/address/city" type="customer/@type">
               from Customer c where c.name = :name and c.city = :location and c.customerType = :type
         <jpa:query>
     <xsl:variable>

where the attributes of the extension element are mapped to the named parameters of the JPA query.  Now if this element isn't inside a <xsl:variable> element, then the response is output as per standard:

context.outputToResultTree(context.getStylesheet(), queryResults);

I hope those two above give you a bit more of an idea of some of the stuff I'm doing.   The entire collection of extension elements/functions is open source at sxe.dev.java.net (though I think it's still going throug approval, so you might have to log in to see it, or ask me for permissions or something, I don't know how it works for pre-approved projects...let me know)....I know the code in there isn't the best, so be kind ;).    Also, I know some of the stuff that those extensions allow you to do may not be considered best practice, however sometimes they come in handy :)

In terms of the dynamic scope question, the answer should be addressed above, each of my extension element has a different strategy for when it's not inside a xsl:variable element, and it's up to the users of the library to read the doco and understand the impact on their transformations.

In regards to using an XPath...may not be the best solution, I just tried to keep things as similar to how Xalan was currently doing things as possible so as to minimize my impact on the project :).  One of my primary motivations while thinking about how to impliment this was how to keep the impact on Xalan to an absolute minimum, so I chose the shortest path to accomplish my goal :)

I hope the above helps understand the motivation for this change a little more.  Feel free to checkout sxe.dev.java.net.  I know some of the things it does are considered not exactly best practice (for example, being able to send an email from an XSLT or being able to write to a graph to a parallel binary stream), however it's an optional library, so I expect users of it to understand the pros and cons of breaking some of the XSLT best practices.

I'll submit the license agreement you posted a link to sometime today (for some reason, my ISP blocks apache, so I have to wait until I get to work :) ).


> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Adam Jenkins (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788793#action_12788793 ] 

Adam Jenkins commented on XALANJ-2510:
--------------------------------------

It's not a case (to be justified and pleaded), and my tone shouldn't matter, the merit of the argument should...and I think this level of frustration is quite justified at this point.

Yes, Henry gave criticism (yes constructive)....but stopped short of advice.  So the choice to continue is not mine....you withhold my ability to contribute by telling me my patch is not good enough, but don't offer advice on where or how to improve it.  So I have no choice.

And yes, Henry has been polite, and has a couple of cases I've acknowledged the merit on and tried to find a way forward with...I guess there's too conversations going on here, which can be tricky with issues...one with Henry, one with Martin.  No one is willing to let me know which of the massive amount of items listed above that my patch apparently fails to address actually need to be addressed for it to be considered.

And damn sure no one is offering advice on where to start looking or investigating to make it better.

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Adam Jenkins (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788310#action_12788310 ] 

Adam Jenkins commented on XALANJ-2510:
--------------------------------------

Hi Henry,

You make a fair point on xsl:variable vs xsl:with-param, if I extend the patch to xsl:with-param, are you happy to commit it?

As for a named template call from an xsl:variable, my patch doesn't change any existing functionality...it's just an IF statement that MAY be used by an extension element. If they do that, it will work exactly the same as it currently does, I haven't changed any of that functionality. 

And as I said...this is exactly how extension functions work...I've basically just done the same thing for extension elements.   You can't use an extension function in the way you've specified, so why should it be a problem for extension elements?

The whole extension element, within an if, within a variable, that happens to want to set an object.  I have to ask how many people would even likely to hit that? And if they do, can they not submit their own patch when they come up against it to enhance my changes? Why does the scope for a patch that has a specific use, and adds a fair amount of functionality, have to be increased to cover all possible conceivable uses...especially when it's an optional piece of functionality, used by very few users of Xalan.   What percentage of your user based writes extension elements, and what percentage of those are going to hit that problem described, and what percentage of those are going to be unable to declare the variable ahead of time, and what percentage of those are going to be unable to submit their own patch to solve it....because that's the group of people we're talking about here, we're holding up a current user need for a fairly low probability theoretical users need. 

Isn't the whole point of open source to grow slowly over time with user need, patch by patch? Isn't the whole reason that agile methodologies have taken off because they do only what is needed to solve the current problem rather than thinking up every possible solution...I mean, if ever anything fell into YAGNI.

Martin has expressed a concern with how I've implemented the entity manager extension element over on sxe.dev.java.net.  Fine, no problems, I possibly think it should have been raised over there, but I've included his suggestion about default="yes/no" on that extension element.

Using a placeholder xml I have a problem with as it's very different to how extension functions and Transformer.setParameter(...) currently work.  It would require post processing of the transformation which is a massive change for a small piece of functionality...so again, YAGNI on the one.

As for accidently serializing an object, well, people can do that at the moment, either by getting it from an extension function or passing it into Transformer.getParameter, so unless you want me to also change them, one of which is part of the spec, so I don't like our chances there, then I don't think that concern has a great deal of merit.

So back to xsl:variable vs xsl:with-param. If I make the same changes to xsl:with-param and resubmit the patch, will it go through?

If anyone has a better way of doing this....let me know, happy to rewrite it all.....but given it took me so long just to get this little patch noticed, it doesn't fill me with hope that this ability (which is a blaring architectural inconstistency between extension functions and extension elements if you want to get into inconsistencies...maybe I should have made it a bug) will be in Xalan any time soon.

If I sound a bit p-d off, it's because I am....for years I've been defending Xalan to my peers against the massive onslaught of "switch to Saxon" (and I teach across Australia for the most active java training institute over here, so when I say peers, I mean pretty much everyone I meet whenever I do an XSLT or a Java course)...so when I was charged with enhancing my existing extension functions and elements with a couple of others and releasing them (that caused this issue), I had a choice, Xalan or Saxon....I chose Xalan to inject a bit of life into it and this is what I hit....the exact philibustering that I was warned about.

As for keeping the ticket open but rejecting the patch...fantastic, if you've got someone else lined up to code it I'm happy to use their solution?  Do you have an ETA on it so I can plan my work around yours?  Like I said, I'm happy to code, use, do anything that gives me the ability to set a variable from an extension element...but all I'm getting is a bunch of what-ifs with no real suggestion to how you would like this changed (post processing an XML document for placeholders aside).

Otherwise...what do we do....."no sorry Adam, we don't like your patch and won't give you direction as to how we would like it, so you can just stall all your plans and keep submitting until you happen to hit upon something that gives us the warm and fuzzies"?

Is there an escalation strategy at Xalan...who makes the final calls on these things? Is this the end of the line for this functionality based on random what-ifs and YAGNI functionality?  You're not exactly filling me with open-source contribution love here guys.  I have a real need, today, which is a blocker on my project, that is being canned based on theoretical corner cases...doesn't that fly in the face of what open source is supposed to be about?  Many people, making changes based on their current needs slowly building and enhancing a project over time?

Adam

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2510) Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ https://issues.apache.org/jira/browse/XALANJ-2510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12783695#action_12783695 ] 

Henry Zongaro commented on XALANJ-2510:
---------------------------------------

Hi, Adam.

Thank you for the contribution.

I've taken a quick look at your patch.  One thing I notice immediately is that it applies to xsl:param and xsl:variable, but I expect you would want it to apply to xsl:with-param as well - right?  And probably the EXSLT func:result element, too.

I'd also like to understand how this interacts with other features of the language.  Without a sample implementation of an extension element like the one you've posited, it's difficult to tell whether this new feature is well-integrated.

For instance, suppose I make the extension element in the content of an xsl:if or xsl:choose to evaluate it conditionally, will that work?

<xsl:variable name="myvar">
   <xsl:if test="condition">
      <my:extension someAttribute="somevalue"/>
   </xsl:if>
</xsl:variable>

The way you've written the patch, it looks like you're expecting this kind of element that needs to return an "override" value to be a child of an xsl:variable/xsl:param.  Similarly, what if the extension element is in the dynamic scope of an xsl:variable rather than the static scope - i.e., what if the xsl:variable contains an xsl:call-template, and that named template contains the extension element.  How does the override get set on the xsl:variable that contained the call?  Again, a sample implementation of such an extension element might have helped to clarify the way the mechanism works.

Finally, I wonder about the way the result is set on the xsl:variable is through this mechanism of supplying an alternative XPath expressions, rather than somehow integrating it as a different result kind.

By the way, it's important that any contribution that's not completely trivial be covered by a contributor's license agreement.  That assures the ASF that you have the right to make the contribution.  May I suggest that you submit one?  You can find it here.[1]

[1] http://www.apache.org/licenses/#clas

> Ability to set non tree fragment variable using an extension element (PATCH SUPPLIED)
> -------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2510
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2510
>             Project: XalanJ2
>          Issue Type: Improvement
>      Security Level: No security risk; visible to anyone(Ordinary problems in Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan-extensions
>    Affects Versions: The Latest Development Code
>            Reporter: Adam Jenkins
>             Fix For: The Latest Development Code
>
>         Attachments: XALANJ-2510.patch
>
>
> When using extension elements, there is no way to set a non XRTreeFrag related variable.
> For example, say you have:
> <xsl:variable name="myvar">
>    <my:extension someAttribute="somevalue"/>
> </xsl:variable>
> If my:extension wants to set a tree fragment, string or nodeset into myvar, that's not a problem, however if it wants to set a java object, currently there is no mechanism for that (any java object passed either returned from the method or passed to XSLProcessorContext.outputToResultTree is toString()'ed before being passed back to the ElemVariable.getValue() method).
> The proposed change (patch supplied) is to supply an optional variable on ElemVariable.java whereby child extension elements can call up to their parent and set an XPath to be evaluated after the extension element has finished processing.
> This requires only very minor modification to the ElemVariable.getValue method to check this variable.
> This also ensures that this is optional functionality and will not affect that basic Xalan processing.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org