Newbies tom_ray Posted February 23, 2011 Newbies Posted February 23, 2011 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
comment Posted February 23, 2011 Posted February 23, 2011 Why don't you attach your raw XML output, to make it easier for us? Also explain what exactly "doesn't work"?
Newbies tom_ray Posted February 23, 2011 Author Newbies Posted February 23, 2011 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>
comment Posted February 23, 2011 Posted February 23, 2011 By "raw XML" I meant your output when you export without a stylesheet.
Newbies tom_ray Posted February 23, 2011 Author Newbies Posted February 23, 2011 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
comment Posted February 23, 2011 Posted February 23, 2011 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
Newbies tom_ray Posted February 23, 2011 Author Newbies Posted February 23, 2011 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
Recommended Posts
This topic is 5386 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