HTML in XSL User-Defined Functions

Discussion in 'XML' started by mySpamB8@gmail.com, Jun 8, 2006.

  1. Guest

    I'd like to output an HTML fragment from an XSL UDF, but the HTML tags
    aren't being output (just non-html values show up in the output). As a
    noob, I'm probably missing some fundamental piece of info.

    For instance, the following yields simply "hello" in my HTML output:

    <xsl:function name="jj:test">
    <td>hello</td>
    </xsl:function>

    Also, it would be a bonus if someone would guide me to some good, free,
    online XSLT (2) documentation.

    Thanks,
    Jamie
     
    , Jun 8, 2006
    #1
    1. Advertising

  2. wrote:

    > Also, it would be a bonus if someone would guide me to some good, free,
    > online XSLT (2) documentation.


    It depends on what you are looking for in terms of depth but I think the
    Saxon documentation Michael Kay provides here
    <http://www.saxonica.com/documentation/xsl-elements/intro.html>
    <http://www.saxonica.com/documentation/functions/intro.html>
    <http://www.saxonica.com/documentation/expressions/intro.html>
    is rather helpful for a start.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jun 8, 2006
    #2
    1. Advertising

  3. wrote:
    > I'd like to output an HTML fragment from an XSL UDF, but the HTML tags
    > aren't being output (just non-html values show up in the output). As a
    > noob, I'm probably missing some fundamental piece of info.
    >
    > For instance, the following yields simply "hello" in my HTML output:
    >
    > <xsl:function name="jj:test">
    > <td>hello</td>
    > </xsl:function>



    You have not shown us how you call that function, if you do e.g.
    <xsl:copy-of select="jj:test()" />
    then I am sure the td element will be there in the result tree.
    If you use e.g.
    <xsl:value-of select="jj:test()" />
    then you get what you ask for, the string value of that td element node
    the function returns.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jun 8, 2006
    #3
  4. Martin Honnen wrote:

    > You have not shown us how you call that function, if you do e.g.
    > <xsl:copy-of select="jj:test()" />
    > then I am sure the td element will be there in the result tree.


    I think an even better way is to use e.g.
    <xsl:sequence select="jj:test()" />
    as that avoids copying the node.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jun 8, 2006
    #4
  5. > Also, it would be a bonus if someone would guide me to some good, free,
    > online XSLT (2) documentation.


    As others have said, it depends on what you want. There are a fair
    number of articles/tutorials on XML-related topics on DeveloperWorks
    http://www.ibm.com/xml

    The XSLT FAQ website is _VERY_ useful
    http://www.dpawson.co.uk/xsl/index.html
    and if you're serious about this you may want to subscribe to the
    mailing list it draws from, which is a bit more focused than this newsgroup:
    http://www.mulberrytech.com/xsl/xsl-list/

    And of course the official specs are available from the W3C's website
    http://www.w3.org
    though reading those takes a certain amount of experience.


    Mike Kay's XSLT book is _not_ free, but is a pretty darned good
    human-readable reference for XSLT. I used it frequently while I was
    coming up to speed.
     
    Joe Kesselman, Jun 8, 2006
    #5
  6. Peter Flynn Guest

    wrote:
    > I'd like to output an HTML fragment from an XSL UDF, but the HTML tags
    > aren't being output (just non-html values show up in the output). As a
    > noob, I'm probably missing some fundamental piece of info.


    Yep. http://xml.silmaril.ie/authors/html/

    ///Peter
     
    Peter Flynn, Jun 10, 2006
    #6
    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. Neil Zanella

    accessing user defined utility functions

    Neil Zanella, Jan 18, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    1,151
  2. Replies:
    1
    Views:
    3,687
    A. Bolmarcich
    May 27, 2005
  3. Kourosh
    Replies:
    6
    Views:
    872
    Peter Flynn
    May 17, 2006
  4. Oodini
    Replies:
    1
    Views:
    1,838
    Keith Thompson
    Sep 27, 2005
  5. Replies:
    1
    Views:
    538
    Sion Arrowsmith
    Jul 10, 2008
Loading...

Share This Page