[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Missing hypertext text

Posted on 2011-02-19
3
Medium Priority
?
447 Views
Last Modified: 2012-06-27
Hi!

Any specific modifications to the below listed XML / XSLT as to how to recreate the below listed functionality using XML & XSLT?

<A HREF="mywebpage.html">My Web Page</A>

Currently, all of the urls are listed but no custom text like the above "My Web Page".
In other words, I rather have a user friendly text like "About Us" in lieu of
http://www.sample.com/aboutus.html displayed but still have a functionaly hypertext.

Also, do you have to include the domain name as part of the <loc> tag value or just the pagename for a valid sitemap?

Sample: XML

<?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
 <url>
  <loc>http://www.sample.com/mywebpage.html</loc>
  <changefreq>weekly</changefreq>
  <priority>1.00</priority>
  </url>
<url>
  <loc>http://www.sample.com/mynewpage.html</loc>
  <changefreq>weekly</changefreq>
  <priority>1.00</priority>
  </url>
</urlset>

XSLT:

<?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:priority" order="descending" 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:loc"/>
            </a>
        </p>
    </xsl:template>
</xsl:stylesheet>
0
Comment
Question by:TrueBlue
  • 3
3 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 34934859
XML sitemap don't have a way for adding a "name" of the relation
So you need to divert from the spec if you want to do that

There is no way creating the
"My New Page"
from
http://www.sample.com/mynewpage.html</loc>
unless you start stuffing full dictionairies in your XSLY

your best bet is to set the named reference as an extra element in the sitemap

<url>
  <loc>http://www.sample.com/mywebpage.html</loc>
  <alt>My Web Page</alt>
  <changefreq>weekly</changefreq>
  <priority>1.00</priority>
  </url>

and in the xslt
          <a href="{sm:loc}">
                <xsl:value-of select="sm:alt"/>
            </a>
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 34934883
Actually to do what I just suggested, it would be more correct to use the sitemap.org extension mechanism
(using a different namespace)


<?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns:trueblue="http://www.trueblue.org/sitemap/extensions" 
         xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
 <url>
  <loc>http://www.sample.com/mywebpage.html</loc>
  <trueblue:alt>My Web Page</trueblue:alt>
  <changefreq>weekly</changefreq>
  <priority>1.00</priority>
  </url>
<url>

Open in new window

0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 34934890
and make th eappropriate changes to the stylesheet as well


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:trueblue="http://www.trueblue.org/sitemap/extensions" 
    xmlns:sm="http://www.sitemaps.org/schemas/sitemap/0.9"
   version="1.0">
...
        <a href="{sm:loc}">
                <xsl:value-of select="trueblue:alt"/>
            </a>

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month17 days, 17 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question