<?xml version="1.0"?>
<!-- 
tagnetic.org: Tools for tag parsing and rich web experiences.
Copyright (C) 2004-2005 tagnetic.org

This file is part of TagneticCore, a tag parser.

TagneticCore is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

TagneticCore is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser Public License for more details.

You should have received a copy of the GNU Lesser Public License
along with TagneticCore; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Also available at: http://www.gnu.org/licenses/lgpl.html
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="1.0">
	<xs:element name="tagneticconfig" type="tagneticConfigType"/>
	<xs:complexType name="tagneticConfigType">
		<xs:annotation><xs:documentation>Root element for tagneticconfig files.</xs:documentation></xs:annotation>
		<xs:sequence>
			<xs:element name="include" type="xs:string" minOccurs="0" maxOccurs="unbounded">
				<xs:annotation><xs:documentation>Relative path, relative to tagneticconfig file that defines this element, to another tagneticconfig file that will be included as part of this configuration file.</xs:documentation></xs:annotation>
			</xs:element>
			<xs:element name="compilation" type="compilationType" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="elementsyntax" type="elementSyntaxType" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="tags" type="tagsType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="compilationType">
		<xs:annotation><xs:documentation>Contains the information on the source directory/files, and information
		on how to compile them to the destination directory/files.</xs:documentation></xs:annotation>
		<xs:sequence>
			<xs:element name="source" type="SourceType"/>
			<xs:element name="destination" type="DestinationType"/>
			<xs:element name="filefilter" type="FileFilterType" minOccurs="0"/>
			<xs:element name="recursedirectories" type="boolType" default="true" minOccurs="0"/>
			<xs:element name="copynonmatchingfiles" type="boolType" default="false" minOccurs="0"/>
			<xs:element name="locales" type="xs:string" minOccurs="0">
				<xs:annotation><xs:documentation>A list of comma-separated locales. The source files will be parsed once for each value in the comma-separated list, and a separate destination directory will be created for each value. For example, if <b>en_US,fr</b> is the locale list, and the destination directory is <b>outdir</b>, then when Tagneto finishes processing, there will be a <b>outdir/en_US</b> directory anda <b>outdir/fr</b> directory. If <b>branch</b> elements are used in the tagneticconfig, the locale directories will be under the branch directories. See the <a href="http://java.sun.com/j2se/1.4.2/docs/api/index.html">Locale JavaDoc</a> for a discussion of valid locale values.</xs:documentation></xs:annotation>
			</xs:element>
			<xs:element name="branch" type="BranchType" minOccurs="0"/>
			<xs:element name="postfilters" type="PostFiltersType" minOccurs="0"/>
			<xs:element name="fileoverlays" type="FileOverlaysType" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>
     <xs:complexType name="SourceType">
		 <xs:annotation><xs:documentation>Specifies the source directory. This MUST be a directory. Individual files are not allowed. Use the <b>filefilter</b> element to choose which files under that directory to process. Also, this MUST be a relative path, relative to the tagneticconfig file that is defining this element.</xs:documentation></xs:annotation>
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="charset" type="xs:string">
					<xs:annotation><xs:documentation>The charset encoding name. Useful in internationalization support. See <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html">Charset JavaDoc</a> for information on valid charset names.</xs:documentation></xs:annotation>
				</xs:attribute>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
	<xs:complexType name="DestinationType">
		<xs:annotation><xs:documentation>Specifies the destination directory. This MUST be a directory, and it MUST be a relative path, relative to the tagneticconfig file that is defining this element.</xs:documentation></xs:annotation>
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="charset" type="xs:string">
					<xs:annotation><xs:documentation>The charset encoding name. Useful in internationalization support. See <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html">Charset JavaDoc</a> for information on valid charset names.</xs:documentation></xs:annotation>
				</xs:attribute>
				<xs:attribute name="extension" type="xs:string">
					<xs:annotation><xs:documentation>Specify a different extension to use for the files that get compiled/transformed and placed in the destination directory. The value of this attribute will replace any text after the last dot of the source file name. Example: to rename any *.xml files to .html, use <b>extension="html"</b>.</xs:documentation></xs:annotation>
				</xs:attribute>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
	<xs:complexType name="FileOverlaysType">
		<xs:annotation><xs:documentation>The list of file overlays to be applied to any matching source files.</xs:documentation></xs:annotation>
		<xs:sequence>
			<xs:element name="fileoverlay" type="FileOverlayType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="FileOverlayType">
		<xs:annotation><xs:documentation>A file "overlay" to be applied to source files that match the regular expression specified in the <b>file</b> element. The contents of the overlay file will be placed either before or after the source file (indicated by the <b>position</b> attribute). The overlay file path (the <b>overlay</b> element) MUST be a relative path, relative to tagneticconfig file defining this element.</xs:documentation></xs:annotation>
		<xs:sequence>
			<xs:element name="file" type="xs:string"/>
			<xs:element name="overlay" type="xs:string"/>
		</xs:sequence>
		<xs:attribute name="position" type="PositionType"/>
	</xs:complexType>
	<xs:simpleType name="PositionType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="before"/>
			<xs:enumeration value="after"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:complexType name="elementSyntaxType">
		<xs:annotation><xs:documentation>Specifies a Java class that will provide a syntax for identifying element syntax. This allows for creating tags or elements that don't look like the normal XML syntax. Tagneto comes configured to support the normal XML syntax and a syntax that looks like XML entities. These syntaxes should be enough for most developers, but if not, a Java class that implements the <b>TagMatcher</b> interface can be identified by using this element in a tagneticconfig.</xs:documentation></xs:annotation>
		<xs:sequence>
			<xs:element name="param" type="paramType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="classname" type="xs:string">
			<xs:annotation><xs:documentation>The Java class, with full package designation, that implements the <b>TagMatcher</b> interface. If the element syntax pattern is simple enough (clear start and end tokens, very simple attribute and name/value separators, no support for element bodies), then the org.tagnetic.core.parser.tagmatcher.SimpleTagMatcher that is part of Tagneto may be enough. That class is actually used to specify the XML entity-like syntax that is supported in Tagneto. See Tagneto's <b>TagMatchers.xml</b> configuration file for an example usage.</xs:documentation></xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<xs:complexType name="FileFilterType">
		<xs:annotation><xs:documentation>Specifies a file name filter on what types of files in the source directory will be compiled/transformed by Tagneto. The <b>type</b> attribute only supports one type of file filters, regular expressions. To only parse files that end in ".html", then the file filter would be <b>\.html$</b>, NOT *.html. To process all HTML, JS and CSS files, then the following filter: <b>\.htm$|\.html$|\.js$|\.css$</b> could be used.</xs:documentation></xs:annotation>
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="type" type="typeType" use="required"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
	<xs:complexType name="paramType">
		<xs:annotation><xs:documentation>Allows specifying a name/value pair for elements that allow for open-ended configuraiton.</xs:documentation></xs:annotation>
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="name" type="xs:string" use="required"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
	<xs:simpleType name="typeType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="regexp"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="boolType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="true"/>
			<xs:enumeration value="false"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:complexType name="tagsType">
		<xs:annotation><xs:documentation>Defines a list of tags that are part of a namespace.</xs:documentation></xs:annotation>
		<xs:sequence>
			<xs:element name="tag" type="tagType" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="nsprefix" type="xs:string">
			<xs:annotation><xs:documentation>Defines the namespace prefix that will be part of the tag names. For instance, Tagneto defines some view: namespace tags (like <b>view:include</b>). In Tagneto's <b>ViewTags.xml</b>, the <b>tags</b> config element has <b>nsprefix="view"</b>.</xs:documentation></xs:annotation>
		</xs:attribute>
		<xs:attribute name="scriptcontextname" type="xs:string" default="js">
			<xs:annotation><xs:documentation>A logical name for the script context. Ignore this attribute if using JavaScript as the script language for the tags.</xs:documentation></xs:annotation>
		</xs:attribute>
		<xs:attribute name="scriptcontext" type="xs:string" default="org.tagnetic.core.scriptcontext.implementer.javascript.JavaScriptContext">
			<xs:annotation><xs:documentation>The Java class, with full package designation, that implements the org.tagnetic.core.scriptcontext.ScriptContext interface. Used for providing a script execution context for the tags. Ignore this attribute if using JavaScript as the script language for the tags.</xs:documentation></xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<xs:complexType name="tagType">
		<xs:annotation><xs:documentation>Identifies a tag that will be handled by a Java tag handler.</xs:documentation></xs:annotation>
		<xs:sequence>
			<xs:element name="attribute" type="attributeType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="required">
			<xs:annotation><xs:documentation>The tag (element) name.</xs:documentation></xs:annotation>
		</xs:attribute>
		<xs:attribute name="classname" type="xs:string" use="required">
			<xs:annotation><xs:documentation>A Java class, with full package designation, that derives from  org.tagnetic.core.framework.Tag. Implements that tag handling behavior.</xs:documentation></xs:annotation>
		</xs:attribute>
		<xs:attribute name="priority" type="xs:integer" default="-1">
			<xs:annotation><xs:documentation>The priority of this tag handler. Multiple tag handlers can be specified for each tag name. The normal priority is the first one defined is the first one that gets executed. Use this attribute to change that default ordering. A value of 0 means the tag handler will be called first. If multiple tag handlers are defined with priority 0, then the last one that declares priority 0 will be the first one to be called.</xs:documentation></xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<xs:complexType name="attributeType">
	    <xs:annotation><xs:documentation>Identifies an attribute that is part of the tag.</xs:documentation></xs:annotation>
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="name" type="xs:string" use="required">
				  <xs:annotation><xs:documentation>The name of the attribute.</xs:documentation></xs:annotation>
				</xs:attribute>
				<xs:attribute name="property" type="xs:string">
					<xs:annotation><xs:documentation>The property on the tag handler's Java class that will be called to set the value that corresponds with this attribute. Uses the Java Beans naming convention. For instance, if the property name is "foo" then the "setFoo()" method will be called on the tag handler. Similarly, if the property is called "alongerfoo", then "setAlongerfoo()" will be called. If the property attribute is not specified, then the <b>name</b> attribute will be used to find the setter on the tag handler Java class.</xs:documentation></xs:annotation>
				</xs:attribute>
				<xs:attribute name="type" type="attributeTypeType">
					<xs:annotation><xs:documentation>If this type is specified, currently only one value can be used: "path". If type="path" is used, then the attribute value is assumed to be a path relative to the tagneticconfig file defining the attribute.</xs:documentation></xs:annotation>
				</xs:attribute>
				<xs:attribute name="required" type="xs:boolean">
					<xs:annotation><xs:documentation>Indicates if this attribute is required on the tag when it is used in the source files. If required="true" is used and a source file does not define this attribute when it uses the associated tag, then an exception will be thrown when Tagneto runs.</xs:documentation></xs:annotation>
				</xs:attribute>
				<xs:attribute name="trimdefault" type="xs:boolean" default="true">
					<xs:annotation><xs:documentation>Indicates whether the attribute value should have leading and trailing whitespaced trimmed off. The default for all attributes is true, but if that is not desired for a particular tag, then specify trimdefault="false".</xs:documentation></xs:annotation>
				</xs:attribute>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
	<xs:simpleType name="attributeTypeType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="path"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:complexType name="BranchType">
		<xs:annotation><xs:documentation>Defines a variable that has certain values. Tagneto will parse the source files once for each value that is specified for the branch variable, and create a destination directory for each value. This allows for a compile/transform-time branch. Useful if the source is basically the same except for some minor differences, like if the source supports generating a web site for two brands, but the only difference between the web site is the branding. Example: a branch variable <b>var="siteBrand"</b> is defined with values of "BrandA" and BrandB". The destination directory is called <b>outdir</b>. Tagneto will parse the source files twice, one time with siteBrand='BrandA' and another time with siteBrand='BrandB'. Tag handlers for the source can use these script variables to do different things. When Tagneto is done processing, then there will be two directories under the destination directory: <b>outdir/BrandA</b> and <b>outdir/BrandB</b>. If locales are defined as part of the <b>compilation</b> tagneticconfig element, then the locale directories will be under the branch directories. Also note that branches can be nested.</xs:documentation></xs:annotation>
		<xs:sequence>
			<xs:element name="value" type="xs:string" maxOccurs="unbounded"/>
			<xs:element name="branch" type="BranchType" minOccurs="0"/>
		</xs:sequence>
		<xs:attribute name="var" type="xs:string" use="required">
			<xs:annotation><xs:documentation>The name of the script variable that will hold the branch value.</xs:documentation></xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<xs:complexType name="PostFiltersType">
		<xs:sequence>
			<xs:element name="postfilter" type="PostFilterType" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="PostFilterType">
		<xs:annotation><xs:documentation>A Java class that has the chance to modify the text of a transformed file before it is saved to the destination directory. This allows for source cleanup, comment removal, or final text modification with the benefit of having the fully transformed source available.</xs:documentation></xs:annotation>
		<xs:sequence>
			<xs:element name="param" type="paramType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="classname" type="xs:string">
			<xs:annotation><xs:documentation>A Java class, with full package designation, that implements the org.tagnetic.core.filecontentfilter.FileContentFilter interface. A generic regular expression post filter is supported via org.tagnetic.core.filecontentfilter.RegExpFileContentFilter. In Tagneto's source code, look at<b>src/js/JsLibrarryTagneticConfig.xml</b> for example usage.</xs:documentation></xs:annotation>
		</xs:attribute>
	</xs:complexType>
</xs:schema>
