Update of /cvsroot/springnet/Spring.Net/doc/reference/src
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv8292
Modified Files:
index.xml xml-custom.xml xsd-configuration.xml
Log Message:
SPRNET-938 - Add documentation for authoring custom namespace parsers
Index: index.xml
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/doc/reference/src/index.xml,v
retrieving revision 1.86
retrieving revision 1.87
diff -C2 -d -r1.86 -r1.87
*** index.xml 2 May 2008 20:40:58 -0000 1.86
--- index.xml 5 May 2008 20:04:55 -0000 1.87
***************
*** 363,366 ****
--- 363,368 ----
<!-- back matter -->
+ &xsd-configuration;
+ &xml-custom;
&xsd;
Index: xsd-configuration.xml
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/doc/reference/src/xsd-configuration.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** xsd-configuration.xml 1 Jun 2007 09:02:07 -0000 1.1
--- xsd-configuration.xml 5 May 2008 20:04:55 -0000 1.2
***************
*** 1,25 ****
! <!--
! /*
! * Copyright 2002-2007 the original author or authors.
! *
! * 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.
! */
! -->
<appendix id="xsd-config">
<title>XML Schema-based configuration</title>
! <section id="xsd-config-introduction">
<title>Introduction</title>
! <para>This appendix details the XML Schema-based configuration introduced in Spring 2.0.</para>
</section>
- </appendix>
--- 1,225 ----
! <?xml version="1.0" encoding="UTF-8"?>
<appendix id="xsd-config">
<title>XML Schema-based configuration</title>
!
! <section id="xsd-config-introduction">
<title>Introduction</title>
!
! <para>This appendix details the use of XML Schema-based configuration in
! Spring.</para>
!
! <para> The <emphasis>'classic' </emphasis>
! <literal><object/></literal>-based schema is good, but its
! generic-nature comes with a price in terms of configuration overhead.
! Creating a custom XML Schema-based configuration makes Spring XML
! configuration files substantially clearer to read. In addition, it allows
! you to express the intent of an object definition.</para>
!
! <para>The key thing to remember is that creating custom schema tags work
! best for infrastructure or integration objects: for example, AOP,
! collections, transactions, integration with 3rd-party frameworks, etc.,
! while the existing object tags are best suited to application-specific
! objects, such as DAOs, service layer objects, etc.</para>
!
! <para>Please note the fact that the XML configuration mechanism is totally
! customisable and extensible. This means you can write your own
! domain-specific configuration tags that would better represent your
! application's domain; the process involved in doing so is covered in the
! appendix entitled <xref linkend="extensible-xml" />.</para>
! </section>
!
! <section id="xsd-config-body">
! <title>XML Schema-based configuration</title>
!
! <section id="xsd-config-body-referencing">
! <title>Referencing the schemas</title>
!
! <para>As a reminder, you reference the standard objects schema as shown
! below</para>
!
! <programlisting>
! <?xml version="1.0" encoding="UTF-8"?>
! <objects xmlns="http://www.springframework.net"
! xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
! xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/schema/objects/spring-objects-1.1.xsd">
!
! <lineannotation> <!-- <literal><object/></literal> definitions here --></lineannotation>
!
! </objects></programlisting>
!
! <note>
! <para>The <literal>'xsi:schemaLocation'</literal> fragment is not
! actually required, but can be included to reference a local copy of a
! schema (which can be useful during development) and assumes the XML
! editor will look to that location and load the schema.</para>
! </note>
!
! <para>The above Spring XML configuration fragment is boilerplate that
! you can copy and paste (!) and then plug
! <literal><object/></literal> definitions into like you have always
! done. However, the entire point of using custom schema tags is to make
! configuration easier. </para>
</section>
+ <para>The rest of this chapter gives an overview of custom XML Schema
+ based configuration that are included with the release.</para>
+
+ <section id="xsd-config-body-schemas-tx">
+ <title>The <literal>tx</literal> (transaction) schema</title>
+
+ <para>The <literal>tx</literal> tags deal with configuring objects in
+ Spring's comprehensive support for transactions. These tags are covered
+ in the chapter entitled <xref linkend="transaction" />.</para>
+
+ <tip>
+ <para>You are strongly encouraged to look at the
+ <filename>'spring-tx-1.1.xsd'</filename> file that ships with the
+ Spring distribution. This file is (of course), the XML Schema for
+ Spring's transaction configuration, and covers all of the various tags
+ in the <literal>tx</literal> namespace, including attribute defaults
+ and suchlike. This file is documented inline, and thus the information
+ is not repeated here in the interests of adhering to the DRY (Don't
+ Repeat Yourself) principle.</para>
+ </tip>
+
+ <para>In the interest of completeness, to use the tags in the
+ <literal>tx</literal> schema, you need to have the following preamble at
+ the top of your Spring XML configuration file; the emboldened text in
+ the following snippet references the correct schema so that the tags in
+ the <literal>tx</literal> namespace are available to you.</para>
+
+ <programlisting><?xml version="1.0" encoding="UTF-8"?>
+ <object xmlns="http://www.springframework.net"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ <emphasis role="bold"> xmlns:tx="http://www.springframework.org/schema/tx"</emphasis>>
+
+ <lineannotation><!-- <literal><object/></literal> definitions here --></lineannotation>
+
+ </object></programlisting>
+
+ <note>
+ <para>Often when using the tags in the <literal>tx</literal> namespace
+ you will also be using the tags from the <literal>aop</literal>
+ namespace (since the declarative transaction support in Spring is
+ implemented using AOP). The above XML snippet contains the relevant
+ lines needed to reference the <literal>aop</literal> schema so that
+ the tags in the <literal>aop</literal> namespace are available to
+ you.</para>
+ </note>
+ </section>
+
+ <section id="xsd-config-body-schemas-aop">
+ <title>The <literal>aop</literal> schema</title>
+
+ <para>The <literal>aop</literal> tags deal with configuring all things
+ AOP in Spring. These tags are comprehensively covered in the chapter
+ entitled <xref linkend="aop" />.</para>
+
+ <para>In the interest of completeness, to use the tags in the
+ <literal>aop</literal> schema, you need to have the following preamble
+ at the top of your Spring XML configuration file; the emboldened text in
+ the following snippet references the correct schema so that the tags in
+ the <literal>aop</literal> namespace are available to you.</para>
+
+ <programlisting><?xml version="1.0" encoding="UTF-8"?>
+ <objects xmlns="http://www.springframework.net"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ <emphasis role="bold">xmlns:aop="http://www.springframework.org/schema/aop"</emphasis>>
+
+ <lineannotation><!-- <literal><object/></literal> definitions here --></lineannotation>
+
+ </objects></programlisting>
+ </section>
+
+ <section id="xsd-config-body-schemas-context">
+ <title>The <literal>db</literal> schema</title>
+
+ <para>The <literal>db</literal> tags deal with creating
+ <classname>IDbProvider</classname> instances for a given database client
+ library. The following snippet references the correct schema so that the
+ tags in the <literal>db</literal> namespace are available to you. The
+ tags are comprehensively covered in the chapter entitled <xref
+ linkend="dbprovider" />.</para>
+
+ <programlisting><?xml version="1.0" encoding="UTF-8"?>
+ <objects xmlns="http://www.springframework.net"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ <emphasis role="bold">xmlns:db="http://www.springframework.org/schema/db"</emphasis>>
+
+ <lineannotation><!-- <literal><object/></literal> definitions here --></lineannotation>
+
+ </objects></programlisting>
+ </section>
+
+ <section id="xsd-config-body-schemas-tool">
+ <title>The <literal>remoting</literal> schema</title>
+
+ <para>The <literal>remoting</literal> tags are for use when you want to
+ export an existing POCO object as a .NET remoted object or to create a
+ client side .NET remoting proxy. The tags are comprehensively covered in
+ the chapter <xref linkend="remoting" /></para>
+
+ <programlisting><?xml version="1.0" encoding="UTF-8"?>
+ <objects xmlns="http://www.springframework.org/schema/objects"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ <emphasis role="bold">xmlns:r="http://www.springframework.org/schema/remoting"</emphasis>>
+
+ <lineannotation><!-- <literal><object/></literal> definitions here --></lineannotation>
+
+ </objects></programlisting>
+ </section>
+
+ <section id="xsd-config-body-schemas-tool">
+ <title>The <literal>validation</literal> schema</title>
+
+ <para>The <literal>validation</literal> tags are for use when you want
+ definte <literal>IValidator</literal> object instances. The tags are
+ comprehensively covered in the chapter <xref
+ linkend="validation" /></para>
+
+ <programlisting><?xml version="1.0" encoding="UTF-8"?>
+ <objects xmlns="http://www.springframework.net"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ <emphasis role="bold">xmlns:v="http://www.springframework.org/schema/validation"</emphasis>>
+
+ <lineannotation><!-- <literal><object/></literal> definitions here --></lineannotation>
+
+ </objects></programlisting>
+ </section>
+
+ <section id="xsd-config-body-schemas-beans">
+ <title>The <literal>objects</literal> schema</title>
+
+ <para>Last but not least we have the tags in the
+ <literal>objects</literal> schema. Examples of the various tags in the
+ <literal>objects</literal> schema are not shown here because they are
+ quite comprehensively covered in the section entitled <xref
+ linkend="object-factory-properties-detailed" /> (and indeed in that
+ entire <link linkend="objects">chapter</link>).</para>
+
+ <programlisting><?xml version="1.0" encoding="UTF-8"?>
+ <objects xmlns="http://www.springframework.net"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.net http://www.springframework.net/schema/objects/spring-objects-1.1.xsd">
+
+ <object id="foo" class="X.Y.Foo, X">
+ <property name="name" value="Rick"/>
+ </object>
+
+ </objects></programlisting>
+ </section>
+ </section>
+
+ <section id="xsd-config-setup">
+ <title>Setting up your IDE</title>
+
+ <para>To setup VS.NET to provide intellisence while editing XML file for
+ your custom XML schemas you will need to copy your XSD files to an
+ appropriate VS.NET directory. Refer to the following chapter for details,
+ <xref linkend="vsnet" /></para>
+
+ <para>For SharpDevelop, follow the directions on the "<ulink
+ url="http://community.sharpdevelop.net/blogs/mattward/articles/FeatureTourEditingXml.aspx">Editing
+ XML</ulink>" product documentation.</para>
+ </section>
+ </appendix>
\ No newline at end of file
Index: xml-custom.xml
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/doc/reference/src/xml-custom.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** xml-custom.xml 1 Jun 2007 09:02:07 -0000 1.1
--- xml-custom.xml 5 May 2008 20:04:55 -0000 1.2
***************
*** 1,9 ****
! <?xml version="1.0" encoding="UTF-8" ?>
<appendix id="extensible-xml">
! <title>Extensible XML authoring</title>
! <section id="extensible-xml-introduction">
! <title>Introduction</title>
! <para>Spring has featured a mechanism for schema-based extensions
! </para>
</section>
</appendix>
\ No newline at end of file
--- 1,388 ----
! <?xml version="1.0" encoding="UTF-8"?>
<appendix id="extensible-xml">
! <title>Extensible XML authoring</title>
!
! <section id="extensible-xml-introduction">
! <title>Introduction</title>
!
! <para>Spring supports adding custom schema-based extensions to the basic
! Spring XML format for defining and configuring objects. This section is
! devoted to detailing how you would go about writing your own custom XML
! object definition parsers and integrating such parsers into the Spring IoC
! container.</para>
!
! <para>To facilitate the authoring of configuration files using a
! schema-aware XML editor, Spring's extensible XML configuration mechanism
! is based on XML Schema. If you are not familiar with Spring's current XML
! configuration extensions that come with the standard Spring distribution,
! please first read the appendix entitled <xref
! linkend="xsd-config" />.</para>
!
! <para>Creating new XML configuration extensions can be done by following
! these (relatively) simple steps:</para>
!
! <para><orderedlist numeration="arabic">
! <listitem>
! <para><link linkend="extensible-xml-schema">Authoring</link> an XML
! schema to describe your custom element(s).</para>
! </listitem>
!
! <listitem>
! <para><link linkend="extensible-xml-namespacehandler">Coding</link>
! a custom <interfacename>INamespaceParser</interfacename>
! implementation (this is an easy step, don't worry).</para>
! </listitem>
!
! <listitem>
! <para><link linkend="extensible-xml-parser">Coding</link> one or
! more <interfacename>IObjectDefinitionParser</interfacename>
! implementations (this is where the real work is done).</para>
! </listitem>
!
! <listitem>
! <para><link linkend="extensible-xml-registration">Registering</link>
! the above artifacts with Spring (this too is an easy step).</para>
! </listitem>
! </orderedlist></para>
!
! <para>What follows is a description of each of these steps. For the
! example, we will create an XML extension (a custom XML element) that
! allows us to configure objects of the type <classname>Regex</classname>
! (from the <literal>System.Text.RegularExpressions</literal> namespace) in
! an easy manner. When we are done, we will be able to define object
! definitions of type <classname>Regex</classname> like this:</para>
!
! <programlisting><myns:regex id="regex"
! pattern="(^\d{5}$)|(^\d{5}-\d{4}$)"
! options="Compiled"/>
! </programlisting>
! </section>
!
! <section id="extensible-xml-schema">
! <title>Authoring the schema</title>
!
! <para>Creating an XML configuration extension for use with Spring's IoC
! container starts with authoring an XML Schema to describe the extension.
! What follows is the schema we'll use to configure
! <classname>Regex</classname> objects.</para>
!
! <programlisting><?xml version="1.0" encoding="utf-8" ?>
! <xsd:schema id="myns"
! xmlns="http://www.mycompany.com/schema/myns"
! xmlns:xsd="http://www.w3.org/2001/XMLSchema"
! xmlns:objects="http://www.springframework.net"
! xmlns:vs="http://schemas.microsoft.com/Visual-Studio-Intellisense"
! targetNamespace="http://www.mycompany.com/schema/myns"
! elementFormDefault="qualified"
! attributeFormDefault="unqualified"
! vs:friendlyname="Spring Regex Configuration" vs:ishtmlschema="false"
! vs:iscasesensitive="true" vs:requireattributequotes="true"
! vs:defaultnamespacequalifier="" vs:defaultnsprefix=""
! >
!
! <xsd:import namespace="http://www.springframework.net"/>
!
! <xsd:element name="regex">
! <xsd:complexType>
! <xsd:complexContent>
! <emphasis role="bold"><xsd:extension base="objects:identifiedType"></emphasis>
! <xsd:attribute name="pattern" type="xsd:string" use="required"/>
! <xsd:attribute name="options" type="xsd:string" use="optional"/>
! </xsd:extension>
! </xsd:complexContent>
! </xsd:complexType>
! </xsd:element>
!
! </xsd:schema> </programlisting>
!
! <para>The emphasized line contains an extension base for all tags that
! will be identifiable (meaning they have an <literal>id</literal> attribute
! that will be used as the object identifier in the container). We are able
! to use this attribute because we imported the Spring-provided
! <literal>'objects'</literal> namespace. The <literal>vs:</literal>
! prefixed elements are for better integration with intellisense in
! VS.NET.</para>
!
! <para>The above schema will be used to configure
! <classname>Regex</classname> objects, directly in an XML application
! context file using the <literal><myns:regex/></literal>
! element.</para>
!
! <programlisting><myns:regex id="usZipCodeRegex"
! pattern="(^\d{5}$)|(^\d{5}-\d{4}$)"
! options="Compiled"/></programlisting>
!
! <para>Note that after we've created the infrastructure classes, the above
! snippet of XML will essentially be exactly the same as the following XML
! snippet. In other words, we're just creating an object in the container,
! identified by the name <literal>'usZipCodeRegex'</literal> of type
! <classname>Regex</classname>, with a couple of constructor arguments
! set.</para>
!
! <programlisting> <object id="usZipCodeRegex" type="System.Text.RegularExpressions.Regex, System">
! <constructor-arg name="pattern" value="(^\d{5}$)|(^\d{5}-\d{4}$)"/>
! <constructor-arg name="options" value="Compiled"/>
! </object></programlisting>
!
! <note>
! <para>The schema-based approach to creating configuration format allows
! for tight integration with an IDE that has a schema-aware XML editor.
! Using a properly authored schema, you can use intellisense to have a
! user choose between several configuration options defined in the
! enumeration. The schema for creating IDbProvider instances shows the use
! of XSD enumerations.</para>
! </note>
! </section>
!
! <section id="extensible-xml-namespacehandler">
! <title>Coding a <interfacename>INamespaceHandler</interfacename></title>
!
! <para>In addition to the schema, we need an
! <interfacename>INamespaceParser</interfacename> that will parse all
! elements of this specific namespace Spring encounters while parsing
! configuration files. The <interfacename>INamespaceHandler</interfacename>
! should in our case take care of the parsing of the
! <literal>myns:regex</literal> element.</para>
!
! <para>The <interfacename>INamespaceHandler</interfacename> interface is
! pretty simple in that it features just two methods:</para>
!
! <itemizedlist spacing="compact">
! <listitem>
! <para><methodname>Init()</methodname> - allows for initialization of
! the <interfacename>INamespaceHandler</interfacename> and will be
! called by Spring before the handler is used</para>
! </listitem>
!
! <listitem>
! <para><methodname>IObjectDefinition Parse(Element,
! ParserContext)</methodname> - called when Spring encounters a
! top-level element (not nested inside a object definition or a
! different namespace). This method can register object definitions
! itself and/or return a object definition.</para>
! </listitem>
! </itemizedlist>
!
! <para>Although it is perfectly possible to code your own
! <interfacename>INamespaceHandler</interfacename> for the entire namespace
! (and hence provide code that parses each and every element in the
! namespace), it is often the case that each top-level XML element in a
! Spring XML configuration file results in a single object definition (as in
! our case, where a single <literal><myns:regex/></literal> element
! results in a single <classname>Regex</classname> object definition).
! Spring features a number of convenience classes that support this
! scenario. In this example, we'll make use the
! <classname>NamespaceParserSupport</classname> class:</para>
!
! <programlisting>using Spring.Objects.Factory.Xml;
!
! namespace CustomNamespace
! {
! [NamespaceParser(
! Namespace = "http://www.mycompany.com/schema/myns",
! SchemaLocationAssemblyHint = typeof(MyNamespaceParser),
! SchemaLocation = "/CustomNamespace/myns.xsd"
! )
! ]
! public class MyNamespaceParser : NamespaceParserSupport
! {
! public override void Init()
! {
! <emphasis role="bold">RegisterObjectDefinitionParser</emphasis>("regex", new RegexObjectDefinitionParser());
! }
! }
! }</programlisting>
!
! <para>Notice that there isn't actually a whole lot of parsing logic in
! this class. Indeed... the <classname>NamespaceParserSupport</classname>
! class has a built in notion of delegation. It supports the registration of
! any number of <interfacename>IObjectDefinitionParser</interfacename>
! instances, to which it will delegate to when it needs to parse an element
! in it's namespace. This clean separation of concerns allows an
! <interfacename>INamespaceParser</interfacename> to handle the
! orchestration of the parsing of <emphasis>all</emphasis> of the custom
! elements in it's namespace, while delegating to
! <literal>IObjectDefinitionParsers</literal> to do the grunt work of the
! XML parsing; this means that each
! <interfacename>IObjectDefinitionParser</interfacename> will contain just
! the logic for parsing a single custom element, as we can see in the next
! step.</para>
!
! <para>To help in the registration of the parser for this namespace, the
! <literal>NamespaceParser</literal> attribute is used to map the XML
! namespace string, i.e.
! <literal>http://www.mycompany.com/schema/myns</literal>, to the location
! of the XML Schema file as an embedded assembly resource.</para>
! </section>
!
! <section id="extensible-xml-parser">
! <title>Coding an
! <interfacename>IObjectDefinitionParser</interfacename></title>
!
! <para>A <interfacename>IObjectDefinitionParser</interfacename> will be
! used if the <interfacename>INamespaceParser</interfacename> encounters an
! XML element of the type that has been mapped to the specific object
! definition parser (which is <literal>'regex'</literal> in this case). In
! other words, the <interfacename>IObjectDefinitionParser</interfacename> is
! responsible for parsing <emphasis>one</emphasis> distinct top-level XML
! element defined in the schema. In the parser, we'll have access to the XML
! element (and thus it's subelements too) so that we can parse our custom
! XML content, as can be seen in the following example:</para>
!
! <programlisting>using System;
! using System.Text.RegularExpressions;
! using System.Xml;
! using Spring.Objects.Factory.Support;
! using Spring.Objects.Factory.Xml;
! using Spring.Util;
!
! namespace CustomNamespace
! {
! public class RegexObjectDefinitionParser : AbstractSimpleObjectDefinitionParser { <co
! id="extensible-xml-parser-simpledateformat-co-1" />
!
! protected override Type GetObjectType(XmlElement element)
! {
! return typeof (Regex); <co
! id="extensible-xml-parser-simpledateformat-co-2" />
! }
!
! protected override void DoParse(XmlElement element, ObjectDefinitionBuilder builder)
! {
! <lineannotation> // this will never be null since the schema explicitly requires that a value be supplied</lineannotation>
! string pattern = element.GetAttribute("pattern");
! builder.AddConstructorArg(pattern);
!
! <lineannotation> // this however is an optional property</lineannotation>
! string options = element.GetAttribute("options");
! if (StringUtils.HasText(options))
! {
! RegexOptions regexOptions = (RegexOptions)Enum.Parse(typeof (RegexOptions), options);
! builder.AddConstructorArg(regexOptions);
! }
! }
!
! protected override bool ShouldGenerateIdAsFallback
! {
! get { return true; }
! }
! }
! </programlisting>
!
! <calloutlist>
! <callout arearefs="extensible-xml-parser-simpledateformat-co-1">
! <para>We use the Spring-provided
! <classname>AbstractSingleObjectDefinitionParser</classname> to handle
! a lot of the basic grunt work of creating a
! <emphasis>single</emphasis>
! <interfacename>IObjectDefinition</interfacename>.</para>
! </callout>
!
! <callout arearefs="extensible-xml-parser-simpledateformat-co-2">
! <para>We supply the
! <classname>AbstractSingleObjectDefinitionParser</classname> superclass
! with the type that our single
! <interfacename>IObjectDefinition</interfacename> will
! represent.</para>
! </callout>
! </calloutlist>
!
! <para>In this simple case, this is all that we need to do. The creation of
! our single <interfacename>IObjectDefinition</interfacename> is handled by
! the <classname>AbstractSingleObjectDefinitionParser</classname>
! superclass, as is the extraction and setting of the object definition's
! unique identifier. The property
! <literal>ShouldGenerateIdAsFallback</literal> will generate a throw-away
! object id incase one is not specified, this is useful when nesting object
! definitions.</para>
! </section>
!
! <section id="extensible-xml-registration">
! <title>Registering the handler and the schema</title>
!
! <para>The coding is finished! All that remains to be done is to somehow
! make the Spring XML parsing infrastructure aware of our custom element; we
! do this by registering our custom
! <interfacename>INamespaceParser</interfacename> using a special
! configuration section handler. The location of the XML Schema in this
! example has been directly assoicated with the parser though the use of the
! <literal>Namespace</literal> attribute.</para>
!
! <section id="extensible-xml-registration-spring-handlers">
! <title><filename>NamespaceParsersSectionHandler</filename></title>
!
! <para>The custom configuration section handler is of the type
! <classname>Spring.Context.Support.NamespaceParsersSectionHandler</classname>
! and is registered with .NET in the normal manner. The custom
! configuration section will simply point to the
! <classname>INamespaceParser</classname> implementation that has the
! <classname>Namespace</classname> attribute. For our example, we need to
! write the following:</para>
!
! <programlisting><configuration>
!
! <configSections>
! <sectionGroup name="spring">
! <section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
! </sectionGroup>
! </configSections>
!
! <spring>
! <parsers>
! <parser type="CustomNamespace.MyNamespaceParser, CustomNamespace" />
! </parsers>
! </spring>
!
! </configuration></programlisting>
</section>
+ </section>
+
+ <section id="extensible-xml-using">
+ <title>Using a custom extension in your Spring XML configuration</title>
+
+ <para>Using a custom extension that you yourself have implemented is no
+ different from using one of the 'custom' extensions that Spring provides
+ straight out of the box. Find below an example of using the custom
+ <literal><regex/></literal> element developed in the previous steps
+ in a Spring XML configuration file.</para>
+
+ <programlisting><?xml version="1.0" encoding="utf-8" ?>
+ <objects xmlns="http://www.springframework.net"
+ xmlns:myns="http://www.mycompany.com/schema/myns">
+
+ <!-- as a top level object definition -->
+ <myns:regex id="usZipCodeRegex"
+ pattern="(^\d{5}$)|(^\d{5}-\d{4}$)"/>
+
+ <object id="jobDetailTemplate" abstract="true">
+ <property name="regex">
+ <!-- as an inner object definition -->
+ <myns:regex pattern="(^\d{5}$)|(^\d{5}-\d{4}$)"
+ options="Compiled"/>
+ </property>
+ </object>
+
+ </objects></programlisting>
+ </section>
+
+ <section id="extensible-xml-resources">
+ <title>Further Resources</title>
+
+ <para>Find below links to further resources concerning XML Schema and the
+ extensible XML support described in this chapter.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>The <ulink
+ url="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/">XML Schema
+ Part 1: Structures Second Edition</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para>The <ulink
+ url="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/">XML Schema
+ Part 2: Datatypes Second Edition</ulink></para>
+ </listitem>
+ </itemizedlist>
+ </section>
</appendix>
\ No newline at end of file
|