HTML in XSL User-Defined Functions

G

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
 
M

Martin Honnen

M

Martin Honnen

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.
 
M

Martin Honnen

Martin said:
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.
 
J

Joe Kesselman

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,002
Messages
2,570,261
Members
46,858
Latest member
FlorrieTuf

Latest Threads

Top