Jump to content
Server Maintenance This Week. ×

How to use XSLT to output a tab


AnFrusch@pepp

This topic is 5385 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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
Link to comment
Share on other sites

  • 4 months later...

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 5385 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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