|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.xml.AbstractXMLProducer org.apache.cocoon.generation.AbstractGenerator org.apache.cocoon.generation.ServiceableGenerator org.apache.cocoon.generation.TraversableGenerator org.apache.cocoon.generation.XPathTraversableGenerator
public class XPathTraversableGenerator
Generates an XML collection listing performing XPath queries on XML sources. It can be used both as a plain TraversableGenerator or, if an XPath is specified, it will perform an XPath query on every XML resource, where "xml resource" is, by default, any resource ending with ".xml", which can be overriden by setting the (regexp) pattern "xmlFiles as a sitemap parameter, or where the name of the resource has a container-wide mime-type mapping to 'text/xml' such as specified by mime-mapping elements in a web.xml descriptor file. The XPath can be specified in two ways:
Field Summary | |
---|---|
protected Context |
context
The cocoon context used for mime-type mappings |
protected Document |
doc
The document that should be parsed and (partly) included. |
protected org.apache.cocoon.generation.XPathTraversableGenerator.XPathPrefixResolver |
prefixResolver
The prefix resolver for namespaced queries |
protected XPathProcessor |
processor
The XPath processor. |
protected static String |
QUERY_ATTR_NAME
Attribute for the XPath query. |
protected static String |
RESULT_DOCID_ATTR
The document containing a successful XPath query |
protected org.apache.regexp.RE |
xmlRE
The regular expression for the XML files pattern. |
protected String |
xpath
The XPath. |
protected static String |
XPATH_NODE_NAME
Local name for the element that contains the included XML snippet. |
Fields inherited from class org.apache.cocoon.generation.TraversableGenerator |
---|
attributes, cacheKeyParList, COL_NODE_NAME, DATE_ATTR_NAME, dateFormatter, depth, excludeRE, includeRE, isRequestedSource, LASTMOD_ATTR_NAME, PREFIX, refreshDelay, RES_NAME_ATTR_NAME, RESOURCE_NODE_NAME, reverse, rootRE, SIZE_ATTR_NAME, sort, URI, URI_ATTR_NAME, validity |
Fields inherited from class org.apache.cocoon.generation.ServiceableGenerator |
---|
manager |
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator |
---|
objectModel, parameters, resolver, source |
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
---|
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer |
Fields inherited from interface org.apache.cocoon.generation.Generator |
---|
ROLE |
Constructor Summary | |
---|---|
XPathTraversableGenerator()
|
Method Summary | |
---|---|
protected void |
addContent(TraversableSource source)
Allow subclasses a chance to generate additional elements within collection and resource elements. |
void |
dispose()
Release all resources. |
protected boolean |
isXML(TraversableSource path)
Determines if a given TraversableSource shall be handled as XML. |
protected void |
performXPathQuery(TraversableSource in)
Performs an XPath query on the source. |
void |
recycle()
Recycle resources |
void |
service(ServiceManager manager)
Set the current ServiceManager instance used by this
Serviceable . |
void |
setup(SourceResolver resolver,
Map objectModel,
String src,
Parameters par)
Set the request parameters. |
Methods inherited from class org.apache.cocoon.generation.TraversableGenerator |
---|
addAncestorPath, addPath, endNode, generate, getAncestors, getKey, getValidity, isExcluded, isIncluded, isRoot, setNodeAttributes, startNode |
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
---|
setConsumer, setContentHandler, setLexicalHandler |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.cocoon.xml.XMLProducer |
---|
setConsumer |
Field Detail |
---|
protected static final String XPATH_NODE_NAME
protected static final String QUERY_ATTR_NAME
protected static final String RESULT_DOCID_ATTR
protected org.apache.regexp.RE xmlRE
protected Document doc
protected String xpath
protected XPathProcessor processor
protected org.apache.cocoon.generation.XPathTraversableGenerator.XPathPrefixResolver prefixResolver
protected Context context
Constructor Detail |
---|
public XPathTraversableGenerator()
Method Detail |
---|
public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException
TraversableGenerator
setup
in interface SitemapModelComponent
setup
in class TraversableGenerator
resolver
- the SourceResolver objectobjectModel
- a Map
containing model objectsrc
- the Traversable Source to be XMLized specified as
src
attribute on <map:generate/>par
- configuration parameters
ProcessingException
SAXException
IOException
public void service(ServiceManager manager) throws ServiceException
ServiceableGenerator
ServiceManager
instance used by this
Serviceable
.
service
in interface Serviceable
service
in class ServiceableGenerator
ServiceException
public void dispose()
ServiceableGenerator
dispose
in interface Disposable
dispose
in class ServiceableGenerator
protected void addContent(TraversableSource source) throws SAXException, ProcessingException
TraversableGenerator
addContent
in class TraversableGenerator
source
- the source to generate additional data for.
SAXException
ProcessingException
protected boolean isXML(TraversableSource path)
path
- the TraversableSource to check
protected void performXPathQuery(TraversableSource in) throws SAXException
in
- the Source the XPath is performed on.
SAXException
- if something goes wrong while adding the XML snippet.public void recycle()
recycle
in interface Recyclable
recycle
in class TraversableGenerator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |