Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Where to call template in XSL


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

Recommended Posts

Posted

Here is a portion of the XSL I am trying to create for transforming my FM export into an RTF document. Just for simplicity, I've eliminated some of the RTF codes and show only the loop where I'm getting the data from the second field exported.












This is text data, so the paragraphs in COL[2] are separated by vertical tab characters which do nothing in the RTF. I have a template for replacing the vertical tabs with CRLF, but I don't know where to call it so that the replacements occur.



Here is the code for the template call. My problem could also be how I'm trying to call the template, but I'm so new at this that I don't understand.















My goal is to replace all of the vertical tabs in the exported text so that paragraph breaks show instead of having just one large paragraph. Any suggestions would be appreciated.

Thanks!

Brudderman

Posted (edited)

[i was going to post this earlier, but the forums were down, then I forgot.]

</p><p> I don't know exactly what you get for returns inside a text field when you export xml (without a stylesheet) on Windows. On a Mac I get a old-style Mac return, "&#013;", which is what you say you get. And you say you want a Unix return (line feed), "&#010;". In that case the following will work (simpler than template call).</p><p> </p><p> <xsl:variable name="data" select="fmp:COL[2]/fmp:DATA"/></p><p> <!-- translate Mac return to Unix return --></p><p> </p><p> <xsl:value-of select="translate($data, '&#013;', '&#010;')"/></p><p> </p><p> I'm putting the DATA into a variable first, then inserting the value returned from the translation.</p><p> </p><p> Is COL[2] the only one you need to run this on? Do you have a lot of COL's? If so there's probably a better way than writing COL[1], COL[2], ... for lots of them. That would be to use a Choose construction, running the above translate() for the column(s) needing it, but not for other columns. </p><p>

Edited by Guest
Posted

Ignore the tags. It was the only way I could get the code to not get translated by the forum's PHP. The "code" tags do not seem to be sufficient anymore.

Posted

Thanks, Fenton! Though I still haven't been able to get it to work yet, I'll keep looking for the problem.

The translate does look simpler, and I've gone with that. Because I don't know exactly what characters I'm dealing with right now, I've substituted a tilde (~) for FMP's paragraph marks before exporting. Now I'm trying to replace them with a pipe (|). When I can get this translation working, then I'll tackle the issue of what kind of return character(s) I need and modify the translate forumla.

So here's what I have now:

I've also ordered a book on XLST, and hopefully that will educate me enough to at least ask intelligent questions.

I'm just exporting two columns, and the first is quite small in terms of data. But the Choose does sound like a better way to go. If I can get the returns taken care of, I'll have a go at the choose, too.

Posted (edited)

If you only have 2 columns then you can just use your COL[1] and COL[2] specific syntax. "Choose" in xsl is much like Case (though quite a bit clunkier; more like an If script step). Pseudo code:

something

something else

default if nothing above is true; can be left blank

Edited by Guest
Posted

OK, I'm getting closer. I do have the transform working to replace "~" with "|", so I know that the syntax there is OK.

But now I actually want to replace "~" with a RTF paragraph break (par) and can't get that to work. Here is what I have in trying to set up a variable for the break:

par

What this gives me is not a break between the paragraphs, but just a literal backslash ().

Instead of the PAR variable, I've also tried these without success:

and

and

and

So any further thoughts on how to get the RTF paragraph break to work would be appreciated.

thanks for all the help so far.

Posted

The translate() function can only exchange a character (or characters) for another character or characters. The operating word is "character", not "word". It just does a 1... to 1... replacement. So the simplest thing is to translate 1 character for another. This line works for me:




So if it doesn't for you there is something else going on. I know it is frustrating trying to translate returns, partly 'cause you can't easily see the difference.

Posted

Thanks, Fenton! I came across the one character exchange limitation last night after reading up on transfer(), but I had already posted. :)

And I never have been able to get the to work, so I don't know what's going on.

But for now, I did solve the problem by exporting from FM by substituting the paragraph breaks (within a record) with the RTF code for a new paragraph (par). Who knows why I didn't think of that before, but I doubt that I would have seen it had it not been for trying to implement your suggestion of transfer.

Now I have the basic text (title and body text) going to an RTF file. My next attempt will be to incorporate the proper font and break the body text into two balanced columns, which was my original goal. After that the footer info, etc., should be simple.

RTF and its codes is a bit confusing, so I'm looking for a simplified spec.

Thanks for the help.

This topic is 6967 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.