| ||
![]() |
Definition of DocTypes | |
|
The phrase "doctypes" has 2 definitions within Lenya. The first is data formats, referred to as "Custom Doctypes" or "Resource Types". The second allows different displays of data by overloading the "doctype parameter".
"Custom Doctypes" are used when you want different fields than the standard Lenya document. If you want to display information about products, you could create a Custom Doctype with fields, such as: ProductId ProductName ProductDescription ProductPrice Deciding the DoctypeDoctype is decided in "{pub}/parameter-doctype.xmap". This value is decided first by URL matching. The default is for "*.html" to use the "sourcetype" Action, which translates the root element of the target XML document. So you can decide the doctype by either the URL or the XML of the target. WARNING: Lenya decides the doctype once for each document, and then caches it. If you want to use different stylesheets for the same target, see Using Multiple Stylesheets for the Same Content. Deciding the Doctype from the XML of the targetIf your Custom Doctype has a unique root element, you can set it by adding a namespace to the SourceTypeAction action: <map:action logger="sitemap.action.sourcetype" name="sourcetype" src="org.apache.cocoon.acting.sourcetype.SourceTypeAction">
would match.
<document-element namespace="http://www.w3.org/1999/xhtml"/>
Checks the xmlns attribute of the first element, so <html xmlns="http://www.w3.org/1999/xhtml" ...>
would match. <document-element local-name="xxx" namespace="http://www.w3.org/1999/xhtml"/>
Combines the last two rules. Deciding the Doctype from the URL requestedThe doctype can be overridden based on the URL. Lenya uses this to force {pub}/index_xx.html to be the "homepage"doctype. The XML for the homepage content is a standard Lenya document, but the XSL processing using different files. <map:match pattern="*/mySpecialArea/**.html">
XSL TransformationAn XML document with these fields requires different processing than a standard Lenya document, so you use the "doctype parameter" to specify different XSL. That value is then used by "{pub}/publication-sitemap.xmap" to choose the XSLT. There are usually two stylesheets for a Custom Doctype: 1. "mydoctype2xtml.xsl" is used to convert non-standard XML to XHTML. Use it to turn your custom XML into displayable HTML. Lenya expects the content to be in an element <div id="body">. 2. "page2xhtml-mydoctype.xsl" is used to add the navigation elements. It is called after the content is aggregated with various navigation XHTML, such as menus and search. If the page layout is the same as your basic website, use: <?xml version="1.0"?>
Usage Instructions1. (Optional) Create custom XML. 2. Modify {pub}/parameter-doctype.xmap to return a different value. 3. (Optional) Create file {pub}/xslt/{myDoctype}2xhtml.xsl to create XHTML with a <div id="body"> element. 4. Create file {pub}/xslt/page2xhtml-MyLayoutType.xsl to layout the content and navigation for display. Usage InstructionsTo see what doctype is being set, temporarily add this to the top of the pipelines in publication-sitemap.xml: <map:match pattern="**">
variables.xsl: <?xml version="1.0" encoding="UTF-8" ?>
|