Project

Profile

Help

Erroneous spacebands inserted by Saxon

Added by Anonymous over 19 years ago

Legacy ID: #3084880 Legacy Poster: Greg Mellinger (mellingg)

I have a function call in which I pass the current reference number, punctuation that may follow the reference number, and the total number of references in the journal: <xslt:value-of select="cjs:format_ref_enum(regex-group(1),regex-group(2),$ref_cnt)"/> The purpose of the function is to 'pad' the reference enumerator with enspaces when required, output the enumerator, punctuation, and Xyvision markup: <xslt:function name="cjs:format_ref_enum"> <xslt:param name="ref_enum"/> <xslt:param name="ref_punc"/> <xslt:param name="ref_ttl"/> <xslt:variable name="xpp-tag" select="$pml2/journal/article/section[@name='citation']"/> <xslt:if test="$pml1/journal/article/section[(@name='citation') and (@pad_enum='1')]"> <xslt:variable name="ref_ttl_chars" select="string-length(string($ref_ttl))"/> <xslt:variable name="ref_cur_chars" select="string-length(string($ref_enum))"/> <xslt:value-of select="for $i in ($ref_cur_chars + 1) to $ref_ttl_chars return '&#x2002;'"/> </xslt:if> <xslt:choose> <!-- Return Specific Article Type Markup --> <xslt:when test="$xpp-tag ne ''"> <xslt:sequence select="$ref_enum"/> <xslt:sequence select="$ref_punc"/> <xslt:sequence select="$xpp-tag"/> </xslt:when> <!-- Return Regular Article Markup --> <xslt:otherwise> <xslt:value-of select="$ref_enum"/> <xslt:value-of select="$ref_punc"/> <xslt:value-of select="$pml1/journal/article/section[@name='citation']"/> </xslt:otherwise> </xslt:choose> </xslt:function> When run, in my output I receive the following: <citation citation-type="book"> 1 . &#8194;<ix> The enumerator is prefixed with a spaceband and followed by a spaceband and the punctuation is also followed by a spaceband. Is this a problem with the design of the function or an issue with saxon8-1-1?


Replies (2)

RE: Erroneous spacebands inserted by Saxon - Added by Anonymous over 19 years ago

Legacy ID: #3085170 Legacy Poster: Michael Kay (mhkay)

Firstly, I suggest you always declare the return type of your functions. This forces you to make a choice: is this function returning one string, or a sequence of strings? If you want it to return one string, you will get a type error, because it is currently returning a sequence of strings. To fix this type error, you will have to change the function so that it concatenates the strings, for example by using string-join(). If you declare it to return multiple strings, then it becomes clear that the strings must be concatenated by the caller of the function. If you call the function from within xsl:value-of, as you have done, then you can achieve this most simply by adding the attribute separator="". By default, if the expression in the select attribute of xsl:value-of returns a sequence of strings, then they are output with space separation. Michael Kay

RE: Erroneous spacebands inserted by Saxon - Added by Anonymous over 19 years ago

Legacy ID: #3086424 Legacy Poster: Greg Mellinger (mellingg)

Thanks Mike!

    (1-2/2)

    Please register to reply