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.

Exporting Portal records in XML

Featured Replies

Hi

I trying to export a record in XML that also contains a portal with multiple records.

When I view the exported XML file the main record is complete but only the first entry in the portal is exported.

My question is it possible to achieve this in Filemaker and if so what do I need to change on my XSL file. The portal fields are:

    <FruitSpecs>
         <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
               <Fruit>
               <Name><xsl:value-of select="fmp:COL[3]/fmp:DATA"/></Name>
               <Qty><xsl:value-of select="fmp:COL[4]/fmp:DATA"/></Qty>
               </Fruit>
          </xsl:for-each>
        </FruitSpecs>

trial.xsl

It is difficult to advise without seeing your file (or at least the raw XML file as exported without an XSLT stylesheet) and the expected result. 

In general, when you export from a parent table and also include fields from a child table in the field export order, there will be a separate DATA element for each child record in each COL element corresponding to a field from the child table. Your stylesheet needs to iterate over those DATA elements. Here is a generic example handling an export of 2 fields from the parent table and 3 fields from the child table:

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fmp="http://www.filemaker.com/fmpxmlresult" 
exclude-result-prefixes="fmp">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/fmp:FMPXMLRESULT">
	<root>
		<xsl:for-each select="fmp:RESULTSET/fmp:ROW">
			<parent>
				<!-- parent fields -->
				<parent-field-A>
					<xsl:value-of select="fmp:COL[1]/fmp:DATA"/>
				</parent-field-A>
				<parent-field-B>
					<xsl:value-of select="fmp:COL[2]/fmp:DATA"/>
				</parent-field-B>
				<!-- child fields -->
				<xsl:for-each select="fmp:COL[3]/fmp:DATA">
					<xsl:variable name="i" select="position()"/>
					<child>
						<child-field-A>
							<xsl:value-of select="."/>
						</child-field-A>
						<child-field-B>
							<xsl:value-of select="../../fmp:COL[4]/fmp:DATA[$i]"/>
						</child-field-B>
						<child-field-C>
							<xsl:value-of select="../../fmp:COL[5]/fmp:DATA[$i]"/>
						</child-field-C>
					</child>
				</xsl:for-each>
			</parent>
		</xsl:for-each>
	</root>
</xsl:template>

</xsl:stylesheet>		

--
P.S. Portals have nothing to do with this. A portal is a layout object; export operates at the data level and does not depend on the existence of a portal on the layout.

 

  • Author

Hi

Ive tried it but the result comes out blank.

Archive.zip

Your stylesheet is not a well-formed XML document.  It has a </xsl:for-each>  end-tag with no corresponding start-tag.

image.png.23e4c7fdd4e745912b8643986a056107.png

But of course you cannot see this if you set error capture to On, but do not check for errors.

  • Author

Now it seems to be adding everything on one element. 

 

Archive.zip

Sorry, I do not intend to provide a debugging service here (or anywhere else, for that matter).

Here's a working demo, make your own adjustments.

demo.zip

 

BTW, if I read your script correctly, you only want to export data pertaining to the current parent record. If so, you might find it more convenient to export from the child table (after doing Go to Related Record), instead of isolating the current parent record. 

Edited by comment

  • Author

Hi

I have it working now using your demo. Thanks for sorting this for me.

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.