[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: creating a string of repeated characters or Paddin
So, I've read the exslt documentation on string padding but it's not exactly clear to me how I would invoke this function given the following excerpted xslt where I need ACTIVITY to always occupy positions 16-65 and MEMBER to occupy positions 66-165 in my fixed file output. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://www.exslt.org/strings" extension-element-prefixes="str" version="1.0"> <xsl:import href="str.padding.template.xsl" /> <xsl:template match="ROW"> <xsl:apply-templates select="ACTIVITY"/> <xsl:apply-templates select="MEMBER"/> <xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet> Any pointers/examples on how to implement the string padding function in this instance? Thanks, Chris -----Original Message----- From: Tim Watts [mailto:timw@xxxxxxx] Sent: Monday, July 16, 2001 3:21 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: creating a string of repeated charactors Thanks Jim, for the link to http://www.exslt.org/str/functions/padding/str.padding.template.xsl It seems that repeating charactors isn't a part of XSLT at this stage - not as a function The EXSLT function <xsl:value-of select="str:padding(10, '*')" /> function is the sort of thing I hoped might exist in *standard* XSLT. Since there isn't I'll use the template that you pointed me to instead. (Thanks for saving me from writing it! :) ) I was hoping that there might me a less verbose way of doing what really is quite a simple task. Tim For others interested, but don't feel like checking the links, the template is... <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" extension-element-prefixes="str"> <xsl:template name="str:padding"> <xsl:param name="length" select="0" /> <xsl:param name="chars" select="' '" /> <xsl:choose> <xsl:when test="not($length)" /> <xsl:when test="string-length($chars) >= $length"> <xsl:value-of select="substring($chars, 1, $length)" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="str:padding"> <xsl:with-param name="length" select="$length" /> <xsl:with-param name="chars" select="concat($chars, $chars, $chars)" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> -----Original Message----- From: cutlass there are many ways of doing this, try looking at the exslt.org link below http://www.exslt.org/str/functions/padding/index.html here is the link to the xslt template u may use http://www.exslt.org/str/functions/padding/str.padding.template.xsl u can directly use this individual template by either cutting and pasting or xsl:import ( u have to remember to either use the correct namespace if importing ). ----- Original Message ----- From: "Tim Watts" <timw@xxxxxxx> To: "XSL Mailing List (E-mail)" <XSL-List@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, July 16, 2001 5:10 AM Subject: creating a string of repeated charactors > I'm sure this must be a simple command, but how would something like a > string of 8 charactors be output in XSLT. > > In ASP it might look something like > String(8, "*") > 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
|