About

I'm Mike Pope. I live in the Seattle area. I've been a technical writer and editor for over 30 years. I'm interested in software, language, music, movies, books, motorcycles, travel, and ... well, lots of stuff.

Read more ...

Blog Search


(Supports AND)

Google Ads

Feed

Subscribe to the RSS feed for this blog.

See this post for info on full versus truncated feeds.

Quote

I learned that you cannot follow the entire Bible. It's impossible. You must pick and choose. Everyone does it, whether they admit it or not. Otherwise, we'd end up stoning adulterers on the street. Some call this "cafeteria religion," and it's meant as a disparaging phrase. But I say: There is nothing wrong with cafeterias! I've had some great meals at cafeterias. The key is to chose the right dishes -- the ones about compassion and tolerance, and leave the ones about hatred and intolerance on the side.

AJ Jacobs



Navigation





<October 2014>
SMTWTFS
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

Categories

  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  

Contact

Email me

Blog Statistics

Dates
First entry - 6/27/2003
Most recent entry - 10/16/2014

Totals
Posts - 2312
Comments - 2502
Hits - 1,675,483

Averages
Entries/day - 0.56
Comments/entry - 1.08
Hits/day - 405

Updated every 30 minutes. Last: 5:35 AM Pacific


  01:26 AM

I was perusing a back issue of Gunderloy's Daily Grind and found an article by Peter Freitag about a neat idea -- applying a CSS style sheet to your RSS feed. Raw RSS feeds look all XML-ish in the browser, but you can link the feed to a style sheet and then it can look nice(r). All you need to do is add a line like this:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="http://you.com/rss.css" ?>
<rss>
...
</rss>
(Well, and there is the small matter of creating the style sheet -- Freitag illustrates that, too.)

This sounded like fun. I added one to my comments feed (example), which was easy, because I keep the feed's XML skeleton in a text file, as described before.[1]

I then turned my attention to the main feed. I implemented that way back when as a Web service (.asmx).[2] I read a skeleton for that, too, and then fill in the <rss> element and children with a bunch of tedious XmlElement-ing.

But I could not get the feed to include the style sheet link. I checked that the skeleton was indeed being read from the file, as expected, but somehow the <?xml-stylesheet ?> element was just never getting in there.

It took me some time to realize that my skeletal <?xml version="1.0" ?> element wasn't getting in there, either. The element was showing up -- or a version of the element was -- but it wasn't being put there by me. Hmmm. Hmmm.

Aha. I figured out that although I was supplying the <rss> guts, the whole XML stream was actually, really being produced by the Web service. As in, the stream being sent to the browser was all the result of SOAP magic, and in the transformation to and from SOAP, the Web service paid no nevermind to anything outside the actual <rss> content I was sending.

Slightly to my surprise, I found an article by "cmumford" on CodeProject.com that explained this and illustrated the solution. As he says: "Unfortunately, this involves serializing the object to a stream, deserializing it into a XmlDocument, and then reserializing it after first attaching the processing directive."

Oh. Well, that's not going to happen. So one of these days, in my copious spare time, I guess I'll rewrite the main feed to be a handler instead of a Web service, which will give me direct control over what gets sent down the wire. And when I get around to that, keep your eye out for a much prettier feed.


[1] Naturally -- oh, how so very surprising -- IE and Firefox differ in support for applying CSS to XML tags with namespaces e.g. <dc:creator>. Firefox supports the proposed new syntax; IE6 does not. (AFAIK) Firefox will in fact ignore the namespace if you don't provide a URL and will apply CSS rules to tags as if they didn't have a namespace. I haven't tested any of this on IE7.

[2] Which I'll blame on Chris Anderson, whose BlogX I used as my very first model for creating this blog. :-)

[categories]   ,

|