Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to use XSLT to output a tab

Featured Replies

Hello, I'm trying to output a field in HTML (via XSLT)B) this field data are 'formatted' using some tab (CTRL+TAB) in .fp7 file but the XSLT transformation ignore those TABs treating them as simple space (nbsp; like).

Is there any way to show the correct tabulation instead? I tried using translate(filed_text, ' ','& nbsp;') but it didn't work.

Edited by Guest

What should they be translated to (as there are no tabs in HTML)?

  • 4 months later...

Yes, XSLT recognizes the tabs as whitespace.

What you could do is the following:

Use a calculation field and the FM Substitute function to replace the tab character with the amount of spaces you desire.

In the XSLT, output the content of the calculation field with

tags around.

You could do the substitution in the XLST stylesheet itself - not much point in using one AND still maintain calculation fields purely for export purposes.

Anyway, this thread is 4 months old.

Ah yes? Then why did you give not the right answer four months ago?

What is the right answer?

An answer that might help him and others who search and read later this forum. That's why I also answer to posts that are not current.

Of course there are many ways (or procedures) for tab substitution. And one can also do with XSLT only, as you mentioned. But the problem here is that one can't use the translate() function, because it replaces only char-by-char, but one needs to substitute tab by several spaces, and that maybe several times. With XSLT 1.0, this can only be done using recursion.

That's why I suggested to use FM's Substitute() function (as a quick fix). It's more powerful than several lines of XSLT code for doing the same thing.

See XSLT recursion examples on http://www.dpawson.co.uk/xsl/sect2/replace.html

I don't know that replacing the tabs with a number of spaces is "the right answer". When I replied to the OP, the request was "to show the correct tabulation" - and there was no mention of spaces. Even now I am not convinced that spaces are the optimal solution.

In any case, I cannot see anything wrong with asking the OP for a clarification, and I think your "rebuke" was misplaced - both in its content and especially in its tone.

the problem here is that one can't use the translate() function

I didn't say one should use the translate() function. There are a lot of things in XSLT that require recursion - I've never found it to be a problem.

Not to mention that this CAN be done without recursion - see for example:

http://fmforums.com/forum/showtopic.php?tid/188654/post/315596/#315596

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.