[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Format number problem
There's nothing obviously wrong with this. What processor are you using? Try it on a different processor to see if the bug is in your code or in the XSLT processor. Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > AXRAMAKR@xxxxxx > Sent: 12 June 2002 18:59 > To: Jeni Tennison > Cc: AXRAMAKR@xxxxxx; xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: Format number problem > > > > Jeni, > Thanks for your quick response. I too realise this should > work. Can't tell why it is not working though. > > This is the rest of the code > <xsl:stylesheet version = "1.0" xmlns:xsl > = "http://www.w3.org/1999/XSL/Transform"> > <xsl:output method = "text"/> > <xsl:template match = "/"> > <xsl:apply-templates/> > </xsl:template> > <xsl:template match = "/ceo_di_msg"> > <xsl:text>CHK*</xsl:text> > <xsl:value-of select = "@usrid"/> > <xsl:text>*</xsl:text> > <xsl:value-of select = "@tsktmdt"/> > <xsl:apply-templates/> > </xsl:template> > <xsl:template match = "ceo_di_msg/car_msg"> > <xsl:text> </xsl:text> > <xsl:text>EQP*</xsl:text> > <xsl:apply-templates/> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/car_id"> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="."/> > <xsl:with-param name="length" select = "'10'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/custcsn"> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="."/> > <xsl:with-param name="length" select = "'9'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/csn"> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="."/> > <xsl:with-param name="length" select = "'9'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/car_data"> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@le"/> > <xsl:with-param name="length" select = "'1'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@wbnbr"/> > <xsl:with-param name="length" select = "'6'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@wbdt"/> > <xsl:with-param name="length" select = "'8'"/> > </xsl:call-template> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/evt_data"> > <xsl:apply-templates/> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/evt_data/evt1"> > <xsl:text> </xsl:text> > <xsl:text>EV1*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@evcd"/> > <xsl:with-param name="length" select = "'2'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@stpcd"/> > <xsl:with-param name="length" select = "'2'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@dfcd"/> > <xsl:with-param name="length" select = "'2'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@stprncd"/> > <xsl:with-param name="length" select = "'2'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@iostp"/> > <xsl:with-param name="length" select = "'1'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@evdt"/> > <xsl:with-param name="length" select = "'12'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@yrd"/> > <xsl:with-param name="length" select = "'5'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@splc"/> > <xsl:with-param name="length" select = "'9'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:value-of select = 'format-number(@zne, "00")'/> > <xsl:text>*</xsl:text> > <xsl:value-of select = 'format-number(@trck, "000")'/> > <xsl:text>*</xsl:text> > <xsl:value-of select = 'format-number(@spt, "00")'/> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@rptcbr"/> > <xsl:with-param name="length" select = "'4'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@evcbr"/> > <xsl:with-param name="length" select = "'4'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@fnacbr"/> > <xsl:with-param name="length" select = "'4'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@hlcbr"/> > <xsl:with-param name="length" select = "'4'"/> > </xsl:call-template> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/evt_data/evt2"> > <xsl:text> </xsl:text> > <xsl:text>EV2*</xsl:text> > <xsl:call-template name="ev2Orpl2"></xsl:call-template> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/evt_data/pl2"> > <xsl:text> </xsl:text> > <xsl:text>PL2*</xsl:text> > <xsl:call-template name="ev2Orpl2"></xsl:call-template> > </xsl:template> > <xsl:template name = "ev2Orpl2"> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@secnb"/> > <xsl:with-param name="length" select = "'1'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@trnsb"/> > <xsl:with-param name="length" select = "'7'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@trndy"/> > <xsl:with-param name="length" select = "'2'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@trndte"/> > <xsl:with-param name="length" select = "'8'" /> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@yblk"/> > <xsl:with-param name="length" select = "'4'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@tblk"/> > <xsl:with-param name="length" select = "'4'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@ofltrn"/> > <xsl:with-param name="length" select = "'10'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:value-of select = 'format-number(@gswg, "000000")'/> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/evt_data/evt3"> > <xsl:text> </xsl:text> > <xsl:text>EV3</xsl:text> > <xsl:apply-templates/> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/evt_data/pl3"> > <xsl:text> </xsl:text> > <xsl:text>PL3</xsl:text> > <xsl:apply-templates/> > </xsl:template> > <xsl:template match > = > "/ceo_di_msg/car_msg/evt_data/evt3/evtdesc|/ceo_di_msg/car_msg > /evt_data/pl3/evtdesc"> > > > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="."/> > <xsl:with-param name="length" select = "'3'"/> > </xsl:call-template> > </xsl:template> > <xsl:template match = "/ceo_di_msg/car_msg/evt_data/pl1"> > <xsl:text> </xsl:text> > <xsl:text>PL1*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@evcd"/> > <xsl:with-param name="length" select = "'2'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@stpcd"/> > <xsl:with-param name="length" select = "'2'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@dfcd"/> > <xsl:with-param name="length" select = "'2'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@stprncd"/> > <xsl:with-param name="length" select = "'2'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@iostp"/> > <xsl:with-param name="length" select = "'1'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@evdt"/> > <xsl:with-param name="length" select = "'12'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@yrd"/> > <xsl:with-param name="length" select = "'5'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@splc"/> > <xsl:with-param name="length" select = "'9'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:value-of select = 'format-number(@zne, "00")'/> > <xsl:text>*</xsl:text> > <xsl:value-of select = 'format-number(@trck, "000")'/> > <xsl:text>*</xsl:text> > <xsl:value-of select = 'format-number(@spt, "00")'/> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@rptcbr"/> > <xsl:with-param name="length" select = "'4'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@evcbr"/> > <xsl:with-param name="length" select = "'4'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@fnacbr"/> > <xsl:with-param name="length" select = "'4'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@hlcbr"/> > <xsl:with-param name="length" select = "'4'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@nsd"/> > <xsl:with-param name="length" select = "'1'"/> > </xsl:call-template> > <xsl:text>*</xsl:text> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padVar" select ="@fsd"/> > <xsl:with-param name="length" select = "'1'"/> > </xsl:call-template> > </xsl:template> > > <xsl:template name="append-pad"> > <!-- recursive template to left justify and append --> > <!-- the value with whatever padChar is passed in --> > <xsl:param name="padVar"/> > <xsl:param name="length"/> > <xsl:variable name="padChar" select = "' '"/> > <xsl:choose> > <xsl:when > test="string-length($padVar) < $length"> > <xsl:call-template name="append-pad"> > <xsl:with-param name="padChar" > select ="$padChar"/> > <xsl:with-param name="padVar" > select="concat($padVar,$padChar)"/> > <xsl:with-param name="length" > select ="$length"/> > </xsl:call-template> > </xsl:when> > <xsl:otherwise> > <xsl:value-of select="substring > ($padVar,1,$length)"/> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > </xsl:stylesheet> > Thanks, > > Akila > > > > > > Jeni Tennison > > <jeni@jenitenniso To: > AXRAMAKR@xxxxxx > n.com> cc: > xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: > Format number problem > 06/12/02 12:49 PM > > Please respond to > > Jeni Tennison > > > > > > > > > > Hi Akila, > > > I want to append 0s to numbers to pad them to the required length. > > > > <xsl:value-of select = 'format-number(@zne, "00")'/> > > > > is my code for formatting the zne attribute to two digits. > So if zne > > is 1 I want to display 01. Is this code correct? It is not working. > > Your code is correct (assuming you haven't changed the > default decimal format). Either there's something buggy in > your processor or something is wrong elsewhere in your code. > > Cheers, > > Jeni > > --- > Jeni Tennison > http://www.jenitennison.com/ > > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > 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
|