Save a Copy as XML

Saves a copy of an open file as an XML representation of the schema, layouts, and scripts.

Options 

  • Window name specifies the window name of an open file. If not specified, the current window is used.

  • Destination file is the path of the XML file to create. See Creating file paths.

  • Include details for analysis tools adds more information in the XML file.

    This option adds the DDR_INFO element, which provides additional information that's useful to third-party tools you can use to analyze your custom app. Depending on your app, this option can produce a significantly larger XML file.

  • Save each layout object's binary data under its node stores every layout object's binary data (for example, an image) under the layout object's node in the XML file. This can make the XML easier for some tools to use but can increase the XML file size.

    When this option is deselected, only a reference is stored under each layout object's node, which points to the library data catalog where the binary data is stored. This can help reduce file size when the same binary data is used for many layout objects.

  • Specify options as JSON is a text expression for a JSON object that lets you specify the following options for this script step:

    • catalogs_included (JSON array): An array of catalog name strings specifying which catalogs to include in the XML file. If omitted, all catalogs are included by default.

    • include_details (Boolean): This option has the same purpose as Include details for analysis tools and overrides its value, if specified.

    • split_catalogs (Boolean): When true, creates a separate XML file for each catalog specified in the catalogs_included key. When false or omitted, creates a single XML file. See Notes for details on split catalog behavior.

    • standalone_binarydata (Boolean): This option has the same purpose as Save each layout object's binary data under its node and overrides its value, if specified.

    When you first select this option, FileMaker Pro automatically generates a template calculation that returns all the above keys with default values, including all supported catalog names for catalogs_included, which you can then customize.

Compatibility 

Product Supported
FileMaker Pro Yes
FileMaker Go No
FileMaker WebDirect No
FileMaker Server Yes
FileMaker Cloud Yes
FileMaker Data API No
Custom Web Publishing No

Originated in version 

18.0

Description 

This script step is similar to choosing Tools > Save a Copy as XML. See Documenting database schemas.

You can use Specify options as JSON to automate complex scenarios where you need to dynamically specify which catalogs to include or whether to split the output into multiple files.

Notes 

  • To perform this script step, the user or the script must have full access privileges. See Creating and editing scripts.

  • This XML format may change from one version of FileMaker Pro to the next. When you use the XML to compare two versions of a FileMaker Pro file, be sure that the same version of FileMaker Pro is used to save a copy of each file as XML. If you use the XML with other tools, be sure those tools are designed to use the XML saved by your version of FileMaker Pro.

  • For Specify options as JSON, when split_catalogs is true:

    • The Destination file option is treated as a folder name, and separate XML files are created for each catalog specified in catalogs_included. If the folder doesn't exist, this script step creates it.

    • The standalone_binarydata key is automatically set to true when splitting catalogs.

    • The value LibraryCatalog is ignored even if specified in catalogs_included.

  • If Specify options as JSON contains a formatting error, the script step returns error code 878 ("JSON data for Options contains a formatting error and couldn't be parsed").

Example 1 

Saves a copy of the open file whose window name is Inventory to an XML file.

Copy
Save a Copy as XML [ Window name: "Inventory" ; Destination file: "Inventory.xml" ]

Example 2 

Saves only scripts, layouts, and custom functions from the file specified by the current window to an XML file using Specify options as JSON.

Copy
Set Variable [ $jsonOptions ; Value:
  JSONSetElement ( "{}" ;
    [ "catalogs_included" ; JSONMakeArray (
      "ScriptCatalog LayoutCatalog CustomFunctionsCatalog" ;
      " " ; JSONString ) ; JSONArray ] ;
    [ "include_details" ; False ; JSONBoolean ] ;
    [ "split_catalogs" ; False ; JSONBoolean ] ;
    [ "standalone_binarydata" ; False ; JSONBoolean ]
  )
]

Save a Copy as XML [ Window name: ; Destination file: "MyApp_Schema.xml" ; Include details for analysis tools ; Specify options as JSON: $jsonOptions ]

Notice that even though Include details for analysis tools is selected in the script step, it is overridden by the include_details key in Specify options as JSON being set to False.

Example 3 

Saves scripts, layouts, and fields into separate XML files within a folder named "MyApp_SaveAsXML".

Copy
Set Variable [ $jsonOptions ; Value:
  JSONSetElement ( "{}" ;
    [ "catalogs_included" ; JSONMakeArray (
      "ScriptCatalog LayoutCatalog FieldCatalog" ;
      " " ; JSONString ) ; JSONArray ] ;
    [ "include_details" ; True ; JSONBoolean ] ;
    [ "split_catalogs" ; True ; JSONBoolean ]
  )
]

Save a Copy as XML [ Window name: ; Destination file: "MyApp_SaveAsXML" ; Specify options as JSON: $jsonOptions ]

This creates a folder named "MyApp_SaveAsXML" containing three files:

  • MyApp_SaveAsXML_ScriptCatalog.xml
  • MyApp_SaveAsXML_LayoutCatalog.xml
  • MyApp_SaveAsXML_FieldCatalog.xml