如何将具有重复字段的 XML 文件导入 FileMaker 数据库?

发布于 2024-08-01 15:07:36 字数 959 浏览 10 评论 0原文

我正在使用 FileMaker Pro 9,我想获取一个包含重复记录的数据库(例如,一个字段是“行”,最多可以有 9 个字符串),并将数据从 XML 文件导入到其中。

现在,使用以下 XML 文件,我只导入第一个条目(“房间”):

<?xml version="1.0" encoding="UTF-8"?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
    <ERRORCODE>0</ERRORCODE>
    <PRODUCT NAME="" VERSION="" BUILD=""/>
    <DATABASE NAME="New Invoice" RECORDS="1" DATEFORMAT="M/d/yyyy" TIMEFORMAT="" LAYOUT="hh/mm/a"/>
    <METADATA>
        <FIELD NAME="Description Index" TYPE="TEXT" EMPTYOK="NO" MAXREPEAT="9"/>
    </METADATA>
    <RESULTSET FOUND="1">
        <ROW RECORDID="" MODID="">
            <COL>
                <DATA>Room</DATA>
                <DATA>Equipment</DATA>
                <DATA>Labor</DATA>
            </COL>
         </ROW>
    </RESULTSET>
</FMPXMLRESULT>

如何导入其余条目(“设备”和“劳动力”)?

I'm using FileMaker Pro 9 and I want to take a database with repeating records (e.g. one field is "Lines" and it can have up to 9 strings) and import data into it from an XML file.

Right now, with the following XML file, I only get the first entry imported ("Room"):

<?xml version="1.0" encoding="UTF-8"?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
    <ERRORCODE>0</ERRORCODE>
    <PRODUCT NAME="" VERSION="" BUILD=""/>
    <DATABASE NAME="New Invoice" RECORDS="1" DATEFORMAT="M/d/yyyy" TIMEFORMAT="" LAYOUT="hh/mm/a"/>
    <METADATA>
        <FIELD NAME="Description Index" TYPE="TEXT" EMPTYOK="NO" MAXREPEAT="9"/>
    </METADATA>
    <RESULTSET FOUND="1">
        <ROW RECORDID="" MODID="">
            <COL>
                <DATA>Room</DATA>
                <DATA>Equipment</DATA>
                <DATA>Labor</DATA>
            </COL>
         </ROW>
    </RESULTSET>
</FMPXMLRESULT>

How can I get the rest of the entries ("Equipment" and "Labor") imported?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

少钕鈤記 2024-08-08 15:07:36

可以在 Filemaker 中导入和导出重复字段(数组),但不能从 XML 格式导入和导出。

我刚刚想通了。 只要使用合并 (.mer) 格式、逗号分隔值 (CSV) 或其他纯文本分隔格式,您就可以从 Filemaker 导出和导入重复字段。 否则,它只会为您提供该字段中的第一个重复项。 XML 不是一个选项。 对于本示例,我将使用 csv 文件。

首先,为了正确导入重复字段,您必须了解一些事情...

  1. 当 Filemaker 导出或导入重复字段数据时,它使用特殊的隐藏字符来分隔重复项目。 该字符是 ASCII-29,但您不能像输入其他字符一样直接输入该字符。 在 Mac 或 PC 上,该键是 ctr+](按住 control 和右方括号)。

  2. 这最好在可以显示不可见字符的文本编辑器中处理,例如 Coda 或 Text Wrangler。 在 Coda 中,我打开了“显示不可见字符”,因为除非您在打开该功能的文本编辑器中,否则您不会看到任何情况发生,因为它会在文本后面插入字符,并且重复之间没有任何空格项目。

  3. 在 CSV 中,字段包含在引号中并以逗号分隔。 记录由回车符(回车键或回车键)分隔。 字段标题用逗号分隔,但不包含在引号中。

以下是 CSV 格式的示例。 我将用括号中的数字 29 指定隐藏字符 ([29]):

盒子编号、内容

“1”,“苹果[29]橙子[29]香蕉”

"2","鳕鱼[29]金枪鱼[29]鲑鱼[29]鳟鱼"

“3”,“我的小马驹[29]希曼”

1 号盒子里有苹果、橙子和香蕉。

2 号盒子里有鳕鱼、金枪鱼、鲑鱼和鳟鱼。

盒子 3 里有《小马宝莉》和《希曼》。

现在你就得到了它。 Filemaker 将其识别为重复字段。 值得首先从 Filemaker 导出一些重复字段,然后从文本编辑器中查看文件(显示隐藏字符),以便直观地了解您将要完成的任务。

You can import and export repeating fields (arrays) in Filemaker, but not from an XML format.

I just figured it out. You can export and import repeating fields from Filemaker as long as you use their merge (.mer) format, or comma separated values (CSV), or another plain text delimited format. Otherwise, it will only give you the first of the repetitions in the field. XML isn't an option for this. For this example, I'll use a csv file.

First, in order to import repeating fields correctly, you have to understand a few things...

  1. When Filemaker exports or imports repeating field data, it uses a special hidden character to separate the repeating items. The character is ASCII-29, but you can't just type that in like you can other characters. On a Mac or PC, the key is ctr+] (hold down control and the right square bracket).

  2. This is best handled in a text editor that can show invisible characters, such as Coda or Text Wrangler. In Coda, I turned on "Show Invisible Characters" because unless you are in a text editor with that turned on, you won't see anything happen, as it inserts the character behind the text and there aren't any spaces between the repeating items.

  3. In a CSV, the fields are contained in quotes and separated by a comma. Records are separated by a carriage return (the enter or return key). Field headers are separated by a comma, but are not contained in quotes.

Here is an example in CSV format. I'll designate the hidden character with the number 29 in brackets ([29]):

Box Number,Contents

"1","apples[29]oranges[29]bananas"

"2","cod[29]tuna fish[29]salmon[29]trout"

"3","My Little Pony[29]He-Man"

Box 1 had apples, oranges and bananas.

Box 2 had cod, tuna fish, salmon and trout.

Box 3 had My Little Pony and He-Man.

And there you have it. Filemaker recognizes it as repeating fields. It would be worth exporting some repeating fields from Filemaker first and taking a look at the file from within a text editor (with hidden characters showing), just to get a visual of what you will be trying to accomplish.

浅暮の光 2024-08-08 15:07:36

你不能。 但您可以绕过它:

据我所知,FileMaker 似乎在内部使用 ASCII-29 字符来分割重复字段中的数据。 你有几个选择。

  1. 如果您可以解决编码问题,只需使用一个元素,然后将房间、设备和劳动力拆分为中间的 ASCII-29 字符。

  2. 添加您自己的分隔符并编写一个脚本/自定义函数来获取导入的数据并将其推送到所需的重复字段中。 (这个脚本看起来很恶心)

  3. 不要使用重复字段

就我个人而言,我尽可能远离重复字段。

如果可能的话,请为重复数据使用新的相关表。 如果您愿意,您可以使用门户或类似的方式来显示它,或者您甚至可以将其拉入主表中的计算字段(如果必须存在)。 像这样:

INVOICE
-------
ID
Invoice Date

LINES
-------
ID
fk_InvoiceID
Item

然后它们可以关联 INVOICE::ID --< LINES::fk_InvoiceID,您可以显示门户中的所有项目。

您还可以在“发票”表中拥有一个类似于以下内容的计算字段:

cLines = List(LINES::Item)

这将为您提供类似以下内容:

Room
Equipment
Labor

在该字段中。

You can't. But you can get around it:

As far as I can tell, FileMaker seems to use the ASCII-29 character internally to split the data that is in repeating fields. You have a couple of options.

  1. If you can work out the encoding issues, just have the one element and split Room, Equipment and Labor up with the ASCII-29 character in between.

  2. Add your own separator and write a script/custom function that takes the imported data and pushed it into the required repeated field. (this script will look icky)

  3. DON'T USE REPEATING FIELDS

Personally I stay as far away from Repeating Fields as possible.

If it is at all possible, use a new related table for the repeating data. You can use a portal or similar to display it if you so desire, or you can even pull it into a calculated field in the main table if it has to be there. Something like this:

INVOICE
-------
ID
Invoice Date

LINES
-------
ID
fk_InvoiceID
Item

They can then be related INVOICE::ID --< LINES::fk_InvoiceID and you can show all the items in a portal.

You can also have a calculated field that looks something like this in the Invoice table:

cLines = List(LINES::Item)

Which will give you something like:

Room
Equipment
Labor

In that one field.

反差帅 2024-08-08 15:07:36

前面的答案都是不正确的。 事实上,您可以将分隔值列表从 XML 文件导入到 FileMaker 表中。 然而,公平地说,FileMaker 本质上无法使用其本机 XML 导入来完成此操作。 为此,必须创建一个 XSL 转换文件,以便在导入时与 XML 文件结合使用。 在转换文件的数据标记内,使用结构来迭代并连接 XML 文件中的值。

The previous answers are incorrect. You can, in fact, import delimited value lists from XML files to FileMaker tables. However, in fairness, FileMaker cannot do it intrinsically using it's native XML Import. In order to do this one must create an XSL Transform file to be used in conjunction with the XML file when importing. Within the data tag in the Transform file use an structure to iterate through and concatenate the values in the XML file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文