abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Calavera" <david.calav...@gmail.com>
Subject Re: XML stylesheet and W3C standard implementation
Date Wed, 23 Jan 2008 08:52:22 GMT
On Jan 23, 2008 12:22 AM, James M Snell <jasnell@gmail.com> wrote:

> The challenge with PI's is that there actually is no single correct
> syntax for them.  There's just the target and the value.  Whether or not
> the value is structured depends entirely on the target.
>
> To associate an xml-stylesheet PI with a feed, you need to do it like
> this:
>
>   Abdera abdera = Abdera.getInstance();
>   Feed feed = abdera.newFeed();
>   Document doc = feed.getDocument();
>   doc.addProcessingInstruction(
>     "xml-stylesheet",
>     "href=\"foo.css\" type=\"text/css\"");
>   doc.writeTo(System.out);
>
> Keep in mind also that IE7 and FF 2.x will likely ignore the stylesheet.


There are a little trick in order to force IE7 and FF2.x to use your
stylesheet. Look at this article:

http://www.ibm.com/developerworks/xml/library/x-think40/

A little excerpt:

The only way to work around this and force the use of your chosen stylesheet
> is to fool the simple heuristic Firefox uses to check for Web feeds, which
> involves sniffing the first 512 bytes of the file for the words "rss" or
> "feed". Listing 2 uses the well-known workaround inserting a comment
> designed to pad out this 512 bytes.
>
> *Listing 2. Atom feed with workaround for Firefox 2.0 and Internet
> Explorer 7 stylesheet default handling*
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <!-- Firefox 2.0 and Internet Explorer 7 use simplistic feed sniffing to override
desired
> presentation behavior for this feed, and thus we are obliged to insert this comment,
a
> bit of a waste of bandwidth, unfortunately. This should ensure that the following
> stylesheet processing instruction is honored by these new browser versions. For some
more
> background you might want to visit the following bug report:
> https://bugzilla.mozilla.org/show_bug.cgi?id=338621
> -->
> <?xml-stylesheet type="text/xml" href="atom2html.xslt"?>
> <feed xmlns="http://www.w3.org/2005/Atom"
>       xml:lang="en"
>       xml:base="http://www.example.org">
> <!-- content of the feed identical to listing 1, so trimmed -->
> </feed>
>
>



-- 
David Calavera
http://www.thinkincode.net

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message