Subject: RE: How dynamic is XSL? From: Søren Neigaard <neigaard@xxxxxxxxxxxxxx> Date: Thu, 10 Aug 2000 19:00:18 +0200 |
Well... It seems like I cant have a template inside a template. How do I then start and stop my XSL document, plus having some templates in between? I tried the following (can you see what I wanted to do?): <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <!-- root of XML document --> <xsl:processing-instruction name="cocoon-format">type="text/html"</xsl:processing-instruction> <wml> <template> <do type="prev" label="Back"> <prev/> </do> </template> <xsl:for-each select="card"> <card> <xsl:attribute name="id"> <xsl:value-of select="cardid"/> </xsl:attribute> <xsl:attribute name="title"> <xsl:value-of select="cardtitle"/> </xsl:attribute> <xsl:template match="img"> <p> <xsl:attribute name="align"> <xsl:value-of select="imgalign"/> </xsl:attribute> <img> <xsl:attribute name="src"> <xsl:value-of select="imgsrc"/> </xsl:attribute> <xsl:attribute name="alt"> <xsl:value-of select="imgalt"/> </xsl:attribute> </img> </p> </xsl:template> <xsl:template match="link"> <p> <xsl:attribute name="align"> <xsl:value-of select="linkalign"/> </xsl:attribute> <a> <xsl:attribute name="href"> <xsl:value-of select="linkhref"/> </xsl:attribute> <xsl:value-of select="linktitle"/> </a> </p> </xsl:template> <xsl:template match="text"> <p> <xsl:attribute name="align"> <xsl:value-of select="textalign"/> </xsl:attribute> <xsl:value-of select="value"/> </p> </xsl:template> </card> </xsl:for-each> </wml> </xsl:template> </xsl:stylesheet> -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Linda van den Brink Sent: 10. august 2000 13:36 To: 'xsl-list@xxxxxxxxxxxxxxxx' Subject: RE: How dynamic is XSL? I assume that you want your output to be an equally arbitrary mix? Then that's easy to accomplish with xsl:template and xsl:apply-templates. Just write a template for each of your elements, and these template rules will fire whenever an element is found in the input document. If you would use xsl:for-each, then as you say if the xsl:for-each selects links, these would be processed first, and then if you have a second xsl:for-each select="text", the text would be processed next. xsl:for-each involves building up the resutl and 'pulling' data from the source file, while xsl:template/apply-templates involves reading the source XML and 'pushing' data to the result. I don't have a sample of your source so I'm leaving it at this rather abstract explanation. Linda XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: How dynamic is XSL?, Linda van den Brink | Thread | RE: How dynamic is XSL?, Søren Neigaard |
Re: Antwort: comments. (Re: key() R, David Tolpin | Date | RE: How dynamic is XSL?, Ben Robb |
Month |