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

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

Recommended Posts

Posted

Is there a way to import data from an XML file by using an XSLT sheet that is imbedded in the FileMaker solution?

The normal way to write such a script step is

-


  • (1) select an external XML file with the data;
    (2) select an external XSL file that tells FM how to interpret the XML file.

I would like to avoid using a text file separate from the solution, so that the whole solution, including the XSL, is in one file.

In the Script step "Import Records", under “Specify XML and XSL Options”, you may specify a Calculation instead of a file. I have tried to make this calculation

-


  • (1) a text field that contains the XSL text
    (2) a container field that contains the Style Sheet document.

Both methods return a runtime error. Has anyone been able to do this?

Posted

The only thing that comes close is to export the data to a local file, "say the FileMaker Pro folder" and then exports blank data to the same location at the end of the script. Allow user abort [off] is enabled of course.

Posted (edited)

In the Script step "Import Records", under “Specify XML and XSL Options”, you may specify a Calculation instead of a file

I don't see anything about a calculation in the Import XML dialog; there is only a choice of file path or http path; either of which could come from calculations; but that's very different from saying you could use a calculation of the xsl content itself.

As Stuart says, you can store the xsl stylesheet in a FileMaker text field, or better, a file in a container field,* then export it to a file at a known location, then use that path for the Import XML dialog.

A good example of this is the Process DDR file of Jonathan Starks.

http://www.jonathanstark.com/downloads.php

*You may have trouble on Windows, if you use the text-in-a-field method however, 'cause of the utf-16. I did anyway. FileMaker uses utf-16 for Export Field Contents of a text field. Easy to fix manually, by changing the encoding back to utf-8. Exporting a file would get around that problem

[His file uses AppleScript, just a little, so it's not made to work directly on Windows; but I wanted to see if it would; conclusion, yes, with the caveat above.]

Edited by Guest
Posted

Works like a charm.

Two important rules not explained in the manual:


  • (1) When you export the contents of a container field that contains a file, you must give the newly-created file the same name as the source file in the container field.
    (2) The file created by exporting the contents of a field replaces any existing file with the same name--unceremoniously, and without warning. Not behavior I would expect, but exactly what I need!

Thank you, gentlemen.

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