none
XSLT format to not break at "-"

    Question

  • I have the following line in my xslt file <xsl:value-ofselect="translate(ClaimDiagnosisCodes, '-', '&#160;')"/> but what I really want to do is not replace the dash with a non breaking space but format it to not break when the "-" is encountered.  I want to keep the entire string on the same line.  Does anyone know a good way to do this?

    Thank you in advance for any help that is offered.

    Friday, December 20, 2013 1:58 PM

Answers

  • I thought perhaps you could add a zero-width non-joiner (&#8204;) after each dash; that does the job in Firefox 25 but unfortunately has no effect in Internet Explorer 9.

    I guess you'll have to split the string at spaces and put a separate span element around each sequence of non-space characters.  You can do that by using the substring-before and substring-after functions in a recursive template.

    Alternatively, there may be some character that looks like a dash but does not cause the line to be broken.  Such a hack might cause problems for screen readers and Braille displays, though.

    • Marked as answer by codeguy444 Friday, December 20, 2013 7:06 PM
    Friday, December 20, 2013 6:20 PM

All replies

  • If you're generating HTML, put <span style="white-space: nowrap">...</span> around the string.

    I hope the forum will preserve the formatting in the following sample.

    1. No special formatting; text can break: ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC
    2. With "white-space: nowrap": ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC-ABC
    Friday, December 20, 2013 5:41 PM
  • Thank you but unfortunately it did not work.  The problem is not it breaking or wrapping at a space but at a "-" (dash).  I actually want it to break at the space but not at the dash.
    Friday, December 20, 2013 6:00 PM
  • I thought perhaps you could add a zero-width non-joiner (&#8204;) after each dash; that does the job in Firefox 25 but unfortunately has no effect in Internet Explorer 9.

    I guess you'll have to split the string at spaces and put a separate span element around each sequence of non-space characters.  You can do that by using the substring-before and substring-after functions in a recursive template.

    Alternatively, there may be some character that looks like a dash but does not cause the line to be broken.  Such a hack might cause problems for screen readers and Braille displays, though.

    • Marked as answer by codeguy444 Friday, December 20, 2013 7:06 PM
    Friday, December 20, 2013 6:20 PM
  • Thank you again, unfortunately our default browser is IE.  I have talked to our business users and they will allow me, for display purposes, to replace the dash with a non-breaking space.  so with allowance I can make it display properly.  I really appreciate your help.
    • Marked as answer by codeguy444 Friday, December 20, 2013 7:05 PM
    • Unmarked as answer by codeguy444 Friday, December 20, 2013 7:06 PM
    Friday, December 20, 2013 7:05 PM