<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You 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.
-->

<!-- $Id: simple.xsp 487399 2006-12-14 23:50:24Z anathaniel $ -->

<xsp:page language="java" 
          xmlns:xsp="http://apache.org/xsp" 
          xmlns:xsp-request="http://apache.org/xsp/request/2.0" 
          xmlns:i18n="http://apache.org/cocoon/i18n/2.1">

  <xsp:logic>
    private static int count = 0;
  </xsp:logic>

  <document i18n:attr="language" language="language">
    <xsp-request:get-session/>
    <xsp:logic>
      synchronized (this) {
          count++;
      }
    </xsp:logic>
    <title>
      <i18n:text>titletext</i18n:text>
    </title>
    <form method="GET">
      <input type="text" name="username">
        <xsp:attribute name="value"><xsp-request:get-parameter name="username" default="[yourname]" as="string" form-encoding="UTF-8"/></xsp:attribute>
      </input>
      <input type="submit" name="submit" value="Submit"/>
    </form>
    <annotation>
      <i18n:translate>
        <i18n:text key="doclink"/>
        <i18n:param>
          <link href="http://cocoon.apache.org/2.1/userdocs/transformers/i18nTransformer.html">Cocoon 2 Web Site</link>
        </i18n:param>
      </i18n:translate>
    </annotation>
    <sub-title>
      <i18n:translate>
        <i18n:text key="count_title"/>
        <i18n:param type="number" pattern="000000">
          <xsp:expr>count</xsp:expr>
        </i18n:param>
        <i18n:param>
          <i18n:date-time src-pattern="EEE MMM dd hh:mm:ss zzz yyyy" src-locale="en" pattern="MEDIUM">
            <xsp:expr>new Date()</xsp:expr>
          </i18n:date-time>
        </i18n:param>
      </i18n:translate>
    </sub-title>

    <content>
      <para title="first" name="article" i18n:attr="title name">
        <i18n:text key="a_key">article_text1</i18n:text>
      </para>
      <para title="second" name="article" i18n:attr="title name">
        <i18n:text>article_text2</i18n:text>
      </para>
      <para title="third" name="article" i18n:attr="title name">
        <i18n:translate>
          <i18n:text key="Hello"/>
          <i18n:param>
            <strong>
              <xsp-request:get-parameter name="username" default="none" as="string" form-encoding="UTF-8"/>
            </strong>
          </i18n:param>
        </i18n:translate>
      </para>
      <para title="forth" name="article" i18n:attr="title name">
        <i18n:translate>
          One = {one}, two = {two}, {third}! {forth}
          This line is not translated {forth}
          <i18n:param name="one">
            <i18n:text>
              <xsp:expr>"ONE".toLowerCase()</xsp:expr>
            </i18n:text>
          </i18n:param>
          <i18n:param name="two">
            <i18n:text>two</i18n:text>
          </i18n:param>
          <i18n:param name="third">baby</i18n:param>
          <i18n:param name="forth">~</i18n:param>
        </i18n:translate>
      </para>

      <para title="Number formatting (not translated)" name="Article">
        <i18n:translate>
          Number: {0} | Currency: {1} | Percent: {2} | Processed on: {3}
          <!--Old format: i18n:param type="number" src-locale="en" value="1703.74" /-->
          <i18n:param>
            <i18n:number src-locale="en"><xsp:expr>17 + 3 + 1974</xsp:expr></i18n:number>
          </i18n:param>
          <!--Old format: i18n:param type="currency" src-locale="en">27.24</i18n:param-->
          <i18n:param>
            <i18n:number type="currency" src-locale="en"><xsp:expr>2002.0 / 28.0</xsp:expr></i18n:number>
          </i18n:param>
          <i18n:param><i18n:number type="percent" src-locale="en" value="1.205"/></i18n:param>
          <i18n:param><i18n:date-time pattern="MEDIUM"/></i18n:param>
        </i18n:translate>
      </para>

      <!--
        - Possibly bug in XSP: requires escaping of '\'
        -->
      <para title="Evaluated {first}, {second}, escaped \\{third\\}." name="i18n:expr" i18n:expr="title">
        This paragraph is an example of attribute expression evaluation.
      </para>
    </content>

    <bottom>
      <copyright>Copyright 1999-2006 The Apache Software Foundation</copyright>
    </bottom>
  </document>
</xsp:page>
