[ANN] Kludgey workarounds for IE and Netscape
James Clark
jjc at jclark.com
Thu Sep 10 13:50:43 BST 1998
Andy Dent wrote:
>
> At 14:19 +0800 9/9/98, Andrew Bunner wrote:
> >>The transformation part of XSL is intended to produce well-formed XML.
> My perspective may be a little different from others because my initial use
> of XML/XSL is for a report writer which renders to screen/print and only
> secondarily to RTF and HTML.
>
> The contrast with most of the tools I've looked at (and books I've read) is
> to an XSL community that appear concerned with transforming one set of XML
> to another. To be honest, I keep feeling there's something I've missed here
> - if the transformation is just generating more XML I don't see that
> containing enough information for a renderer.
>
> Is there anything in the standard which says that, if you are rendering to
> HTML, that you *have* to produce well-formed XML? If you have a server-side
> processor of XML/XSL that is producing HTML I don't see why there's a
> problem. Similarly, an embedded processor in a browser is surely free to
> make its own interpretation.
An XSL processor can do other things with the result tree than just
write it out as XML.
If you want to use XSL to produce some non-XML format, first you need to
devise an XML representation of it. For example, in the case of HTML,
this would be "well-formed HTML", that is XML using the element types
and attributes of XML. Now write some code that turns this XML
representation into the real thing. Now you've just got to arrange for
this code to get run instead of the usual code that writes the result
tree out as XML. You've got two possibilities. One possibility is to
make this a run-time option for your XSL processor. Another is to use
the result-ns attribute. To use this you need to define a namespace for
your HTML representation, make all result elements be from this
namespace, and specify this using result-ns. Then your XSL processor
can recognize the namespace and do the right thing. For example,
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/TR/WD-xsl"
xmlns:h="http://www.w3.org/TR/REC-html40"
result-ns="h">
<xsl:template match="/">
<h:html>
...
</h:html>
</xsl:template>
</xsl:stylesheet>
This gives an XSL processor everything it needs to recognize that you're
generating HTML and do the right thing so you get real HTML.
The XML representation for another format can be very simple. For
example, if you wanted to generate RTF, you could probably get away with
two element types: one element type for the root, and one element type
to contain RTF control information (outside elements of this type you
would escape {, } and \ as \{, \} and \\}, inside it you would not).
You might want an element type for \bin too.
James
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev
mailing list