1

So I'm trying to create a sitmap with xml and an xslt files.

I want the URL's for the sitemap to be clickable when displayed (VERY new to this)... here is as far as I got:

<h3>Sitemap</h3>
<xsl:for-each select="urlset/url">
<p>
    <xsl:element name="a">
    <xsl:attribute name="href">
        <xsl:value-of select="loc"/>
    </xsl:attribute>
    <xsl:text>Link</xsl:text>
    </xsl:element>
</p>
</xsl:for-each>

any know how to change the word "Link" to be the URL of the site address its directing to? whilst still keeping the hyperlink in there?

I have already tried:

<h3>Sitemap</h3>
<xsl:for-each select="urlset/url">
<p>
    <xsl:element name="a">
    <xsl:attribute name="href">
        <xsl:value-of select="loc"/>
    </xsl:attribute>
    <xsl:text><xsl:value-of select="loc"/></xsl:text>
    </xsl:element>
</p>
</xsl:for-each>

But I get an error :(

HELP?

1
  • What is your XSLT processor (Xalan, Saxon)? And what is your error? Commented Feb 15, 2013 at 7:24

2 Answers 2

1

The <xsl:text> element cannot have any child elements. Try removing the <xsl:text> element from around <xsl:value-of select="loc"/>.

Sign up to request clarification or add additional context in comments.

Comments

1

You don't need the extra-<xsl:text> tag as <xsl:value> will already create a text node :

The xsl:value-of element is instantiated to create a text node in the result tree.

Moreover, as @eero-helenius already stated <xsl:text> doesn't accept child elements.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.