Jump to content
Server Maintenance This Week. ×

Exporting Portal records in XML


Plucky

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

Recommended Posts

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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