[Home] [By Thread] [By Date] [Recent Entries]
Hello Roelof,
I'm not sure about what's going wrong with your script (http://symphony-cms.com/learn/articles/view/overriding-templates/ looks ok ?) but let me just suggest a tip with your XSLT. Le 31/12/2011 10:07, Roelof Wobben a C)crit : frontpage-article.xsl : I guess you expect here that each node will be ignored in the output except "section/entry", but you forgot about XSLT default's templates : see http://www.dpawson.co.uk/xsl/sect2/defaultrule.html#d3635e76 any other elements of your xml will passed trough these (default) templates : <xsl:template match="*"> <xsl:apply-templates/> </xsl:template> <xsl:template match="text()"> <xsl:value-of select="."/> </xsl:template> that means any text element which is not within a section/entry will go to the ouput. I suggest you ALWAYS match the root element in any XSLT, then you say what to do for nested elements. In your case, you can try this : <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:apply-templates select="data/recent-posts/section/entry | data/section/section/entry"/> <!-- I ignore image/section cause there is no title element here--> </xsl:template> <xsl:template match="section/entry"> <h2><value-of select="title" /></h2> </xsl:template> Here you can choose exactly which section element to output. You can also be more generic : <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="*"> <xsl:apply-templates /> </xsl:template> <xsl:template match="text()"> <!-- don't ouput text nodes--> </xsl:template> <xsl:template match="section/entry"> <h2><value-of select="title" /></h2> </xsl:template>
You can do the same more simple : <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="text()"/> <xsl:template match="section/entry"> <h2><value-of select="title" /></h2> </xsl:template>
Hope this help, Regards, Matthieu -- Matthieu Ricaud IGS-CP Service Livre numC)rique
|

Cart



