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

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

Recommended Posts

  • Newbies
Posted

Is it possible to have the user be prompted to choose a text file, and then have FM read it?  There's a certain type of XML file that users will need to import more than once. I need a script to process the XML and add records.  I have no problem parsing the XML file in script but I can't figure out a way to read a text file.  Is there a script command that can prompt for a text/xml file?  Or is there some file chooser UI field type?

 

I tried using 'Open File' without specifying the location.  That defaults to only select FM file types.  If you change the dialog to show all file types, and then select a text file, it complains that FM didn't create the file (which it actually did but this clearly is expecting only an FM db).

 

Am I supposed to do something with container fields?  I tried adding one and having the user drag and drop a text file into it but I don't see how to read the actual data from the file.  I can only see the name.  Anyone have any ideas or workarounds?  Thanks.

Posted

Use the calculation in the article to put the path into a variable, e.g., $importfile. Then specify $importfile as the file in the Import Records script step.

Posted (edited)

Another option is to use a plugin, such as the (free) BaseElements.

 

However, you shouldn't be having this problem at all, since Filemaker can import XML files directly, given a suitable XSLT stylesheet. Parsing XML within Filemaker is a lot of unnecessary and error-prone work.

 

 

---

P.S.

Please update your profile to reflect your version and OS.

Edited by comment
Posted

Hi Breton, and welcome to the Forums,

 

Is it possible...

 

 

As comment replied, please update your profile to reflect your current OS, Platform and FileMaker version. Here is a quick link to MY PROFILE. This information helps us address our reply to fit your situation.

 

Lee

  • Newbies
Posted

Thanks I think I finally got this working.

 

Yea I'm familiar XSLT but the export XML creation was so simple I ended up not needing it for that.  It may be possible to use FM's import functionality for this XML but I'm guessing with complex table relationships I'm working with and all the dynamic field name creation I'm going to need, I'd be better off just parsing it myself.  That and I'm also a big fan of functional programming.  I've been looking forward to the XML parsing part.  I'll do it all with elegant custom functions.

Posted

[shrug] Not to belittle your abilities, but Filemaker's text functions are no match for what can be achieved with a dedicated XML parser and XSLT processor - both of which are included in the application.

 

 

I'm guessing with complex table relationships I'm working with and all the dynamic field name creation I'm going to need,

 

"dynamic field name creation"? I don't think that's possible using any method  (except by importing into a new table, if that counts).

Posted

Is it possible with an SQL plugin?

Posted

Is it possible with an SQL plugin?

 

That's a good point - I believe it is. However, given that:

 

There's a certain type of XML file that users will need to import more than once.

 

I doubt it's something you'd want to do. But maybe it's just me...

  • Newbies
Posted

[shrug] Not to belittle your abilities, but Filemaker's text functions are no match for what can be achieved with a dedicated XML parser and XSLT processor - both of which are included in the application.

 

 

 

"dynamic field name creation"? I don't think that's possible using any method  (except by importing into a new table, if that counts).

 

I've amassed a pretty robust set of custom functions for string manipulation.  Using those I've also created a lot of custom functions that control string based data structures.  These made this task much simpler than one would expect.  My regular job is a Java developer so I'm used to having tools like this.

 

"Dynamic field name creation" was a bad choice of words.  I meant that I'll only know which fields I need to import at run-time.  It don't think using FM's automated xml import can allow me to conditionally include/exclude certain fields.  This probably sounds weird, but I didn't design the database I'm working with and it does some things in weird ways.

Posted (edited)
It don't think using FM's automated xml import can allow me to conditionally include/exclude certain fields.

 

I am not convinced that is so. Filemaker could have certainly made it easier by allowing a parameter to be passed to the stylesheet at runtime. Still, you can start the process by exporting a file to a known location and have the stylesheet pick the settings from there.

 

 

EDIT:

Filemaker scripted import - no matter from what type of file - does NOT allow you to "conditionally include/exclude certain fields". The best you can do is prepare several "presets" (each in the form of a stored Import Records script step) and choose one at runtime.

 

Alternatively, you could import all fields into a temp table and take it from there. IMHO, that's still a lot of less work than parsing the entire source file into records AND fields, and only then getting to this exact same point.

Edited by comment

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