Hi, I am currently trying to get the value of the html lang attribute.
Currently I have three buttons that change the value with JavaScript, however as the top menu is made in xslt I need it to change depending on what value html lang has. For example right now it says:
<html lang="sv-se"></html>
I tried using the following xslt code to output the attribute value:
Then, whenever you access an element/tag from the HTML document, you'll need to prefix it with the namespace "html:"...
<xsl:value-of select="html:html/@lang"/>
I know it seems like there are too many references to "html" in there ... but you can change the namespace to whatever you prefer (internally in the XSLT).
I might be mistaken, but how do you set the "lang" property of the HTML element? I don't see how you would access the rendered HTML document from a macro, unless it is specifically loaded as input.
@Lee Kelleher: how do you see this?
I personally think you (Carl Winblad) probably either have a site which, at some level, is split up in language nodes. In that case you could look up the chain to see in what language you are.
Or you're using a language mapped to a hostname, in which case you could determine your current culture using an XSLT extension method (no default method exists in umbraco.library).
How to get a html attribute?
Hi, I am currently trying to get the value of the html lang attribute.
Currently I have three buttons that change the value with JavaScript, however as the top menu is made in xslt I need it to change depending on what value html lang has. For example right now it says:
<html lang="sv-se"></html>
I tried using the following xslt code to output the attribute value:
<xsl:template match="/">
<h1>
<xsl:for-each select="html">
<xsl:value-of select="@lang"/>
</xsl:for-each>
</h1>
<h1><xsl:value-of select="html/@lang"/></h1>
<h1><xsl:apply-templates select="html"/></h1>
</xsl:template>
<xsl:template match="html">
<xsl:value-of select="@lang"/>
</xsl:template>
The site that I'm working on:
www.trollstigar.se
I hope there is an easy solution for my problem
Hi Carl,
The problem here is XML namespaces! Try adding the following to your XSLT:
Then, whenever you access an element/tag from the HTML document, you'll need to prefix it with the namespace "html:"...
I know it seems like there are too many references to "html" in there ... but you can change the namespace to whatever you prefer (internally in the XSLT).
Cheers, Lee.
I might be mistaken, but how do you set the "lang" property of the HTML element? I don't see how you would access the rendered HTML document from a macro, unless it is specifically loaded as input.
@Lee Kelleher: how do you see this?
I personally think you (Carl Winblad) probably either have a site which, at some level, is split up in language nodes. In that case you could look up the chain to see in what language you are.
Or you're using a language mapped to a hostname, in which case you could determine your current culture using an XSLT extension method (no default method exists in umbraco.library).
is working on a reply...