Saturday, June 11, 2011

Preceding-Sibling | The Easy Way

Keeping on track with my previous post regarding the preceding-sibling approach to getting unique values with XSL, I prefer to not have to do the Muench method whenever possible. I like to keep it simple. Here is a really simple way to get a unique or distinct list of categories and sub-categories from an xml file:




<xsl:for-each select="item">
<xsl:variable name="thisNodeCategory" select="Category"/>
<xsl:if test="not(preceding-sibling::item[Category=$thisNodeCategory])">
<span class="Category">
<a href="">
<xsl:value-of select="Category" />
</a>
</span>
<br/>
</xsl:if>
<xsl:if test="SubCategory > ''">
<span class="subCategory">
- <a href="">
<xsl:value-of select="SubCategory" />subcategory
</a>
</span>
<br/>
</xsl:if>
</xsl:for-each>

Friday, June 10, 2011

Easier than preceding-sibling::

I don't like to use preceeding-sibling. It doesn't work when I want it to. So, I created a method that works just like it:



This method is a lot easier to implement. But, it doesn't work with <xsl:sort>. It requires the XML be in the correct sort order before doing the XSL Transform. If you don't have this luxury, you can use the method I will post in the following blog post. Or, if you are really brave, you can use the Muench Method. I think I posted how to do that in a previous post. Well, anyway you decide to do it, good luck.




<xsl:variable name="thisChildNode" select="Category"/>
<xsl:variable name="lastNodePosition" select="position() - 1"/>
<xsl:if test="not(/grandParentNode/parentNode[$lastNodePosition]/childNode = $thisChildNode)">
<h2><xsl:value-of select="childNode" /></h2>
</xsl:if>

Sunday, March 13, 2011

PORDL Mobile Pages Released

By request, every XSL transform on PORDL now comes with its own mobile-ready webpage.

Example:
Pastor's Blog

You can point your cell phone directly to the page or setup a sub-domain for your website to point to the page.

It is also really easy to create a mobile website by adding html navigation to the top or bottom of your XSL stylesheets and pointing the nav links to other PORDL transforms.

Sunday, February 27, 2011

Nested List Sitemap From a Flat XML File

I needed to build a Sitemap where each sub-level is indented more than the top levels...a very typical sitemap. However, my XML file was not in the order it needed to be output to the page and it was a flat XML file, so I couldn't pull the hierarchy from the XML.

I decided to do a template for each level of the sitemap and trigger each template recursively at each level till no more items were available on the level.

It took about 15 hours of staring at code that didn't work till I got it right.

Here is my solution:

Nested Sitemap from a Flat XML File

Thursday, February 17, 2011

Creating SQL Statements from an XML File

I worked up an XSL Stylesheet to transform a two-column Excel file into a SQL Update Statement.

Here is my order of events:

I saved the Excel File as a .csv file.

I used creativyst.com to change the .csv to an XML file.

I put a XML header on the file:

I saved the XML file to a web server where I could access it with a URL.

I used PORDL to create a new feed transform with the following XSL:



The output was a clean SQL Update Statement I could use to do a mass update of records on an OsCommerce database.

Friday, February 11, 2011

Grouping XSL Search Results

How to group XML items using the Muenchian Method

It took a while to figure this out because no one on the internet had a really good example that was easy to port over for my uses. So, I created an XSL sheet that can easily be ported to most any application.

Saturday, January 29, 2011

Embed Any Google News Search Result on Any Website or Blog

Using PORDL.com, you can easily embed any Google News Search result on any website or blog. Create your RSS feed using the following format:

http://news.google.com/news?q=web&output=rss

where the "web" portion of the string is your web search terms.

The output can look like the following example, or any way you desire:

http://pordl.com/transform.aspx?id=528

depending on the XSL template you use.

Tuesday, January 18, 2011

Site Map XSL : Valid for SiteMap.org Specification XML

I was chasing my tail for a while trying to figure out why my XSL stylesheets were not working with every XML sitemap I tried. The problem was, every XML sitemap I tried was using an invalid XML namespace. They were using a namespace hosted on Google at http://www.google.com/schemas/sitemap/0.84. This namespace is invalid. Some were referencing http://www.google.com/schemas/sitemap/0.9 which is also invalid. The correct working namespace to use is http://www.sitemaps.org/schemas/sitemap.0.9 .

Here is a really simple version of the XSL required to render the Site Map XML (with valid namespace) as HTML:



I, also, added this XSL as one of the many default XSL choices when setting up feed transforms on PORDL.com.

Monday, January 10, 2011

Friday, January 7, 2011

Scrolling Feeds are Now Available

Until now, there was only one really reliable way to embed an RSS feed as a scrolling news ticker on a site. That was Googles Ajax Feed Scroller. Google's code could not be customized in any possible configuration. It couldn't handle any RSS/Atom/XML feed. And it was really hard to implement... requiring two large javascript files, an Google API key, a Google Ajax call, and an confusing script to embed on the site.

Now, you also have PORDL's feed scroller. It's everything Google's code doesn't do and more. Here is a sample:
http://pordl.com/scroller_demo.aspx

Wednesday, January 5, 2011

New Generic RSS XSLT Sheet

I created a new generic XSL stylesheet for RSS feeds. It handles more types of feeds, looks more professional, and is easier to customize. I did a mass-update of about 350 feeds on the site with this new stylesheet.

Twitter XSLT Stylesheet

I uploaded a new generic XSL Stylesheet for Twitter feeds. It looks far better than the previous stylesheet.