Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Missing hypertext text

Posted on 2011-02-19
3
Medium Priority
?
444 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

636 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