Subject: XSL : template for attribute From: "Chanukov Orit" <orit@xxxxxxxxxxxxxxx> Date: Wed, 28 Apr 1999 17:57:17 +0200 |
Thank You very match for help . I added it and it works now . I work with IE 5.0 . I have number of another problems with attributes . Could You please help me again ? Different nodes of my XML have attribute "colr" . According to value of this attribute I need to output text with different color . If I write in XSL the following , it's works fine : <xsl:template match="Field"> <p > <xsl:attribute name="STYLE">color: <xsl:choose> <xsl:when test="@colr[.='2']">white</xsl:when > <xsl:when test="@colr[.='0']">green</xsl:when > <xsl:otherwise >black</xsl:otherwise > </xsl:choose> </xsl:attribute> <xsl:apply-templates /> </p> </xsl:template> 2. If I tried to write template for this attribute , it doesn't work correctly - it each time goes to the " otherwise" case . What wrong here ? <xsl:template match="Field"> <p > <xsl:apply-templates select="@colr"/> <xsl:apply-templates /> </p> </xsl:template> <xsl:template match="@colr"> <xsl:attribute name="STYLE">color: <xsl:choose> <xsl:when test="@colr[.='2']">white</xsl:when > <xsl:when test="@colr[.='0']">green</xsl:when > <xsl:otherwise >black</xsl:otherwise > </xsl:choose> </xsl:attribute> </xsl:template> 3. If I removed < p > and </p > from <Field> node , it doesn't work : it outputs "STYLE=color:black" as text . Why ? What is a solution if I don't want to use <p> and </p> ? Thanks in advance , Any comments will be appreciated . Orit Chanukov . -----Original Message----- From: Kay Michael <Michael.Kay@xxxxxxx> Date: Tue, 27 Apr 1999 17:55:43 +0100 You have written a template to process this attribute but you haven't invoked it. <xsl:apply-templates> processes the child character nodes and child elements but not the attributes. To process the attributes, write <xsl:apply-templates select="@*"/> Alternatively write <xsl:if test=".[@crlf]"><br /></xsl:if> in the parent template (exact syntax depends what product you are using, you should always say). Mike Kay -----Original Message----- From: Chanukov Orit [mailto:orit@xxxxxxxxxxxxxxx] Sent: 27 April 1999 15:49 To: XSL-List@xxxxxxxxxxxxxxxx Subject: XSL : template for attribute Hello . How should I write template for attribute ? In my XML file I have , for example , the following line : <Field line="16" offset="1" colr="8" crlf="1" >Selection or command</Field> crlf attribute should insert <&br> to the output . Different nodes of XML tree have this attribute ( not only Field ) . in XSL file I wrote the following : <xsl:template match="text()"><xsl:value-of /></xsl:template> <xsl:template match="Field"> <xsl:apply-templates /> </xsl:template> <xsl:template match="@crlf"> <br></br> </xsl:template> It doesn't work . What wrong here ? See attached XML and XSL files . Thanks in advance , Orit . 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: XSL : template for attribute, Kay Michael | Thread | RE: XSL : template for attribute, David Schach |
Re: Formatting Objects considered h, Paul Prescod | Date | RE: XSL : template for attribute, David Schach |
Month |