XSLT Extension function problem?

Discussion in 'XML' started by harryajh, Apr 22, 2008.

  1. harryajh

    harryajh Guest

    Using xalan 2.7.1

    I'm using XSLT extension functions to retrieve special bits of code
    from a java class static methoth during transformation.

    What I'd like to know is if there is anyway to specify a param passed
    in to the stylesheet as an argument in the extension function?

    I currently something like this -

    <xsl:value-of select="ext:getXSLTCode('part1', 'true')"/>

    but what I'd like to do is something like this -

    <xsl:param name="partNo"/>

    <xsl:value-of select="ext:getXSLTCode($partNo, 'true')"/>

    Obvioulsy this doesn't work & nor does having a nested value-of - has
    anyone any idea if this is actually possible? if not any workarounds?

    thanks in advance

    harry
    harryajh, Apr 22, 2008
    #1
    1. Advertising

  2. * harryajh wrote in comp.text.xml:
    >What I'd like to know is if there is anyway to specify a param passed
    >in to the stylesheet as an argument in the extension function?
    >
    >I currently something like this -
    >
    > <xsl:value-of select="ext:getXSLTCode('part1', 'true')"/>
    >
    >but what I'd like to do is something like this -
    >
    > <xsl:param name="partNo"/>
    >
    > <xsl:value-of select="ext:getXSLTCode($partNo, 'true')"/>
    >
    >Obvioulsy this doesn't work & nor does having a nested value-of - has
    >anyone any idea if this is actually possible? if not any workarounds?


    I am not sure what is obvious about this; perhaps you did not set the
    parameter to a specific value? Does it work if you use string($partNo)
    instead? Do you get some error message? You can find the documentation
    at <http://xml.apache.org/xalan-j/extensions.html#ext-functions>.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Bjoern Hoehrmann, Apr 22, 2008
    #2
    1. Advertising

  3. harryajh

    harryajh Guest

    On 22 Apr, 11:40, Bjoern Hoehrmann <> wrote:
    > * harryajh wrote in comp.text.xml:
    >
    > >What I'd like to know is if there is anyway to specify a param passed
    > >in to the stylesheet as an argument in the extension function?

    >
    > >I currently something like this -

    >
    > > <xsl:value-of select="ext:getXSLTCode('part1', 'true')"/>

    >
    > >but what I'd like to do is something like this -

    >
    > > <xsl:param name="partNo"/>

    >
    > > <xsl:value-of select="ext:getXSLTCode($partNo, 'true')"/>

    >
    > >Obvioulsy this doesn't work & nor does having a nested value-of - has
    > >anyone any idea if this is actually possible? if not any workarounds?

    >
    > I am not sure what is obvious about this; perhaps you did not set the
    > parameter to a specific value? Does it work if you use string($partNo)
    > instead? Do you get some error message? You can find the documentation
    > at <http://xml.apache.org/xalan-j/extensions.html#ext-functions>.
    > --
    > Björn Höhrmann · mailto: ·http://bjoern.hoehrmann.de
    > Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
    > 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/


    Thankyou Björn for such a quick reply, I've tried both those methods
    and although no error is given the parameter is passedd empty!

    i.e

    <xsl:variable name="partNo" select="testvalue"/>
    <xsl:value-of select="ext:getXSLTCode(string($partNo), $partNo)"/>

    in my Java code

    public static String getXSLTCode(String key, String internalOnly)
    ...

    both key & internalOnly == ""
    harryajh, Apr 22, 2008
    #3
  4. * harryajh wrote in comp.text.xml:
    >Thankyou Björn for such a quick reply, I've tried both those methods
    >and although no error is given the parameter is passedd empty!
    >
    >i.e
    >
    > <xsl:variable name="partNo" select="testvalue"/>


    Do you have an element <testvalue> at the right position and if yes,
    what is its contents? If you wanted to specify a string, you have to
    put it in quote marks like so:

    <xsl:variable name="partNo" select=" 'testvalue' "/>

    I've added spaces around the value to clarify what I mean. If you do
    not quote the value, it will treat the identifer as element name.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Bjoern Hoehrmann, Apr 22, 2008
    #4
  5. harryajh

    harryajh Guest

    On 22 Apr, 12:24, Bjoern Hoehrmann <> wrote:
    > * harryajh wrote in comp.text.xml:
    >
    > >Thankyou Björn for such a quick reply, I've tried both those methods
    > >and although no error is given the parameter is passedd empty!

    >
    > >i.e

    >
    > > <xsl:variable name="partNo" select="testvalue"/>

    >
    > Do you have an element <testvalue> at the right position and if yes,
    > what is its contents? If you wanted to specify a string, you have to
    > put it in quote marks like so:
    >
    > <xsl:variable name="partNo" select=" 'testvalue' "/>
    >
    > I've added spaces around the value to clarify what I mean. If you do
    > not quote the value, it will treat the identifer as element name.
    > --
    > Björn Höhrmann · mailto: ·http://bjoern.hoehrmann.de
    > Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
    > 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/


    think I've fixed it now Björn, not really sure what the problem was,
    many thanks for your help!
    harryajh, Apr 22, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand
    Replies:
    3
    Views:
    874
    Tim Daneliuk
    Nov 8, 2003
  2. Christian Seberino
    Replies:
    3
    Views:
    1,163
    Christian Seberino
    Feb 5, 2004
  3. Steve
    Replies:
    3
    Views:
    26,943
    Steve
    Aug 25, 2006
  4. Elhanan
    Replies:
    0
    Views:
    540
    Elhanan
    Jan 23, 2007
  5. llothar
    Replies:
    17
    Views:
    1,241
    Steve Holden
    Apr 7, 2008
Loading...

Share This Page