[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Nestled Template Surrealism
Hi Oliver, > I've created individual templates for each element in my xml > document, with these nestled within several book[test] templates. > Somewhere along the line I've made a mistake & now the document > fails to display at all. > What the problem is escapes me completely. I think the root of your problem here is that you never apply templates to the book elements. You need to have something like: <div align="center"> <xsl:apply-templates /> </div> where at the moment you have a commented-out xsl:for-each. > There is also a continuing problem getting the image_link template to > process properly. Your image_link template looks like: <xsl:template match="image_link"> <table> <tr> <td> <img> <xsl:attribute name="src"> <xsl:choose> <xsl:when test="image_link != ''"> <xsl:value-of select="image_link" /> </xsl:when> <xsl:otherwise>null.gif</xsl:otherwise> </xsl:choose> </xsl:attribute> </img> </td> </tr> </table> </xsl:template> Aside from the fact that you're producing a table with a single row and a single cell in it (which is a bit weird) your problem here is that when you try to set the value of the src attribute, you're testing whether the *current node* has an image_link child element. In this template, the current node *is* an image_link element, so really you want to test, and use the value of, the current node instead. So swap 'image_link' for '.' in the template: <xsl:template match="image_link"> ... <img> <xsl:attribute name="src"> <xsl:choose> <xsl:when test=". != ''"> <xsl:value-of select="." /> </xsl:when> <xsl:otherwise>null.gif</xsl:otherwise> </xsl:choose> </xsl:attribute> </img> ... </xsl:template> or, equivalently: <xsl:template match="image_link"> ... <img> <xsl:attribute name="src"> <xsl:value-of select="." /> <xsl:if test="not(string())">null.gif</xsl:if> </xsl:attribute> </img> ... </xsl:template> or even: <xsl:template match="image_link"> ... <img src="{concat(., substring('null.gif', 1 div not(string())))}" /> ... </xsl:template> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|