Been trying to crack this for a while but no joy! I basicaly want to create an XML (URL) which contains details on properties on my website.
In essence what i need is this following simple XSLT done in a way that when you go on the URL it's a XML format that can be red by RSS readers if that makes sense!
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@isDoc and @level = 1]" />
<xsl:for-each select="$siteRoot/descendant-or-self::*[@isDoc and name() = 'AProperty']">
Hi Lee, I wish unfortunatly just a spelling mistake made putting the code on here, heres my full XSLT which when going on the page shows everything i want but isnt in the usual XML and cant be read by a reader.
Not sure if it's a copy-n-paste issue (on this forum), but looks like you are escaping all the angle-brackets ... so the rendered "XML" output, is not really XML, but HTML-escaped text. If that's the case, try removing all the <xsl:text> elements and swapping all the escaped entities, (e.g. < and >) to proper angle-brackets.
Generate a custom XML feed
Hi all,
Been trying to crack this for a while but no joy! I basicaly want to create an XML (URL) which contains details on properties on my website.
In essence what i need is this following simple XSLT done in a way that when you go on the URL it's a XML format that can be red by RSS readers if that makes sense!
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@isDoc and @level = 1]" />
<xsl:for-each select="$siteRoot/descendant-or-self::*[@isDoc and name() = 'AProperty']">
<item>
<title><xsl:value-of select="@nodeNAme"/></title>
</item>
</xsl:for-each>
Hopefully it's simple an im being a bit silly!
Thanks
Pete
Hi Peter,
Looking at your example XSLT, it is most likely the casing of "@nodeNAme" (XSLT is case-sensitive), try "@nodeName", see if that works.
Cheers, Lee.
Hi Lee, I wish unfortunatly just a spelling mistake made putting the code on here, heres my full XSLT which when going on the page shows everything i want but isnt in the usual XML and cant be read by a reader.
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@isDoc and @level = 1]" />
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:call-template name="BOB">
</xsl:call-template>
</xsl:template>
<xsl:template name="BOB">
<xsl:text disable-output-escaping="yes"><?xml version="1.0" encoding="UTF-8"?></xsl:text>
<xsl:text><rss></xsl:text><br />
<xsl:text><channel></xsl:text><br />
<xsl:text><title></xsl:text>Premier Blog<xsl:text></title></xsl:text> <br />
<xsl:text><link></xsl:text>http://www.premiervillasinthesun.com/blog<xsl:text></link></xsl:text><br />
<xsl:text><description></xsl:text>Just another WordPress site<xsl:text></description></xsl:text><br />
<xsl:text><lastBuildDate></xsl:text>Tue, 05 Mar 2013 12:13:21 +0000<xsl:text></lastBuildDate></xsl:text> <br />
<xsl:text><language></xsl:text>en-US<xsl:text></language></xsl:text> <br />
<br />
<xsl:for-each select="$siteRoot/descendant-or-self::*[@isDoc and name() = 'AProperty']">
<xsl:text><item></xsl:text>
<xsl:text><title></xsl:text><xsl:value-of select="@nodeName"/> <xsl:text></title></xsl:text>
<xsl:text></item></xsl:text>
<br />
</xsl:for-each>
<xsl:text></channel></xsl:text><br />
<xsl:text></rss></xsl:text>
</xsl:template>
</xsl:stylesheet>
Not sure if it's a copy-n-paste issue (on this forum), but looks like you are escaping all the angle-brackets ... so the rendered "XML" output, is not really XML, but HTML-escaped text. If that's the case, try removing all the <xsl:text> elements and swapping all the escaped entities, (e.g. < and >) to proper angle-brackets.
Cheers, Lee.
Hi Lee,
Just trued it without but it seems to render even less on the page ah!
now using
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@isDoc and @level = 1]" />
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:call-template name="BOB">
</xsl:call-template>
</xsl:template>
<xsl:template name="BOB">
<rss><br />
<channel>
<title>Premier Blog</title> <br />
<link>http://www.premiervillasinthesun.com/blog</link><br />
<description>Just another WordPress site</description><br />
<lastBuildDate>Tue, 05 Mar 2013 12:13:21 +0000</lastBuildDate> <br />
<language>en-US</language> <br />
<br />
<xsl:for-each select="$siteRoot/descendant-or-self::*[@isDoc and name() = 'AProperty']">
<item>
<title><xsl:value-of select="@nodeName"/> </title>
</item>
<br />
</xsl:for-each>
</channel><br />
</rss>
</xsl:template>
</xsl:stylesheet>
Which when the url is loaded just gives me
http://www.premiervillasinthesun.com/blog
Just another WordPress site
Tue, 05 Mar 2013 12:13:21 +0000
en-US
Any ideas?
Ah i stand corrected has worked thanks!!
is working on a reply...