Re: [xslt] How can I tell the type of output I receive?
- From: Dave Hyatt <hyatt apple com>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: Re: [xslt] How can I tell the type of output I receive?
- Date: Thu, 12 Aug 2004 15:51:57 -0700
Worked like a charm. I now have simple XSL transformations working!
(Cheer.) Thanks for the help.
Anyone have any good pointers to XSL examples that use
<?xml-stylesheet...> to load the XSL files? I tested with the ones on
devedge.netscape.com, but any other examples would be much appreciated,
especially ones that output HTML that wants to load subresources (like
images, scripts, or CSS files).
dave
On Aug 11, 2004, at 6:54 PM, William M. Brack wrote:
David Hyatt said:
I am very close to having a basic transform working in Safari. I am
using the following function:
xsltSaveResultTo
And I have collected the output from this call. The problem is that
I
now need to do three different things with this output depending on
whether it's HTML, XML/XHTML, or text. I notice from looking at the
source that xsltSaveResultTo has a lot of logic for figuring out
what
the type of the output is before it actually does the serialization.
Is there any way that I can get to this information, or is it not
exposed yet?
If it isn't exposed, could xsltSaveResultTo be enhanced in some way
to
provide some indicator of the type of the output?
Thanks!
dave
(hyatt apple com)
Reading the code of xsltSaveResultTo, it appears to me that there is
actually very little logic involved. Assuming that the variable
"result" is an xmlDocPtr pointing to the result of the
transformation and "style" is an xsltStylesheetPtr pointing to the
stylesheet, and further assuming everything has already been
verified/validated when xsltSaveResultTo was called, then:
-----------
const xmlChar *myMethod;
XSLT_GET_IMPORT_PTR(myMethod, style, method)
if ((myMethod == NULL) && (result->type == XML_HTML_DOCUMENT_NODE))
myMethod = (const xmlChar *) "html";
-----------
gives you what you are asking for - a string which says
"html" - it's HTML
"text" - it's TEXT
"xhtml"- it's XHTML
anything else, including NULL, is XML
The macro XSLT_GET_IMPORT_PTR is only needed to take care of the
proper cascading of imported stylesheets; if it's guaranteed there
are no imports, then style->method could be directly accessed.
HTH
Bill
_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt gnome org
http://mail.gnome.org/mailman/listinfo/xslt
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]