<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
  Copyright 2002-2004 The Apache Software Foundation

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- vi: set et sw=2 ts=2 tw=75: -->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.2//EN" "http://apache.org/forrest/dtd/document-v12.dtd">
<document> 
  <header> 
    <title>SourceTypeAction</title> 
  </header> 
  <body> 
    <section> 
      <title>Intro</title> 
      <p>SourceTypeAction assigns a "type" (a string) to an XML file. This is
        done based on information occuring in the header of the XML file, up to the
        document (root) element. This type is then returned to the sitemap as a
        variable with the name 'sourcetype'. If no matching sourcetype could be be
        found, null is returned and thus the contents of the action element will not be
        executed.</p> 
      <p>SourceTypeAction works by pull-parsing the document and collecting
        information such as the public id, the processing instructions, the document
        element local name and namespace, and the xsi:schemaLocation and
        xsi:noNamespaceSchemaLocation attributes. This information is then compared
        with the rules described in the configuration of the SourceTypeAction.</p> 
    </section> 
    <section> 
      <title>Configuration</title> 
      <p>The action should be declared and configured in the map:actions
        section of the sitemap. Example:</p> 
      <source><![CDATA[<map:action name="sourcetype" src="org.apache.cocoon.acting.sourcetype.SourceTypeAction">
  <sourcetype name="documentv11">
    <document-declaration public-id="-//APACHE//DTD Documentation V1.1//EN"/>
  </sourcetype>
  <sourcetype name="foo">
    <document-element local-name="foo">
  </sourcetype>
</map:action>]]></source> 
      <p>Each sourcetype-tag declares a source type. Inside the sourcetype-tag
        a number of rules can be defined, described below. The sourcetypes will be
        checked in the same order as they are defined in the configuration, the first
        sourcetype of which all rules match will be used.</p> 
      <p>These are the available rules:</p> 
      <dl> 
        <dt>document-declaration</dt> 
        <dd>This rule checks the public ID. It takes one attribute
          <code>public-id</code>.</dd> 
        <dt>document-element</dt> 
        <dd>This rule checks the local name and/or namespace of the document
          element. These are specified with the attributes <code>local-name</code> and
          <code>namespace</code>. At least one of these two is required.</dd> 
        <dt>processing-instruction</dt> 
        <dd>This rule checks a processing instruction. It can take two
          attributes: <code>target</code> and <code>data</code>. The target attribute is
          always required, the data attribute is optional.</dd> 
        <dt>w3c-xml-schema</dt> 
        <dd>This rule checks the value of the xsi:schemaLocation and
          xsi:noNamespaceSchemaLocation attributes on the document element. These are
          specified with the attributes <code>schema-location</code> and
          <code>no-namespace-schema-location</code>.</dd> 
      </dl> 
    </section> 
    <section> 
      <title>Usage</title> 
      <p>The source of which the sourcetype must be defined must be specified
        using the 'src' attribute on the map:act element.</p> 
      <source><![CDATA[<map:act type="sourcetype" src="{1}">
...
</map:act>]]></source> 
    </section> 
  </body> 
</document> 
