Newbies bdale65 Posted April 20, 2015 Newbies Posted April 20, 2015 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
comment Posted April 20, 2015 Posted April 20, 2015 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.
Newbies bdale65 Posted April 20, 2015 Author Newbies Posted April 20, 2015 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 !
Recommended Posts
This topic is 3580 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 accountSign in
Already have an account? Sign in here.
Sign In Now