Is there an easy way to mod a sitemap to support Google News Sitemap . I've been trying to find a way of including <news:news> into the XSLT and I keep getting errors.
OK, actually it shouldn't be a problem but try to remove the "news" prefix from the "exclude-result-prefixes" attribute then... then the processor should just include the namespace on the element and not repeat it anywhere else. (Edit: I've removed it from the sample code now, so that works).
Namespace display issues has everything to do about scopes - but the main thing you should know is this: The XML will work just fine (unless the parser reading it is seriously badly implemented).
If you like, post the full XSLT file here, and I can tell you what's going on...
Very short explanation - these 2 snippets are exactly the same to an XML parser:
<!-- update this variable on how deep your site map should be --> <xsl:variablename="maxLevelForSitemap"select="100"/> <xsl:variablename="today"select="umbraco.library:CurrentDate()" /> <xsl:variablename="later"select="umbraco.library:DateAdd($today, 'd', -20)" />
<xsl:templatematch="/"> <!-- change the mimetype for the current page to xml --> <xsl:value-ofselect="umbraco.library:ChangeContentType('text/xml')"/>
<xsl:templatename="drawNodes"> <xsl:paramname="parent"/> <xsl:iftest="$parent/ancestor-or-self::*//BlogPost [@isDoc and umbraco.library:DateGreaterThanOrEqual(PostDate, $later)]"> <xsl:for-eachselect="$parent/ancestor-or-self::* [@isDoc]/Blog [@isDoc]//BlogPost">
<!-- If the document does not have a template, nothing is shown in the frontend anyway. So this is not proper content and should not be in the sitemap --> <xsl:iftest="@template > 0"> <url> <loc> <xsl:value-ofselect="$urlPrefix" /><xsl:value-ofselect="umbraco.library:NiceUrl(@id)" /> </loc> <news:news> <news:publication> <news:name>Njection</news:name> <news:language>en</news:language> </news:publication> <news:publication_date><xsl:value-ofselect="umbraco.library:FormatDateTime(@updateDate, 'yyyy-MM-ddTHH:mm:ss+00:00')" /></news:publication_date> <news:title><xsl:value-ofselect="pageTitle"/></news:title> <news:keywords>Lifestyle, Automotive, Technology, <xsl:value-ofselect="metaKeywords"/></news:keywords> </news:news> </url> </xsl:if>
<xsl:iftest="(count(./* [@isDoc and string(umbracoNaviHide) != '1' and @level <= $maxLevelForSitemap]) > 0) or (count(./node [string(./data [@alias='umbracoNaviHide']) != '1' and @level <= $maxLevelForSitemap]) > 0)"> <xsl:call-templatename="drawNodes"> <xsl:with-paramname="parent"select="."/> </xsl:call-template> </xsl:if>
Creating a news sitemap in Umbraco.
www.google.com/.../answer.py?answer=93992
Is there an easy way to mod a sitemap to support Google News Sitemap . I've been trying to find a way of including <news:news> into the XSLT and I keep getting errors.
Hi Shannon,
You probably just forgot to declare the news: prefix + namespace - something along the lines of:
/Chriztian
That did it but now I have another issue. After including the name namespace, it's gets included in the <loc> location.
oops.. I ment in the <url>
OK, actually it shouldn't be a problem but try to remove the "news" prefix from the "exclude-result-prefixes" attribute then... then the processor should just include the namespace on the element and not repeat it anywhere else. (Edit: I've removed it from the sample code now, so that works).
/Chriztian
Thanks. I forgot to "include" it in the "exclude-result-prefixes" Works like a dream
Odd. Now the xmlns:news moved from the <loc> section to the <news:news> section
Hi Shannon,
Namespace display issues has everything to do about scopes - but the main thing you should know is this: The XML will work just fine (unless the parser reading it is seriously badly implemented).
If you like, post the full XSLT file here, and I can tell you what's going on...
Very short explanation - these 2 snippets are exactly the same to an XML parser:
- It doesn't matter where the namespace and its prefix gets defined, as long as it's in scope when used.
/Chriztian
is working on a reply...