Certain form handler properties (documentSets
, parserOptions
, prefAnswerConstr
, and weightedProps
) set query tags that can contain child tags. To set these query tags, the form handler must gather user input and use it to assemble the XML. This can be an involved process, especially if the XML is complex, with many levels of nested tags.
For example, the contents of the <documentSets>
tag might look something like this:
<and> <strprop op="equal" case="false" name="childSKU.color"> rose </strprop> <numprop op="lesseq" name="childSKU.price"> 30.00 </numprop> </and>
Within the <documentSets>
tag, these tags would limit search results to items with a property key called childSKU.color
with an associated value of "rose"
and a property key called childSKU.price
with an associated value that is less than or equal to 30.00. This is only a simple constraints example. Actual <documentSets>
tags can be arbitrarily complex, and can include nested Boolean (<or>
,<and>
, and <not>
) tags.
Query tags that can contain nested tags are represented in the form handlers by properties of type atg.search.query.formhandlers.XMLBuilder
. XMLBuilder
is a simple interface with one method, buildXML()
, which the form handlers invoke when they assemble the query. You can create your own implementation of this interface, and point the corresponding form handler property at a Nucleus component of this custom class.
For example, to specify a custom XML builder to use for the <documentSets>
tag:
documentSetsBuilder=/app/customXMLBuilder
MapXMLBuilder
If no custom builder is specified for a given XMLBuilder
type form handler property, the form handler will default to using the atg.search.query.formhandlers.MapXMLBuilder
class. This class is designed to allow creation of arbitrarily complex XML in JSPs.
For more information, see Appendix B, Using the MapXMLBuilder Class.
CustomCatalogXMLBuilder
Queries for ATG Commerce custom catalogs can use the atg.commerce.search.CustomCatalogXMLBuilder
class, an extension of the MapXMLBuilder
class, as the documentSetsBuilder
. This adds an extra dynamic constraint to the query that checks to see if all the product document results are part of the user’s catalog.
CustomCatalogXmlBuilder
constructs an AND
query that contains the existing query and a query constraint for the catalog, which checks to see if the product.ancestorCatalogs
property contains the catalog currently set as the user’s.