Blog Post File Format

I decided previously to use an RSS <item> as the file format for a blog post.  Looking into the MetaWeblogAPI, it seems like that was a good move, since posting with MetaWeblogAPI involves simply sending the <item> to post. 

So there’s two things to do:

  • Figure out the SQL query to use with Community Server to get the data I need out
  • Write some XML code to take this data and write it to disk as an XML file

The SQL Query looks like this:

1
2
3
4
5
6
7
8
9
10
11
SELECT cs_Posts.PostDate, cs_Posts.Subject, cs_Posts.Body
FROM cs_Posts INNER JOIN cs_Sections
  ON cs_Posts.SectionID = cs_Sections.SectionID
LEFT OUTER JOIN cs_weblog_Weblogs
 ON cs_Posts.SectionID = cs_weblog_Weblogs.SectionID
LEFT OUTER JOIN cs_Threads
 ON cs_Posts.ThreadID = cs_Threads.ThreadID
LEFT OUTER JOIN cs_weblog_Posts
 ON cs_Posts.PostID = cs_weblog_Posts.PostID
WHERE
 (cs_Posts.PostLevel = 1) AND (cs_Sections.Name = N'steve''s blog')

This gets me 3 output columns:  PostDate, Subject, and Body.  Perfect.  Substitute my blog name for yours if you’re going to reuse this query.

Populating a DOM with these is a simple matter:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Element rootNode = xmlDoc.createElement("item");
xmlDoc.appendChild(rootNode);

Element titleNode = xmlDoc.createElement("title");
titleNode.setTextContent(subject);
rootNode.appendChild(titleNode);

Element bodyNode = xmlDoc.createElement("description");
bodyNode.setTextContent(body);
rootNode.appendChild(bodyNode);

Element dateNode = xmlDoc.createElement("pubDate");
dateNode.setTextContent(date.toString());
rootNode.appendChild(dateNode);

Now I want to figure out what the common way to write out XML with Java is.  I found the wrong way to do it.  Actually that page says “Serialization has been left as a task for vendor specific classes”.  It’s hard to believe that something as core as writing XML would be left out of the framework.

Fortunately Sun has a page that shows how to write out a DOM as an XML file (as part of their XSLT tutorial, strangely enough). 

Where in C# you’d simply write:

1
doc.Save("MyFile.xml");

The equivalent in Java is something like this:

1
2
3
4
5
6
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
File f = new File("MyFile.xml");
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(f);
transformer.transform(source, result);

I’m not sure why Java is so needlessly obtuse, but there it is.

But now that this part is done, I have a directory containing an xml file containing an <item> for every blog posting I wrote with .Text over the last few years.  391 items.  I’ve put the raw items here.

An idea I’ve been working on lately is using OPML to identify collections of things like mail messages and blog posts, and having web tools work with those collections, wherever they may be, rather than managing their own private copy of the data.  It’d be great to be able to refer to the Flickr metadata they manage for my photos directly, rather than having to do it through their API.  But that’s another story.

 

Leave a Reply

 




 
buy cheap Endep online buy cheapest Endep and Endep how to order Amitriptyline online without prescription buy Amitriptyline without rx from us pharmacy online Amitriptyline purchase purchase online prescription Amitriptyline without purchasing Amitriptyline online without prescription order generic Amitriptyline buy Endep no prescriptions how to order Endep online without prescription comprare Endep generico Endep online buy Endep in england buy cheap Endep online free consult Endep purchased online without prescription what is Endep Endep tabletten buy Endep no perscription cod Endep non rx fedex overnight free want to buy Anafranil in usa Aricept overdose buy discount Aricept on line Aricept buy Aricept online Aricept order buy Aricept pills Nizoral suppliers cheap order rx Nizoral canada Nizoral order Nizoral usa cod comprar Nizoral generico buy Nizoral 200 mg buy cheap Nizoral under without rx buy cheap Nizoral with dr. prescription Prozac 200 mg buy Lisinopril australia el Nizoral generico buy Lisinopril tablets without rx next day delivery Lisinopril with no script buy Lisinopril c o d purchase arimidex no scams order Arimidex order amex Arimidex canadian pharmacy buy Arimidex without doctor order rx free Arimidex buy Abilify with american express buy Abilify cod where can i purchase Abilify without a prescription order Finpecia without a prescription cheap order rx Finpecia purchase Famvir no visa online without prescription buy Famvir paypal without rx buy Famvir without Famvir without prescription medications Famvir without persription purchase Famvir online no membership overnight shipping Famvir no physician approval Amitriptyline purchase order Amitriptyline free next day airAmitriptyline on line buy next day Fluoxetine buy Fluoxetine line purchase Fluoxetine cod delivery buy Fluoxetine 20 mg purchase Fluoxetine buy cheap Fluoxetine under without rx purchase Fluoxetine visa without prescription Fluoxetine by mail Fluoxetine for pets Fluoxetine 10mg Amitriptyline purchase online how to order Famvir online without a rx Prozac Amitriptyline no perscription Famvir next day purchase Anafranil no prescription cheap buy cheapest Anafranil next day delivery on Anafranil saturday Anafranil buy Anafranil buy Anafranil overnight where to purchase Anafranil no prescription no fees Anafranil drug buy Lisinopril where Lisinopril buy on line order Lisinopril online no membership overnight shipping no prescription required for Lisinopril order maxalt cash on delivery Maxalt from canada buy cheapest Maxalt purchase Maxalt visa without prescription buy Maxalt uk Maxalt 10 mg purchase Maxalt no visa online without prescription purchase generic Lisinopril online Lisinopril no prescription to buy maxalt order online no membership overnight how to get a arimidex rx Aricept without a perscription fedex Aricept overnight without a prescription Donepezil prescription order buy genuine Aricept Aricept uk sales buy Amitriptyline with amex Accutane 40 mg delivered overnight buy brand Accutane 40 mg Accutane 40 mg orderd online without prescription where to purchase generic Accutane 40 mg online without a rx how to get 40 mg Accutane without next day delivery 40 mg Accutane with no script buy Amitriptyline online Accutane 40 mg online no prescription buy Accutane 40 mg online us pharmacy Accutane 40 mg best buy buy Accutane 40 mg c o d order 40 mg Accutane cash on delivery no presciption 40 mg Accutane