|
|
 Rank: Enthusiast
Joined: 7/2/2008 Posts: 34 Location: India
|
Hi, I have written the following code to get the output in XML but failed to get the output... I need to pass the XML value to a flash through javascript... Quote:<?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" exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/> <xsl:template match="/"> <div id="topmenu"> <script type = "text/javascript">
function getLinks(menutype) {alert ('hello');
MenuXML = ' <xsl:call-template name="drawNodes"> <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::root//node "/> <xsl:with-param name="id" select="string('menuList')"/> </xsl:call-template> '
document.write (MenuXML) }
getLinks(1); </script> </div> </xsl:template> <xsl:template name="drawNodes"> <xsl:param name="parent"/> <xsl:param name="id"/> <menulinks> <!--<xsl:if test="$id != ''"> <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute> <xsl:attribute name="class"><xsl:value-of select="string('adxm menu')"/></xsl:attribute> </xsl:if> <xsl:if test="$id = ''"> <xsl:attribute name="id">submenu<xsl:value-of select="current()/@id"/></xsl:attribute> <xsl:attribute name="class">sublist</xsl:attribute> </xsl:if>-->
<xsl:for-each select="$parent/node [ @nodeTypeAlias != 'News Item' and @nodeTypeAlias != 'Event' and @nodeTypeAlias != 'umbracoBlogPost' and @nodeTypeAlias != 'umbracoBlogDateFolder' and @nodeTypeAlias != 'umbracoBlogComment' and string(data [@alias='umbracoNaviHide']) != '1' ]"> <menulink MenuLink="{umbraco.library:NiceUrl(@id)}"> <xsl:attribute name="MenuTitle"><xsl:value-of select="@nodeName"/></xsl:attribute> </menulink>
<xsl:call-template name="drawNodes"> <xsl:with-param name="parent" select="."/> </xsl:call-template>
</xsl:for-each> </menulinks>
</xsl:template>
</xsl:stylesheet> thanks in anticipation... Amritanshu Good judgment comes from experience, and often experience comes from bad judgment. So experience is simply the name we give our mistakes...
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,694 Location: KY, USA
|
Tim had a nice little xmlOutput macro for just this kind of situation. It was on his old blog. Maybe he can post a link or put it on his new blog? Also, you'll need to be more detailed about what your macro does (or doesn't) do. Simply saying it fails to give the output is not very much to go on. Please help us help you. cheers, doug.
MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
|
|
 Rank: Enthusiast
Joined: 7/2/2008 Posts: 34 Location: India
|
Sorry drobar for not making myself clear.. my macro goes and get all nodes and sub nodes link and node name..it does check that node should not belong to categories mentioned ... I am then intent to pass this to a flash file through javascript... what I am getting now is 2 time </menulink></menulink> which is not what I wish... also can you send me the links of Tim blog so that I can check that too ...
thanks, amritanshu
Good judgment comes from experience, and often experience comes from bad judgment. So experience is simply the name we give our mistakes...
|
|
 Rank: Enthusiast
Joined: 7/2/2008 Posts: 34 Location: India
|
Ok got them working ... thanks Quote:<?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" exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="html"/>
<xsl:param name="currentPage"/> <xsl:template match="/"> <div id="topmenu"> <script type = "text/javascript">
function getLinks(menutype) {alert ('hello');
MenuXML = ' <xsl:call-template name="drawNodes"> <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::root//node "/> <xsl:with-param name="id" select="string('menuList')"/> </xsl:call-template> ' MenuHTML = '<span id="links"> <xsl:value-of select="@nodeName"/></span>'
New XMLDoc = XMLDoc.load(MenuXML)
document.write (escape(MenuXML) )
}
getLinks(1); </script> </div> </xsl:template> <xsl:template name="drawNodes"> <xsl:param name="parent"/> <xsl:param name="id"/> <menulinks> <!--<xsl:if test="$id != ''"> <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute> <xsl:attribute name="class"><xsl:value-of select="string('adxm menu')"/></xsl:attribute> </xsl:if> <xsl:if test="$id = ''"> <xsl:attribute name="id">submenu<xsl:value-of select="current()/@id"/></xsl:attribute> <xsl:attribute name="class">sublist</xsl:attribute> </xsl:if>-->
<xsl:for-each select="$parent/node [ @nodeTypeAlias != 'News Item' and @nodeTypeAlias != 'Event' and @nodeTypeAlias != 'umbracoBlogPost' and @nodeTypeAlias != 'umbracoBlogDateFolder' and @nodeTypeAlias != 'umbracoBlogComment' and string(data [@alias='MainMenuHide']) != '1']"><!--it will hide the page where we select this property as true i.e.,"1"--> <menulink MenuLink="{umbraco.library:NiceUrl(@id)}"> <xsl:attribute name="MenuTitle"><xsl:value-of select="@nodeName"/></xsl:attribute> </menulink>
<xsl:if test="count(./node) > 0"> <xsl:call-template name="drawNodes"> <xsl:with-param name="parent" select="."/> </xsl:call-template> </xsl:if> </xsl:for-each> </menulinks>
</xsl:template>
</xsl:stylesheet>
Good judgment comes from experience, and often experience comes from bad judgment. So experience is simply the name we give our mistakes...
|
|
|
Guest |