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.

Simple XML Export but to include repetitions

Featured Replies

Hi

Im after a bit of help please

I have a small test database that I'm trying to figure out if its at all possible to export a single xml file to give me a result like this:

<?xml version="1.0" encoding="UTF-8"?>
<JOB>
<PrimaryKey>88B2BDCE-A0B2-41EB-B190-0480DF3AD6A9</PrimaryKey>
<WTN>3453</WTN>
<Customer>Bosch</Customer>
<Colours1>Red</Colours1>
<Colours2>Blue</Colours2>
<Colours3>Yellow</Colours3>
<Colours4>Green</Colours4>
<Colours5>Pink</Colours5>
</JOB>
 

everything is working correctly apart from the Colours field that contains 5 repetitions. my test.xsl just gives me this result:

<?xml version="1.0" encoding="UTF-8"?>
<JOB>
<PrimaryKey>88B2BDCE-A0B2-41EB-B190-0480DF3AD6A9</PrimaryKey>
<WTN>3453</WTN>
<Customer>Bosch</Customer>
<Colours>Red</Colours>
</JOB>
 

<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="/">
    <JOB>
        <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
            <PrimaryKey><xsl:value-of select="fmp:COL[1]/fmp:DATA"/></PrimaryKey>
            <WTN><xsl:value-of select="fmp:COL[2]/fmp:DATA"/></WTN>
            <Customer><xsl:value-of select="fmp:COL[3]/fmp:DATA"/></Customer>
            <Colours><xsl:value-of select="fmp:COL[4]/fmp:DATA"/></Colours>
            </xsl:for-each>
        </JOB>
    </xsl:template>
</xsl:stylesheet>        
 

I know I can just create 5 separate colour fields and export them individually but this is just a test database for a much bigger database that contains multiple fields with repetitions.

any help will be much appreciated.

 

 

test.fmp12

test.xml

test.xsl

Try it this way:

<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="/">
  <JOB>
    <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
      <PrimaryKey><xsl:value-of select="fmp:COL[1]/fmp:DATA"/></PrimaryKey>
      <WTN><xsl:value-of select="fmp:COL[2]/fmp:DATA"/></WTN>
      <Customer><xsl:value-of select="fmp:COL[3]/fmp:DATA"/></Customer>
      <xsl:for-each select="fmp:COL[4]/fmp:DATA">
        <xsl:element name="Colours{position()}">
          <xsl:value-of select="."/>
        </xsl:element>
      </xsl:for-each>
    </xsl:for-each>
  </JOB>
</xsl:template>

</xsl:stylesheet>

 

Note:
Numbered elements are considered bad XML practice (just think how difficult it would be to process each color in a subsequent transformation).

  • Author

Thats perfect..

Thanks for your help.

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.