[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: date formatting function
> Now, the bigger question: I need to later internationalize date > formatting. To that end, , where the root of the config file I am > using to configure the formatting will hold an xml:lang attribute > ("cs:citationstyle/@lang") . > > So: > > a) how to do this with the above approach? format-date() accepts parameters to indicate the language you want to use, which will affect, for example, the names used for months. However, it won't affect whether the month comes before the day. That's because most countries don't have a single standard way of displaying dates - if you look at British newspapers, for example, each one does it differently. Also, of course, the number of languages supported "out of the box" in a given processor may not include all the languages you want. (Saxon basically includes English, plus German more as an example of how to roll-your-own than as a genuine part of the product). > > b) what are the advantages/disadvantages of the format-date approach > above, versus the below (which is what I currently have)? In > theory, I > guess the format-date approach is only useful if it already > handles all > of the internationalization of month formatting I'm doing manually > below. In either case, I need to change things to make more > configurable with respect to order and punctuation (9 September 2000 > vs. September 9, 2000, etc.). Your code only seems to be handling English. Obviously if you write your own formatting you can make it more flexible but it's more code to write and test. > > <xsl:template match="mods:date | mods:dateIssued | > mods:url/@dateLastAccessed"> > <xsl:variable name="month-part"> > <xsl:choose> > <xsl:when test="substring(.,6,2) = '01'">January</xsl:when> > <xsl:when test="substring(.,6,2) = '02'">February</xsl:when> > <xsl:when test="substring(.,6,2) = '03'">March</xsl:when> > <xsl:when test="substring(.,6,2) = '04'">April</xsl:when> > <xsl:when test="substring(.,6,2) = '05'">May</xsl:when> > <xsl:when test="substring(.,6,2) = '06'">June</xsl:when> > <xsl:when test="substring(.,6,2) = '07'">July</xsl:when> > <xsl:when test="substring(.,6,2) = '08'">August</xsl:when> > <xsl:when test="substring(.,6,2) = '09'">September</xsl:when> > <xsl:when test="substring(.,6,2) = '10'">October</xsl:when> > <xsl:when test="substring(.,6,2) = '11'">November</xsl:when> > <xsl:when test="substring(.,6,2) = '12'">December</xsl:when> > <xsl:otherwise></xsl:otherwise> > </xsl:choose> > </xsl:variable> A minor observation, you could write this much more consisely and efficiently as <xsl:variable name="month-part" select="('January', 'February', 'March', ...) [xs:int(substring(current(),6,2)]"/> Michael Kay http://www.saxonica.com/
|
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
|