NYC Newbie Posted June 12, 2011 Posted June 12, 2011 I have an xml response that I'd like to filter thru an XSL and import into filemaker. It contains the info for a standard order - buyer contact and several items ordered. Here is a sample response file - <?xml version="1.0" encoding="ISO-8859-1"?> <orderUpdateResponse version="1.0"> <purchaseOrder id="87047440DONOTIMPORT"> <buyer id="3392278"> <email>[email protected]</email> <mailingAddress> <city>Manassas</city> <code>22204</code> <country>USA</country> <name>Some Dude</name> <phone>703444 5555</phone> <street>666 Old Dominion Way</street> </mailingAddress> </buyer> <buyerPurchaseOrder id="DONOTIMPORT" /> <orderTotals> <gst currency="USD">0.0</gst> <handling currency="USD">0.0</handling> <shipping currency="USD">30.0</shipping> <subtotal currency="USD">95.0</subtotal> <tax currency="USD">0.0</tax> <total currency="USD">125.0</total> </orderTotals> <purchaseOrderItemList> <purchaseOrderItem id="89776655DONOTIMPORT"> <book id="34565478754DONOTIMPORT> <vendorKey>identificationinfo1</vendorKey> </book> <purchaseOrder id="87047440DONOTIMPORT" /> </purchaseOrderItem> <purchaseOrderItem id="89337622DONOTIMPORT"> <book id="3255656543DONOTIMPORT"> <vendorKey>identificationinfo2</vendorKey> </book> <purchaseOrder id="87047440DONOTIMPORT" /> </purchaseOrderItem> <purchaseOrderItem id="89337623DONOTIMPORT"> <book id="3797027063DONOTIMPORT"> <vendorKey>identificationinfo3</vendorKey> </book> <purchaseOrder id="87047440DONOTIMPORT" /> </purchaseOrderItem> </purchaseOrderItemList> </purchaseOrder> </orderUpdateResponse> In filemaker I have an order layout with a portal of the items ordered. Below is my XSLT style sheet so far, I'm lost, especially on how to import the multiple items of an order - I would be grateful for any corrections and help. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/> <xsl:template match="/"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <ERRORCODE>0</ERRORCODE> <PRODUCT BUILD="" NAME="" VERSION=""/> <DATABASE DATEFORMAT="" LAYOUT="" NAME="" RECORDS="" TIMEFORMAT=""/> <METADATA> <FIELD NAME="email" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="shipCity" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="shipPostalCode" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="shipCountry" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="shipName" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="shipPhone" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="shipAddress1" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="handling_cart" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="orderSubtotal" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="SalesTax" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> <FIELD NAME="orderTotal" TYPE="TEXT" EMPTYOK="YES" MAXREPEAT=""/> </METADATA> <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW"> <vendorBookID><xsl:value-of select="fmp:COL[1]/fmp:DATA" /></vendorBookID> </xsl:for-each> </xsl:template> </xsl:stylesheet>
comment Posted June 12, 2011 Posted June 12, 2011 how to import the multiple items of an order You should import the items into a OrderItems table. And the buyer info into a Buyers table. So that's three separate imports, each with its own stylesheet. Or you could import everything into a flat table (where each record is an order item and the other data is duplicated). Then you can do the other imports from there (or leave it as is - it really depends on what you intend to do with this). <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW"> <vendorBookID><xsl:value-of select="fmp:COL[1]/fmp:DATA" /></vendorBookID> </xsl:for-each> This makes no sense: you are importing, not exporting. There is no FMPXMLRESULT to select from.
NYC Newbie Posted June 12, 2011 Author Posted June 12, 2011 consultant, thanks for the quick response. hadn't thought about splitting up the imports, good idea. but here's the issue, i get many responses some with just one order item, some with twenty. there is no fixed amount. what is the code language to loop the multiple items? this is what i'm scratching at. thanks.
comment Posted June 12, 2011 Posted June 12, 2011 i get many responses some with just one order item, some with twenty. there is no fixed amount. what is the code language to loop the multiple items? Create a new record (i.e. a Filemaker ROW) for each purchaseOrderItem.
Recommended Posts
This topic is 4982 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