Troubles with coding

Feb 25, 2012 at 7:14 AM
Edited Feb 26, 2012 at 7:30 AM

Hello Yves,

thank you for advice with ISBN/ISSN script, you showed me principles under the hood of your templates and therefor I found another ideas, what I would like implement, but I meet some troubles, since I'am not experienced with xsl.

For example, I want to implement code, that search field Year and if there is letter "c", then write copyright sign befor year. I think that I fail to properly use string $year and I need some help with <xsl:value-of select>. Here is the code, that I wrote and is not working.


 <!-- Handle years and years accessed. -->
<xsl:when test="starts-with($name, 'Year') and string($source/*[local-name() = $name])">
                    <xsl:value-of select="translate($source/*[local-name() = $name], 'cC()-1234567890', '&copy;&copy;')"/>
                    <xsl:call-template name="format-year">
                      <xsl:with-param name="year" select="translate($source/*[local-name() = $name], 'cC()-&copy;', '')"/>
                      <xsl:with-param name="options" select="$options"/>


It is inserted into your code, that you use for Year and YearAccessed. In our citation norm, we sometimes need to add dash and or copyright symbol to the year field, and because you handle with Years as numbers, I need to clean parameter year for template operations. I tried to use translate function.

Then, if in $source/b:Year exists letter "c" (or (c). C, (C)), a want to write copyright symbol befor year. I tried to use function translate as well, but with no success (as well).

At last, but not least, I want to add dash at the end of year, in some fields with new option e.g. ":d", if there is no dash in year field. This is for citation of Periodical or Journal sources, where our norm need to specific years, for which the source was printed (e.g. 1987-1996) and if it is still printed, then add only year of beginning and dash behind it (e.g. 1987- ), so, if someone insert only year of begining and forget to insert dash, it would be inserted automaticaly. This one I  would solve as xsl:when test for option 'd' and if true, test for contains dash if not, add <xsl:text>&dash;</xsl:text> at the end.