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.

XSL for a XML export of related fields

Featured Replies

  • Newbies

I hope someone can help me. I've spent about 12 hours trying to figure this out and I'd pull out my hair if I had any.

I have two tables (Category) and (Images) (*See picture of tables.) and my XML output should look like this....

<root>

<category id="1" title="toys" name="toys" parent_id="-1">

_____<images>

__________<image id="1" title="ball" colorize="true" imageUrl="domain/ball.jpg" category_id="1" description="ball, toy" />

__________<image id="2" title="car" colorize="true" imageUrl="domain/car.jpg" category_id="1" description="car, toy" />

_____</images>

</category>

<category id="2" title="clothes" name="clothes" parent_id="-1">

_____<images>

__________<image id="3" title="shirt" colorize="true" imageUrl="domain/shirt.jpg" category_id="2" description="red, shirt" />

__________<image id="4" title="pants" colorize="true" imageUrl="domain/pants.jpg" category_id="2" description="pants, blue" />

_____</images>

</category>

</root>

This is my XSL (that doesn't work)....

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

<xsl:stylesheet version='1.0'

xmlns:xsl='http://www.w3.org/1999/XSL/Transform'

xmlns:fm="http://www.filemaker.com/fmpdsoresult"

exclude-result-prefixes="fm">

<xsl:output version='1.0' encoding='UTF-8' indent='yes' method='xml' />

<xsl:template match="/">

<xsl:for-each select="fm:FMPDSORESULT/fm:ROW">

<category>

<xsl:attribute name="ID"><xsl:value-of select="fm:ID"/></xsl:attribute>

<xsl:attribute name="title"><xsl:value-of select="fm:title"/></xsl:attribute>

<xsl:attribute name="name"><xsl:value-of select="fm:name"/></xsl:attribute>

<xsl:attribute name="parent_id"><xsl:value-of select="fm:parent_id"/></xsl:attribute>

<images>

<xsl:for-each select="fm:ID/fm:DATA">

<xsl:variable name="pos" select="position()"/>

<image>

<xsl:attribute name="ID"><xsl:value-of select="."/></xsl:attribute>

<xsl:attribute name="imageTITLE"><xsl:value-of select="../../fm:imageTITLE/fm:DATA[$pos]"/></xsl:attribute>

</image>

</xsl:for-each>

</images>

</category>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

--------------------------------------------------------

ANY IDEAS? Any help will be much appreciated!!

-TOM

xsl.png

Why don't you attach your raw XML output, to make it easier for us? Also explain what exactly "doesn't work"?

  • Author
  • Newbies

Why don't you attach your raw XML output, to make it easier for us? Also explain what exactly "doesn't work"?

It works for the categories, but it is missing each category's related images. The output I'm currently getting would look like this...

<root>

<category id="1" title="toys" name="toys" parent_id="-1">

<images>

</images>

</category>

<category id="2" title="clothes" name="clothes" parent_id="-1">

<images>

</images>

</category>

</root>

By "raw XML" I meant your output when you export without a stylesheet.

  • Author
  • Newbies

I've attached a zipped folder with the filemaker database and the XML output and the XSL stylesheet.

Thanks for any input!

image-categories.zip

The first problem is that you are not exporting any child (image) fields.

The other issue is that XML is case-sensitive: "imageTITLE" is not the same as "ImageTITLE".

I also see a lot of unprintable characters in your stylesheet - this was throwing errors in my test application.

Finally, you have a field named ID in both tables - so it would be better to refer to the "other" ID for the loop (not critical, though).

image-categories.zip

  • Author
  • Newbies

You have made my day! or week. THANK YOU.

I'm obviously a hack and this was also the first time I was ever exposed to XSL and even my XML knowledge is scant. I found very little detailed information specifically about XSL as it pertains to FileMaker exports ...until I found this forum.

If I need to hire a qualified consultant ...I know where to look.

Thanks Again,

Tom

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.