mike's web log

 

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

Don't get too attached to your deathless prose, because the editor will change it. A good editor will improve your writing, but any editor will change it. In this respect editors are the same as dogs; when they see something new, they simply must mark it with their own scent.

Mike Gunderloy



 

Navigation






<April 2014>
SMTWTFS
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910


 

25 Most-Visited Entries

 

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
 

Blogs I Read

 

Contact

Email me
 

Blog Statistics

Dates
First entry - 6/27/2003
Most recent entry - 4/3/2014

Totals
Posts - 2298
Comments - 2480
Hits - 1,618,444

Averages
Entries/day - 0.58
Comments/entry - 1.08
Hits/day - 410

Update every 30 minutes. Last: 1:02 AM Pacific

 
   |  Stylin' with SOAP

posted at 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] ,