February 23, 201114 yr 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
February 23, 201114 yr Why don't you attach your raw XML output, to make it easier for us? Also explain what exactly "doesn't work"?
February 23, 201114 yr 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>
February 23, 201114 yr 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
February 23, 201114 yr 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
February 23, 201114 yr 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