Subject: RE: How dynamic is XSL? From: Søren Neigaard <neigaard@xxxxxxxxxxxxxx> Date: Thu, 10 Aug 2000 21:53:47 +0200 |
Ok - great. But where does the missing "</img>" go? --------REPOST OF FILES--------- <?xml version="1.0"?> <?xml-stylesheet href="example.xsl" type="text/xsl" media="explorer"?> <?cocoon-process type="xslt"?> <card> <cardid>index</cardid> <cardtitle>WAP XML Test</cardtitle> <img> <imgalign>center</imgalign> <imgsrc>Graphics/header.wbmp</imgsrc> <imgalt>Header</imgalt> </img> <text> <textalign>left</textalign> <value>Choose a link:</value> </text> <link> <linkalign>left</linkalign> <linkhref>Sub02-A1.jhtml</linkhref> <linktitle>Coastlines</linktitle> </link> <link> <linkalign>left</linkalign> <linkhref>#about</linkhref> <linktitle>About</linktitle> </link> </card> <?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:apply-templates/> </card> </xsl:for-each> </wml> </xsl:template> <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> </xsl:stylesheet> --------------------------------------- And I expected this result: --------------------------------------- <wml> <template> <do type="prev" label="Back"> <prev/> </do> </template> <card id="index" title="WAP XML Test"> <p align="center"> <img src="Graphics/header.wbmp" alt="Header"> </p> <p align="left"> Choose a link: </p> <p align="left"> <a href="Sub02-A1.jhtml">Coastlines</a> </p> <p align="left"> <a href="#about">About</a> </p> </card> </wml> --------------------------------------- But I got this instead: --------------------------------------- <wml> <template> <do label="Back" type="prev"> <prev></prev> </do> </template> <card id="index" title="WAP XML Test"> index WAP XML Test <p align="center"> <img alt="Header" src="Graphics/header.wbmp"> </p> <p align="left"> Choose a link: </p> <p align="left"> <a href="Sub02-A1.jhtml">Coastlines</a> </p> <p align="left"> <a href="#about">About</a> </p> </card> </wml> --------REPOST OF FILES--------- -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Ben Robb Sent: 10. august 2000 20:29 To: 'xsl-list@xxxxxxxxxxxxxxxx' Subject: RE: How dynamic is XSL? Within your XML you have the following: <card> <cardid>index</cardid> <cardtitle>WAP XML Test</cardtitle> ... </card> Your "apply-templates" sees the cardid and cardtitle tags, and, failing to find a matching template, moves on. However, there is also a default template for text elements, which has the form of: <xsl:template match="text()"> <xsl:value-of select="." /> </xsl:template> This prints out the value of any text elements it finds. So, either negate the default by putting this line in: <xsl:template match="text()"/> or, specify empty templates for <cardid> and <cardtitle> <xsl:template match="cardid"/> <xsl:template match="cardtitle"/> or, if you can play with the DTD/ Schema of the incoming XML, make it so that it has the following structure (which is probably the best solution): <card id="index" title="WAP XML Test"> ... </card> Rgs, Ben 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?, Ben Robb | Thread | RE: How dynamic is XSL?, Carlos Araya |
Possible to create HDML?, Caras, Yuko | Date | RE: How dynamic is XSL?, Jeni Tennison |
Month |