Here is how we do it. Just stash the DOM object for the XML into the sesssion.

<map:match pattern="assoc-list">
<map:select type="sessionAttributeExists">
<map:parameter name="attribute-name" value="assoc-cache"/>
<map:when test="true">
<map:generate type="session-attr">
<map:parameter name="attr-name" value="assoc-cache"/>
</map:generate>


<map:serialize type="xml"/>
</map:when>
<map:otherwise>
<map:generate src="xml/assoc_query.xml"/>
<map:transform type="sql">
<map:parameter name="use-connection" value="mbrdb"/>
<map:parameter name="userid" value="{userid}"/>
</map:transform>
<map:transform type="writeDOMsession">
<map:parameter name="dom-name" value="assoc-cache"/>
<map:parameter name="dom-root-element" value="page"/>
</map:transform>


                       <map:serialize type="xml"/>
                   </map:otherwise>
               </map:select>
           </map:match>

We wrote an selector that tests to see if an attribute exists. I've included the source (minus includes). It would just as easily be an action instead.

public class SessionAttributeExistsSelector extends AbstractLogEnabled
   implements Configurable, ThreadSafe, Selector {

protected String defaultName;

public void configure(Configuration config) throws ConfigurationException {
this.defaultName = config.getChild("attribute-name").getValue(null);
}


public boolean select(String expression, Map objectModel, Parameters parameters) {
String name = parameters.getParameter("attribute-name", this.defaultName);


       if (name == null) {
           getLogger().warn("No attribute name given -- failing.");
           return false;
       }

Object value = ObjectModelHelper.getRequest(objectModel).getSession().getAttribute(name);

if (value == null) {
getLogger().debug("Session attribute '" + name + "' does not exist.");
return false;
}


       return true;
   }
}

Geoff Howard wrote:

Justin Makeig wrote:

I have a table of contents (TOC) document that is being aggregated with an
XML instance document for each page request. For example, when
http://mysite.com/Instance is requested, the sitemap aggregator generates a
document that looks like:


<Page>
    <TOC/>
    <Instance/>
</Page>

where TOC and Instance are loaded from the file system using
map:aggreate/map:part.

This system allows me to use XSL keys instead of the document function to
reference elements in the TOC making the transforms speedy and cacheable.


The TOC document is around 50K and growing arithmetically. Since the TOC is
generated at design-time (not run-time), I would like to cache it so that it
doesn't have to reparsed for every request. Is this possible? Is it already
being done with map:aggregate? Any assistance would be much appreciated.



Can you send your sitemap snippet that does the aggregation?


Geoff


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to