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.

help nesting <xsl:for-each>

Featured Replies

  • Newbies

I suspect this is an easy solve

I am trying to nest a <xsl:for-each> loop within another <xsl:for-each> and getting a blank field in my resulting FMP table for one of them ( ie the Release ID ) within my example, the other 3 fields work ok. Could someone please look at the sample xml & xslt files and see if I can be pointed in the right direction ?

I am creating a FMP solution for a historical research project for work ( a musical history radio show ) and I am importing a huge xml file from the Discogs ( music collection ) website - they kindly provide a monthly dump of their xml data, and it must be said their xml / schema is a total mess. I am reorganising it into various related tables of my own ( thus coming up something slightly more usuable ).

The example xml is a heavily edited version of the original Discogs xml.

I will be relating a Releases table to a Tracklist table via a Release ID.

I have another xslt file ( not included ) which grabs other data shown the xml into a Releases table ( eg Release ID, Artist ID, Name, Label, Year, etc etc ) and that works a treat.

I am having trouble creating the Tracklist table ( ie no Release ID goes into that field via my shoddy xslt file )

I am sure I have confused you...but maybe not :)

 

testrelease6.xml

transform_releases_test6b.xslt

If I understand correctly what you're trying to do, you should replace the <RESULTSET> part of your stylesheet with:

<RESULTSET>
	<xsl:for-each select="releases/release/tracklist/track">
		<ROW>
			<COL><DATA><xsl:value-of select="../../@id"/></DATA></COL>
			<COL><DATA><xsl:value-of select="position"/></DATA></COL>
			<COL><DATA><xsl:value-of select="title"/></DATA></COL>
			<COL><DATA><xsl:value-of select="duration"/></DATA></COL>
		</ROW>
	</xsl:for-each>
</RESULTSET>

(The indentation is unessential, but it helps in understanding.)

This gets the value from the @id attribute of the grandparent node of the current node - that is the <release> of the current <track>. It is not necessary to use another <xsl:for-each> for this purpose.

 

CAVEAT: XSLT is very context-dependent; what works for "a heavily edited version of the original", may not work for the original.

  • Author
  • Newbies

Yes, thanks, works a treat - I knew about the parent / child concept but not the grandparents, but get it now.

I know what you mean about the XML I only edited it as an example to post here - the original that I downloaded from Discogs extracted to a monster 17gig xml, with everything thrown into the one xml, a big seething mass of data.

I am systematically going through all this and breaking it into smaller ( related ) tables and creating different xslt files to extract what I need for each table.

Thanks for helping me out !

 

 

 

 

 

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.