October 10, 201114 yr LS, I am trying to build a xml-file based on an xml-result export. I want it to look like : <data> <record> <ID>1</ID> <name_last>Miltenburg</name_last> <name_first>Joost</name_first> ... </record> </data> I have the xml-result : (part) <METADATA> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="id" TYPE="TEXT"/> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="name_last" TYPE="TEXT"/> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="name_first" TYPE="TEXT"/> ... </METADATA> What I want is to dynamically get all the different values of the NAME-attributes of the field elements. How do I do that ? That way I'd only have to write one xsl for all my exports. So it would be a loop within the looping of the records. Any help would be appreciated...
October 10, 201114 yr Try doing this for each fmp:COL: <xsl:variable name="pos" select="position()"/> <xsl:element name="{../../../fmp:METADATA/fmp:FIELD[$pos]/@NAME}"> <xsl:value-of select="fmp:DATA"/> </xsl:element> Note that this will fail if your field names are not valid element names (e.g. they contain spaces). Exporting as FPMDSORESULT would probably be even simpler.
May 21, 201213 yr Author Thnx ! I should have figured this out myself... You are right about the FPMDSORESULT remark. However, this has been deprecated for quite a while now. This gives me some future proofing, for my xml exports. Thnx again... :laugh:
Create an account or sign in to comment