Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

XML Import to Filemaker

Featured Replies

  • Newbies

Hi!

I try to import xml data into a FM database (laboratory analyses into medical records). As you might imagine, I have several problems... confused.gif I learned that I have to use a XSL stylesheet to translate XML to filemaker FMPXMLRESULT grammar. I have found some examples for doing so. So far, so good...

However, I was unable to find out how to import XML data that uses attributes instead of simple fields, e.g. the following nested (and nasty... blush.gif) example:

 (Test Id="PROBNP" Text="NT-Pro BNP" Unit="ng/l" High="84" Ref="bis 84")

    (Value Ind="1")1234(/Value)

(/Test)

I have attached an example file with a complete analysis report.

So, my specific problems are:

1) how can I import such fields with attributes like "Id", "Text" and so on?

2) how can I "flatten" the structure of the nested data to import it into 1 table?

Thanks in advance for your help!

Luke

KBef_140001_02.txt

Short answers (I'm a little burned, time for more coffee ???-) I may be able to do some more later. It's not real complex.

1. Attributes are accessed with the @ character. Otherwise they're much like any other element. Ex.

<xsl:value-of select="/KumBef/Results/Group/Test/@Id"/>

In your real xsl you would have a template to match the root, which could be simply "/", then you'd have either more templates to match parts below, or you'd use <xsl:for-each select=""> to match parts; or a mixture of the two methods. In either case the long node reference above would be much shorter.

Obviously you've got several groups. So, for example, a subset of the data (without the FileMaker stuff, nor the patient) could be something like:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes" />

<xsl:template match="/KumBef">

<xsl:for-each select="Results/Group">

<xsl:value-of select="@Id"/>

<xsl:value-of select="@Text"/>

<xsl:for-each select="Test">

<xsl:value-of select="@Id"/>

<xsl:value-of select="@Text"/>

<xsl:value-of select="@Unit"/>

</xsl:for-each>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

2. "Flattening" data is a bad idea. XML is designed to hold relational data. It's much like having 2 FileMaker files with tables. Would you expect to import multiple tables into one table? No. You'd just import each into its corresponding table, making sure to bring along an ID to tie them together.

You would do almost the same thing with xml. You can do separate imports, but of the same xml document. Each time you would use a different xsl stylesheet, which would only match the fields for that table; also including something you can use as relational key. If there is nothing you can use as a key, then you can create one as you go. But hopefully there is.

  • Author
  • Newbies

Thank you very much indeed! Luke

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.