eBay SDK for Java
Attributes & Catalogs > Retrieving Attribute and Product Meta-Data > Retrieving the Product Finder XSL Stylesheet 
 



< Back Next >

Retrieving the Product Finder XSL Stylesheet

The information in this section is only applicable for applications that support listing with Pre-filled Item Information.

The eBay Platform provides the Product Finder XSL stylesheet to give developers a dynamic and scalable way to render product finder meta-data in an application. The stylesheet is updated as necessary when the product finder meta-data changes.

Use GetProductFinderXSLCall to retrieve the latest version of the stylesheet. You should not hard-code the stylesheet in your application. The Attributes Library includes a sample data-source provider class called ProductFinderXslDownloader, which executes GetProductFinderCall and handles other common functionality that you need when working with the product finder stylesheet. This class implements the IProductFinderXslProvider interface and caches the data in memory. If you want to use the Attributes Library, you can use the sample downloader class or you can create your own implementation of the IProductFinderXslProvider interface that stores the data in a different way (such as in a database).

This section describes the following process:

Prerequisites

Step 1:  Indicate the Stylesheet to Return

Step 2:  Make the API Call

Step 3:  Decode the Product Finder XSL Stylesheet

Step 4:  Store the Stylesheet for Future Use

Step 5:  Maintain the Product Finder XSL Stylesheet

Step 6:  Next Steps

Prerequisites

There are no special steps to perform before executing GetProductFinderXSLCall. Of course, in order for the data to be useful, you need to also execute GetProductFinderCallto retrieve the XML that you will transform.

Step 1: Indicate the Stylesheet to Return

The first time you execute GetProductFinderXSLCall, you should retrieve the latest Product Finder XSL stylesheet, and determine the current version of the file. If you are using the Attributes Library, the same principle applies when working with data-source provider classes that implement IProductFinderXslProvider, such as the ProductFinderXslDownloader class.

In subsequent calls, you can use the DetailLevel property to retrieve only the version of the file to check whether the version has changed. If it has, get the latest stylesheet. To retrieve a particular version of the file, specify values in the FileName and FileVersion fields. To retrieve the latest version, leave the FileVersion field blank.

Currently, only XSL file is returned from this call. Whether or not you need to specify FileName depends on your application's design. In the future, this call might return more XSL files. If you design your application with the assumption that only one file will be returned, you may need to update your code immediately if the call starts retrieving other XSL files. If you specify FileName, your application will continue to only retrieve the desired file, and you can update your code at your convenience to handle other kinds of XSL files.

See GetProductFinderXSL for information on the best ways to use data filters like XSLFileName, XSLFileVersion, and DetailLevel.

You can expect the Product Finder XSL to be updated at least once or twice a month, but it may sometimes be updated more frequently than this interval. Use GetProductFinderXSLCall or a data-source provider like the ProductFinderXslDownloader class to retrieve the XSL whenever it changes.

These fields are also summarized in GetProductFinderXSL.

When you use the Attributes Library to retrieve the Product Finder XSL stylesheet for an eBay site, you create an instance of the ProductFinderMaster class and configure it to use a data-source provider, such as the ProductFinderXslDownloader class. The example below shows creating the master class and the data-source provider.

Example 19-11 Retrieving the Latest Item Specifics SYI XSL Stylesheet 
try 
{ 
   ProductFinderMaster pfm        = new ProductFinderMaster(); 
   ProductFinderXslDownloader asd = new ProductFinderXslDownloader(); 

Step 2: Make the API Call

Making the API call with the Attributes Library entails invoking the downloadProductFinderXsl( ) method on your data-source provider class, which retrieves the stylesheet(s) from eBay and caches them in memory. If you create your own data-source provider class that implements the IProductFinderXslProvider interface, your class would call the getProductFinderXSL( ) method defined on the GetProductFinderXSLCall class to download the data and then use the getXslFile( ) method to retrieve the XSL file(s) locally without retrieving the same data from eBay again. In the example below, the asd variable holds the data-source provider. The data-source provider is then set on the ProductFinderMaster object (the pfm variable) to be retrieved later during the listing flow.  

Example 19-12 Making the API Call 
   asd.downloadProductFinderXsl(asn); 
   pfm.setXslProvider(asd); 
} 
// Catch and handle errors, displaying appropriate messages for the end-user 

GetProductFinderXSLCall returns a string that specifies the product finder XSL stylesheet for the site to which you sent the request.

See GetProductFinderXSL for a list of the fields that are returned.

Step 3: Decode the Product Finder XSL Stylesheet

An XSL stylesheet that is returned in the XSLFile.FileContent property is initially formatted as a MIME base-64-encoded ASCII string. You need to decode the string before you can use the XSL stylesheet. When you use the getProductFinderXSL( ) method on GetProductFindersXSLCall, it decodes the string for you.

Step 4: Store the Stylesheet for Future Use

Store the XSL stylesheet (e.g., as a string in a database or as a flat file) for future use.

For information about how to work with the Product Finder XSL stylesheet and how to parse the post data, see Working with the Product Finder XSL Stylesheet.

Step 5: Maintain the Product Finder XSL Stylesheet

At the beginning of each day that you will render the GetProductFinder XML, retrieve the latest Product Finder XSL stylesheet. Use the FileVersion input property in combination with the FileName property to retrieve a particular version of an XSL stylesheet.

Step 6: Next Steps

When a user chooses to list in a category that supports a product finder search, apply the stylesheet to render a product finder returned from GetProductFinderCall or a data-source provider class that implements the IProductFinderXmlProvider interface in your application's user interface. Once the user selects the attributes to search on and submits the page, the JavaScript that is included in the stylesheet will generate post data that you can use to determine the attributes and values that the user has selected. See Working with the Product Finder XSL Stylesheet.


< Back Next >


 
Attributes & Catalogs > Retrieving Attribute and Product Meta-Data > Retrieving the Product Finder XSL Stylesheet 
© 2005–2007 eBay Inc. All rights reserved.