Jump to content

Using XSL style sheet to filter records to import


Cabinetman
 Share

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

Recommended Posts

:bang: Once again after hours of playing and trying to learn I just can't seem to get it! I know it's not that hard so if someone will point me in the right direction I'd appreciate it.

The attached is a basic XSL style sheet and example from which I can apply my new found knowledge (I hope) to my others.

I only want to import from the xml response certain records into my database and ignore the rest. So basically I only want to import those matching certain predefined criteria

Examples:

PublicationDate=Jan 2011

or

ProductGroup=Books

or

Format=DVD

I believe it will involve the 'for-each' but I'm not sure where. ??

and does it involve the template match also?

Help?

amazon_info_search_filtering_zipped.zip

Link to comment
Share on other sites

It would be easier if we had an example of the XML source (i.e. the response from Amazon). In general, lookup some information about "xpath predicates".

Will do. However I'm not a programmer so hopefully it'll make some sense....

Trying to upload a sample but it wont go though yet.

Sorry I forgot to include it before.

Link to comment
Share on other sites

I believe that if you change your main selector to:

...

<xsl:for-each select="amz:ItemLookupResponse/amz:Items/amz:Item[amz:ItemAttributes/amz:Format='DVD' or amz:ItemAttributes/amz:ProductGroup='Books' or substring(amz:ItemAttributes/amz:PublicationDate,1,7)='2011-01']">

<ROW>

...

it should work. Hard to test with your data.

Link to comment
Share on other sites

I believe that if you change your main selector to:

...

<xsl:for-each select="amz:ItemLookupResponse/amz:Items/amz:Item[amz:ItemAttributes/amz:Format='DVD' or amz:ItemAttributes/amz:ProductGroup='Books' or substring(amz:ItemAttributes/amz:PublicationDate,1,7)='2011-01']">

<ROW>

...

it should work. Hard to test with your data.

Thank you!

I had the basic form but I forgot to add the 'amz:' before itemAttributes and Format!!

I thought I was just way off base so I left that out of the upload.........

Here's a basic final for anyone needing it.

Side note: The actual product group should have been singular Book instead of Books.

Also now I just need to figure out how to pass a variable into it (if that's even possible) instead of separate XSL's for each. Say 1 for Book, 1 for DVD, etc...

amazon_info_search_alternateversions_Filtered_upload.zip

Link to comment
Share on other sites

I believe that if you change your main selector to:

...

<xsl:for-each select="amz:ItemLookupResponse/amz:Items/amz:Item[amz:ItemAttributes/amz:Format='DVD' or amz:ItemAttributes/amz:ProductGroup='Books' or substring(amz:ItemAttributes/amz:PublicationDate,1,7)='2011-01']">

<ROW>

...

it should work. Hard to test with your data.

One last thing... 'cause I'm trying but it aint working.

IF I need to match an either to 1 or 2 and a then 1 how does it go??? Like maybe I want all PaperBack books and Audio CD's under 1000 sales rank..........

<xsl:for-each select="amz:ItemLookupResponse/amz:Items/amz:Item[amz:ItemAttributes/amz:Binding='Paperback' or amz:ItemAttributes/amz:Binding='Audio CD' and amz:SalesRank<1000]">

?????????

Link to comment
Share on other sites

IF I need to match an either to 1 or 2 and a then 1 how does it go???

I am not sure what that means... Perhaps:

...[amz:ItemAttributes/amz:Binding='Paperback' or amz:ItemAttributes/amz:Binding='Audio CD'] [amz:SalesRank<1000]">

Please have mercy upon those of us trying to answer and proof-read your posts.

now I just need to figure out how to pass a variable

Maybe you should write to Filemaker, Inc. about this. The XSLT processor DOES allow for a 'parameter' to be passed to it - but FMI's implementation didn't provide access to this feature.

Link to comment
Share on other sites

I am not sure what that means... Perhaps:

...[amz:ItemAttributes/amz:Binding='Paperback' or amz:ItemAttributes/amz:Binding='Audio CD'] [amz:SalesRank<1000]">

Please have mercy upon those of us trying to answer and proof-read your posts.

Maybe you should write to Filemaker, Inc. about this. The XSLT processor DOES allow for a 'parameter' to be passed to it - but FMI's implementation didn't provide access to this feature.

My apologies.... What I should have said was if I only wanted Paperbacks under 1000 salesrank and Audio CD's under 1000 salesrank ...... but nothing else.

I ended up putting the salesrank FIRST, an 'and' ... then the 'or' ... like so:

.....amz:Item[amz:='SalesRank' and amz:ItemAttributes/amz:Binding='Audio CD' or amz:ItemAttributes/amz:Binding='Paperback']">

HOWEVER ... mine is probably incorrect structure but it did work.

THANK YOU FOR YOUR HELP !!!

Link to comment
Share on other sites

This topic is 4307 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
 Share

×
×
  • Create New...

Important Information

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