Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7121 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

This one is driving me batty. I'm trying to transform Amazon's AWS XML into FileMaker's FMPXMLRESULT. The transformation is happening successfully -- everything looks perfect in Oxygen -- but FileMaker seems to be pulling Amazon's root xmlns into its node, thus throwing a validation error when trying to import (see picture here: Import Error).

Here's an example of the XML:


<?xml version="1.0" encoding="UTF-8"?>

<ListLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2005-03-23">

<OperationRequest>

<HTTPHeaders>

<Header Name="UserAgent" Value="Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)

AppleWebKit/412 (KHTML, like Gecko) Safari/412"/>

</HTTPHeaders>

<RequestId>1WMW28R1SWHGBZACCN7T</RequestId>

<Arguments>

<Argument Name="Service" Value="AWSECommerceService"/>

<Argument Name="ListId" Value=""/>

<Argument Name="SubscriptionId" Value=""/>

<Argument Name="ProductPage" Value="2"/>

<Argument Name="ResponseGroup" Value="Small"/>

<Argument Name="ListType" Value=""/>

<Argument Name="Operation" Value="ListLookup"/>

</Arguments>

<RequestProcessingTime>0.971019983291626</RequestProcessingTime>

</OperationRequest>

<Lists>

<Request>

<IsValid>True</IsValid>

<ListLookupRequest>

<ListId>O0A8K3T09FFP</ListId>

<ListType>WishList</ListType>

<ProductPage>2</ProductPage>

<ResponseGroup>Small</ResponseGroup>

</ListLookupRequest>

</Request>

<List>

<ListItem>

<Item>

<ASIN>0972323457</ASIN>

<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=ws%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0972323457%2526location=/o/ASIN/0972323457%25253FSubscriptionId=1KBGRFM607FQ2HNV7S02%252526coliid=IQZHG6LWZ93UB%252526colid=O0A8K3T09FFP</DetailPageURL>

<ItemAttributes>

<Author>Charles D'Ambrosio</Author>

<ProductGroup>Book</ProductGroup>

<Title>Orphans</Title>

</ItemAttributes>

</Item>

</ListItem>

<ListItem>

<Item>

<ASIN>0679642749</ASIN>

<DetailPageURL>http://www.amazon.com/exec/obidos/redirect?tag=ws%26link_code=xm2%26camp=2025%26creative=165953%26path=http://www.amazon.com/gp/redirect.html%253fASIN=0679642749%2526location=/o/ASIN/0679642749%25253FSubscriptionId=1KBGRFM607FQ2HNV7S02%252526coliid=I10KO6H1MOM4X3%252526colid=O0A8K3T09FFP</DetailPageURL>

<ItemAttributes>

<Author>EMILE ZOLA</Author>

<Creator Role="Introduction">ARTHUR GOLDHAMMER</Creator>

<ProductGroup>Book</ProductGroup>

<Title>The Kill (Modern Library)</Title>

</ItemAttributes>

</Item>

</ListItem>

</List>

</Lists>

</ListLookupResponse>

Here's my stylesheet:


<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aws="http://webservices.amazon.com/AWSECommerceService/2005-03-23" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="xsi">

<xsl:template match="/">

<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">

<ERRORCODE>0</ERRORCODE>

<PRODUCT BUILD="" NAME="" VERSION=""/>

<DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="" RECORDS="{count(/*/*/*/*)}" TIMEFORMAT="h:mm:ss a"/>

<METADATA>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="ASIN" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="DetailPageURL" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Author" TYPE="TEXT"/>

<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Title" TYPE="TEXT"/>

</METADATA>

<RESULTSET FOUND="">

<xsl:for-each select="/aws:ListLookupResponse/aws:Lists/aws:List/aws:ListItem">

<ROW>

<xsl:attribute name="MODID">0</xsl:attribute>

<xsl:attribute name="RECORDID"><xsl:value-of select="position()"/></xsl:attribute>

<COL><DATA><xsl:value-of select="aws:Item/aws:ASIN" /></DATA></COL>

<COL><DATA><xsl:value-of select="aws:Item/aws:DetailPageURL" /></DATA></COL>

<COL><DATA><xsl:value-of select="aws:Item/aws:ItemAttributes/aws:Author" /></DATA></COL>

<COL><DATA><xsl:value-of select="aws:Item/aws:ItemAttributes/aws:Title" /></DATA></COL>

</ROW>

</xsl:for-each>

</RESULTSET>

</FMPXMLRESULT>

</xsl:template>

</xsl:stylesheet>

Anyone have thoughts about this? Do I need to slice out the AWS namespace declaration somehow before passing it off to FMP? Any help is much appreciated!

Jed

Posted

Yes, apparently you do need to slice it out. If you just add it to your exclude-result prefixes it works.

exclude-result-prefixes="xsi aws"

Why exactly, and what it all means will require Martin or Beverly :-)

I don't think you particularly need the xsi declaration or namespace, as you aren't validating against a schema. But perhaps it is more politically correct :-]

Also, if you're going to count (which you don't have to; obviously FileMaker doesn't care much), then it's:

{count(/*/*)}

Posted

I just wanted to add that NAMESPACES are your friend! Use them correctly, use the wisely, just use them!! smile.gif

You can use your own namespace! For example, many of us use "fm:" or "fmp:" or "fmd:" to signify the FMPXMLRESULT or FMPDSORESULT. But if I wanted to declare the namespace as "bev:" I could. I just have to use it correctly:

... xmlns:bev="http://www.filemaker.com/fmpxmlresult" exclude-result-prefixes="bev" ...

... xsl:value-of select="./bev:ROW[3]/bev:COL[5]/bev:DATA" /...

The namespace is a way to let the stylesheet and processors have a 'short-cut' to the full path (and definition) of the element. Otherwise (exaggerated), you might have to do this:

... xsl:value-of select="./http://www.filemaker.com/fmpxmlresult/ROW[3]/http://www.filemaker.com/fmpxmlresult/COL[5]/http://www.filemaker.com/DATA" /...

This topic is 7121 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.