Searching the FAQs
No FAQ site would be fully functional without the ability to perform text searches. This site uses the Oracle Text search engine to search XML either as content or structurally using XPaths. The index.xsql page combines these text searches with category searches to create a single result, as evidenced by the following sample query for all Java components that reference DOM:http://localhost:8988/xdkus/app_faq/index.xsql?
pagename=search&search=DOM&cat=all&lang=JAVA
This URL links to a new XSQL page, search.xsql, that performs a direct search instead of the browse action discussed previously. This page has all the same elements as list.xsql except that it takes an additional parameter, search, and it has an additional predicate, as shown in the following query:
<xsql:query skip-rows="{@paging-skip}" max-rows="{@paging-max}">
<![CDATA[
SELECT extractValue(value(x),'/FAQ/TITLE') as title,
extractValue(value(x),'/FAQ/@id') as id
FROM faq x
where extractValue(value(x),'/FAQ/LANGUAGE/text()') ='{@lang}'
and contains(value(x),'{@search}')>0
order by id
]]>
</xsql:query>
Note that the Oracle Text CONTAINS() function is now added to the WHERE clause to narrow the selection process further. The output from this page will again be a list of FAQs that is displayed using the identical paging and listing code discussed earlier.