• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Let user decide which structured application to use for xml-file import

New Here ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

Hey guys,

I am fairly new to the FrameMaker-scripting-thing. I basically have a folder, full of .xml files that shall be opened with a structured application and then be saved as a .fm file. I can already do that but I have to manually tell FrameMaker which structured application to use (as in How do I load an XML file, and save it as an fm file). But I can't really say which one should be used. I'd rather have the user specify the application once for the first file (maybe even open the dialog that can be seen when manually opening a .xml-file) and use it for the rest of the files as well.

Pseudo-Code:

var structApp = ChooseStructApp();

openXmlFile(filePath, structApp);

Does anyone know how to do anything like that?

Kind regards,

Tom

TOPICS
Scripting

Views

324

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

Hi Tom,

Before we get into the scripting part. Why do you need to manually tell FrameMaker which XML app to use? Is it because they all use the same Doctype, but use different schemas or DTDs?

This is the problem we get with S1000D for example. in that case it is indeed necessary to query the XML before it is opened by the relevant FrameMaker XML application.

The way I have dome that is to open the file first with ExtendScript, check the value of the xsi:noNamespaceSchemaLocation attribute, or perhaps some element in the structure that is unique to the DTD.

Ian

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

Hi Ian,

first of all: thanks for your quick reply!

Yes, they use the same Doctype but different DTDs. Okay, so your solution seems to be halfway automated (by guessing based on one value which DTD to use, instead of asking the user). That of course would be very nice as well. I'll try to see, if I can actually do that.

Thanks so much!

Tom

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

LATEST

Hi Tom,

What I would do here is create a custom open function with the following features:

  1. A dedicated open command on the File Menu. Calls a function openXmlFile().
  2. The function openXmlFile() uses the ExtendScript file handling features to present a file browser.
  3. The user selects the file.
  4. A small function opens the file for reading and checks for some unique content or DTD name. Closes the file and Returns a value based on what is found.
  5. A switch statement allows all cases to be evaluated and returns an XML application name based on the return value from the previous step.
  6. Use FrameMaker's Open() function to open the XML file using the application name passed in the previous step.

That's what how it works in FrameMaker's S1000D > Open S1000D command. So everything is automated - yes it's very annoying when you use the wrong XML app to open a file!

Let me know if you need any help with any of that.

Regards

Ian

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines