Jump to content

XML Import to Filemaker


Luke44

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

Recommended Posts

  • 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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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