Inserting external HTML into xsl output

E

eva.mukhija

Hi

I need to insert some html content generated by certain business logic
into an xsl output. I have been able to insert custom Java extensions
and generate the HTML to be outputted. My problem is that xsl
transformation is not resulting in rendering the content as HTML. I've
tried xsl:copy-of and xsl:text. I think it is probably generating a
text node with the given content and writes entire html code as it is
rather than rendering it. Can somebody provide the solution?/

Thanks
Eva
 
J

Joe Kesselman

I think it is probably generating a
> text node with the given content and writes entire html code as it is
> rather than rendering it

Probably.

You didn't say which processor you're using. With Xalan, one solution
would be for the extension to return the generated content as a DOM
subtree rather than as text. That would give Xalan the information it
needs to recognize handle the content as nodes rather than as text.

With other processors, all I can suggest is that you check their
documentation for their own extension features. This is not
well-standardized, unfortunately.
 
M

Martin Honnen

I need to insert some html content generated by certain business logic
into an xsl output. I have been able to insert custom Java extensions
and generate the HTML to be outputted. My problem is that xsl
transformation is not resulting in rendering the content as HTML. I've
tried xsl:copy-of and xsl:text. I think it is probably generating a
text node with the given content and writes entire html code as it is
rather than rendering it.

You can try whether the XSLT processor supports disable-output-escaping
<http://www.w3.org/TR/xslt#disable-output-escaping>
e.g
<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
You should however take note that disable-output escaping is an optional
feature that is usually only support if the XSLT result is serialized to
a string or stream. And it might not even be supported at all by an XSLT
processor.
 
J

Joseph Kesselman

Martin said:
You can try whether the XSLT processor supports disable-output-escaping

Good thought, worth a try if you really want to insert the fragments as
text. Xalan does support that feature, for what it's worth.
 
J

Joseph Kesselman

For information about writing a Xalan extension -- what the function can
return and how Xalan will interpret it -- see
http://xml.apache.org/xalan-j/extensions.html

I don't think there's an example in the Xalan samples/extensions
directory that returns a value that becomes a Node-Set or Result Tree
Fragment, but that's what you would want if you want to yield something
that Xalan will consider an XML tree. As that website documents, a
returned DOM Node or NodeIterator will be treated by Xalan as an XSLT
node-set, with the exception of a DocumentFragment node which will be
treated as an XSLT Result Tree Fragment. (The distinction between RTFs
and nodesets will be going away in XSLT 2.0, for what that's worth.)
 

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
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top