<commit_before><?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.3//EN" "http://forrest.apache.org/dtd/document-v13.dtd">
<document> 
  <header> 
    <title>SourceTypeAction (content aware pipelines)</title> 
  </header> 
  <body> 
    <section> 
      <title>Introduction</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="documentv13">
    <document-declaration public-id="-//APACHE//DTD Documentation V1.3//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> <commit_msg>Clarify the sitemap snippet and link to an example.<commit_after><?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.3//EN" "http://forrest.apache.org/dtd/document-v13.dtd">
<document> 
  <header> 
    <title>SourceTypeAction (content aware pipelines)</title> 
  </header> 
  <body> 
    <section> 
      <title>Introduction</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 your sitemap. Example:</p> 
      <source><![CDATA[<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 <map:components>
  <...>]]>
  <strong><![CDATA[<map:actions>
   <map:action name="sourcetype"
      src="org.apache.cocoon.acting.sourcetype.SourceTypeAction">
    <sourcetype name="download-v1.0">
     <document-declaration
        public-id="-//Acme//DTD Download Documentation V1.0//EN" />
    </sourcetype>      
   </map:action>
  </map:actions>]]></strong><![CDATA[
 </map:components>
 <...>
</map:sitemap>]]></source> 
      <p>There are other examples in <code>main/webapp/forrest.xmap</code></p>
      <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>
      <p>See a real-life example in the advanced section of the
        <link href="your-project.html#adding_new_content_type_2">Using Forrest</link>
        document.
      </p>
    </section> 
  </body> 
</document> 
{'fraction_non_alphanumeric': 0.1040241215354285, 'fraction_numerical': 0.00800185550272527, 'mean_word_length': 2.9833718244803693, 'pattern_counts': {'":': 0, '<': 188, '<?xml version=': 2, '>': 188, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3690277', 'n_tokens_mistral': 2507, 'n_tokens_neox': 2361, 'n_words': 896}