make three columns instead of one

Hi!

We are using the below listed XSLT to display our XML sitemap.
We have alot of links, so we think it would be easier to read if there were three columns.
Any specific modifications so that the XSLT would display these links in three columns (in a grid if possible) instead of one would be greatly appreciated.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sm="http://www.sitemaps.org/schemas/sitemap/0.9"
   version="1.0">
    <xsl:output method="html" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xsl:template match="sm:urlset">
        <html>
            <body>
                <xsl:apply-templates select="sm:url">
                    <xsl:sort select="sm:alt" order="ascending" data-type="text"/>
                </xsl:apply-templates>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="sm:url">
        <p>
            <a href="{sm:loc}">
                <xsl:value-of select="sm:alt"/>
            </a>
        </p>
    </xsl:template>
</xsl:stylesheet>
TrueBlueAsked:
Who is Participating?
 
Geert BormansInformation ArchitectCommented:
Yes, two XSLT files indeed
The first one we worked on can be used to create the html sitemap from your master sitemap
The second one can be used to generate the xml sitemap from the master sitemap
(the master sitemap being the xml sitemap plus extension)

the first XSLT you call when the html sitemap is requested
the second XSLT is called when the xml sitemap is requested
basically instead of statically serving /sitemap.xml, make sure that you have some code that generates that /sitemap.xml on request
(or run the second XSLT from time to time when you need to change the sitemap.xml because the master sitemap had changed)
0
 
Geert BormansInformation ArchitectCommented:
Try this

I removed the ordering because that would make things substantially more difficult.
Let me know if the sorting is crucial
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sm="http://www.sitemaps.org/schemas/sitemap/0.9"
    version="1.0">
    <xsl:output method="html" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xsl:param name="num-of-cols" select="3"/>
    <xsl:template match="sm:urlset">
        <html>
            <body>
                <table border="1">
                    <xsl:apply-templates select="sm:url[position() mod $num-of-cols = 1]"/>
                </table>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="sm:url">
        <tr>
            <xsl:for-each select="self::sm:url | following-sibling::sm:url[position() &lt; $num-of-cols]">
                <td>
                    <a href="{sm:loc}">
                        <xsl:value-of select="sm:alt"/>
                    </a>
                </td>
            </xsl:for-each>
        </tr>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
TrueBlueAuthor Commented:
Gertone,

I know you mentioned that the alt tag was not strict XSLT.
Google webtools gave an error like below for each occurence of the alt tag in our XML sitemap page:
Invalid XML tag
This tag was not recognized. Please fix it and resubmit. Parent tag: url
Tag: alt

Would these errors go away by using the namespace method you suggested?
TIA
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Geert BormansInformation ArchitectCommented:
yes, these errors would go away with a different namespace
(at least when the validator supports sitemap extensions, most will)
0
 
TrueBlueAuthor Commented:
Gertone,

Apparently Google does not support sitemap extensions because I tried the method with a different namespace and Google gives the same errors.
Does everyone have to maintain two sitemaps?
One for search engines and one for users.
0
 
Geert BormansInformation ArchitectCommented:
I don't know actually, I never worked with XML sitemaps before and I must say that I was shocked to find out that a sidemap has no way of adding user friendly information to it.
I started reading into this and yes, xml sitemaps are meant for search engines only, not for human consumption.

No, you don't need to maintain two sitemaps.
I would recommend to make one sitemap as you did, but filter out the alt field
You can use the XSLT we worked on so far to create the HTML three column sitemap

You can use the XSLT that I include with this message for generating the google xml sitemap
(assuming you did not put the alt in a different namespace

All from your one source sitemap

Hope this helps
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sm="http://www.sitemaps.org/schemas/sitemap/0.9"
    version="1.0">
    <xsl:output method="xml" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xsl:template match="node()">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates select="node()"></xsl:apply-templates>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="sm:alt"/>
</xsl:stylesheet>

Open in new window

0
 
TrueBlueAuthor Commented:
Gertone,

First, thank you for your exceelent help.
Are you saying have two xslt files?
If so, currently I call only one from the XML page.
So how would I know which one to call?
TIA
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.