cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@cocoon.zones.apache.org
Subject [DAISY] Updated: XPathTraversableGenerator
Date Thu, 27 Mar 2008 21:08:27 GMT
A document has been updated:

http://cocoon.zones.apache.org/daisy/documentation/873.html

Document ID: 873
Branch: main
Language: default
Name: XPathTraversableGenerator (unchanged)
Document Type: Sitemap Component (unchanged)
Updated on: 3/27/08 9:08:15 PM
Updated by: Luca Morandini

A new version has been created, state: draft

Parts
=====

Short description
-----------------
This part has been added.
Mime type: text/xml
File name: null
Size: 251 bytes
Content:
<html>
<body>

<p>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.</p>

</body>
</html>


Long description
----------------
This part has been added.
Mime type: text/xml
File name: null
Size: 2536 bytes
Content:
<html>
<body>

<p>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 <tt>xmlFiles</tt> (this has the effect
of increasing, not limiting, the scope of the search) 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:</p>

<ol>
<li>By using an XPointerish syntax in the URL: everything following the pound
sign (possiby preceding query string arguments) will be treated as the XPath;
</li>
<li>Specifying it as a sitemap parameter named "xpath"</li>
</ol>

<p class="note">XPathTraversableGemerator It is a subclass of
TraversableGenerator, hence it uses the same st of parameters, adding some of
its own.</p>

<p><strong> Sample usage:</strong></p>

<pre><strong>Sitemap:</strong>
&lt;map:match pattern="documents/**"&gt;
	&lt;map:generate type="xpathdirectory" src="docs/{1}#/article/title|/article/abstract"
&gt;
     		&lt;map:parameter name="xmlFiles" value="\.xml$"/&gt;
	&lt;/map:generate&gt;
	&lt;map:serialize type="xml"/&gt; 
&lt;/map:match&gt;

<strong>Request:</strong>
   http://www.some.host/documents/test

<strong>Result:</strong>
 &lt;collection:collection
   name="test" lastModified="1010400942000"
   date="1/7/02 11:55 AM" requested="true"
   xmlns:collection="http://apache.org/cocoon/collection/1.0"&gt;
   &lt;collection:collection name="subdirectory" lastModified="1010400942000" date="1/7/02
11:55 AM" /&gt;
   &lt;collection:resource name="test.xml" lastModified="1011011579000" date="1/14/02
1:32 PM"&gt;
     &lt;collection:xpath docid="test.xml" query="/article/title"&gt;
       &lt;title&gt;This is a test document&lt;/title&gt;
       &lt;abstract&gt;
         &lt;para&gt;Abstract of my test article&lt;/para&gt;
       &lt;/abstract&gt;
     &lt;/collection:xpath&gt;
   &lt;/collection:resource&gt;
   &lt;collection:resource name="test.gif" lastModified="1011011579000" date="1/14/02
1:32 PM"&gt;
 &lt;/collection:collection&gt;
</pre>

<p class="note">If you need to use namespaces, you can set them as sitemap
parameters in the form:<br/>
<tt>&lt;map:parameter name="xmlns:<em>your prefix</em>"
value="nsURI"/**"&gt;</tt></p>

</body>
</html>


Mime
View raw message