• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

returning strings using call-template

 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wondering if I could return strings using the templates or anyother technique.....
Any help is appreciated.
Thanks.
Example:
Using call-template to load a value into a "param"
I know it doesn't work, but looking for a workaround.... ;)

[ November 25, 2002: Message edited by: Madhav Lakkapragada ]
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure I understand what you want to achieve, but I'll try to answer anyway
Templates do not "return" strings in usual sense, but you can get the effect by catching the output of the template.
1) if you only need to output the value of a string -- make your template to output the value and call this template from where you need this output
2) if you want to apply further processing to the string, wrap your template call in xsl:variable element
<xsl:variable name="myString">
<xsl:call-template ...>
</xsl:variable >
[ November 25, 2002: Message edited by: Mapraputa Is ]
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As much as I love your answer, I have to ask you this, so forgive me if this is stupid.

2) if you want to apply further processing to the string, wrap your template call in xsl:variable element
<xsl:variable name="myString">
<xsl:call-template ...>
</xsl:variable >

I like this approach, but isn't this same as what I was trying to do with the with-param. IMO, this is same as the <xsl:value-of ...> stmt.
I mean instead of
<xsl:with-param name="Location" select="$getLocation"/>
I was trying to do
<xsl:with-param name="Location">
<xsl:call-template ...../>
</xsl:with-param>

Anyways, whatever works.........I guess! :roll:
Thanks, Map.
- madhav
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Map:
Although, I can still read after my third Honey Brown just wanted to let you know that I am trying to get this to work with a recursive call-template (you know that damn business logic) and I just ran into this....
(Location of error unknown)XSLT Error (javax.xml.transform.TransformerConfigurat
ionException): javax.xml.transform.TransformerException: java.lang.RuntimeExcept
ion: Programmer's assertion in getNextStepPos: unknown stepType: -1
....long night ahead!!! eh ? :roll:
- madhav
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Madhav, your XSL should work as it is.
I modified it slightly to see the output, basically getLoc template prints "41" and myGPSLocation template reads this value as a parameter and increments it by 1. The output is 42, as expected. What doesn't work in your version (except for dreadful getNextStepPos exception)?
And by the way, Happy Birthday tomorrow!
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
except for dreadful getNextStepPos exception
Figured this one....
I had to generate an XML string from the data that I had so I did...
<xsl:value-of select="<MyLocation Id="$curPos"/>"/>
This stmt was causing the dreadful exception. It went away when I added a aphos around the string like this: (single quotation after the select=" )
<xsl:value-of select="'<MyLocation Id="$curPos"/>'"/>
So the night ends.......Thanks for the wishes.
- madhav.........one more year wiser!
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<xsl:value-of select="<MyLocation Id="$curPos"/>"/>
This doesn't look like well-formed XML to me (and neither does your proposed fix)
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<xsl:value-of select="<MyLocation Id="$curPos"/>"/>
This doesn't look like well-formed XML to me (and neither does your proposed fix)

No it's not well formed as you see it. Its the browser that puts the lessthan and greater than symbols. In my original post, I had escaped it using the charaters & l t g t and ;.
Once you escape them properly then it will be the right solution. Atleast it worked for me.

<xsl:value-of select=" ' & l t ; MyLocation Id=& q u o t ; $curPos & q u o t ; /& g t ; ' "/>
Solution with extra spaces...

regds.
- madhav
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once you escape them properly then it will be the right solution. Atleast it worked for me.
This is probably a wrong day to ask, but what problem are you trying to solve? I got a feeling that there might be more elegant solution... If you'll say what you want, we can try to find this solution and post it as your birthday present
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what problem
Well well well.....as much as I would like to say more, I can't answer that question!
That's why I was eluding the fact about "complex business logic".....
Thanks.
- madhav
 
reply
    Bookmark Topic Watch Topic
  • New Topic