Spring Custom label Specification definition XSD

Source: Internet
Author: User
Tags documentation

Introduction:

In spring's configuration file, all of the tags are spring-defined. <bean/>, and so on, with the definition of the specification, in order to allow users to fill out the normal available. You want to write a custom label, but first you need to understand the XML Schema Definition (XSD).

Label Definition:

For the definition of this class label, Spring has the corresponding XSD definition document

Http://www.springframework.org/schema/beans

For XSD, simply the definition of a label for XML, there is no explanation for the XSD too much, see

Http://www.w3school.com.cn/schema/schema_example.asp

Here is a simple description of some of the definitions that are often encountered in the application.

Application Scenario:

The database connection is further encapsulated to simplify the configuration.

      from the original configuration: XML code   <bean id= "DataSource"         class= "Org.springframework.jdbc.datasource.DriverManagerDataSource" >        <property name= "Driverclassname"  value= "Com.mysql.jdbc.Driver" ></property>        <property name= "url"             value= "jdbc:mysql://localhsost/freebug?useunicode=true&amp;characterencoding=utf8&amp; Autoreconnect=true "></property>       <property name=" username " >           <value>root</value>       </property>       <property name= "Password" >           <value>root</value>       </property>   </bean>      <!--  session  -->    <bean id= "sqlmapclient"  class= "Org.springframework.orm.ibatis.SqlMapClientFactoryBean" >        <property name= "configlocation"  value= "classpath: Sqlmapcommonconfig.xml " />       <property name=" DataSource "  ref= "DataSource"  />   </bean>   

Instead: XML code <mysql:client id= "Sqlmapclient" datasouceip= "Localhsost" characterencoding= "" UTF8 "fr Eebug "username=" root "password=" root "configlocation=" Classpath:SqlMapCommonConfig.xml "/>

From here, the configuration is handled in a simplified form. Many other information properties can also be restricted by default and regular.

How to make the above configuration can be set up, which requires the definition of the XSD specification for this tag.

Label Definition

The    definition is as follows: XML code    <?xml version= "1.0"  encoding= "UTF-8"?>   <xsd: schema xmlns= "Http://sammor.javaeye.com/schema/tags"        xmlns:xsd= "http:/ /www.w3.org/2001/xmlschema " xmlns:beans=" Http://www.springframework.org/schema/beans "        targetnamespace= "Http://sammor.javaeye.com/schema/tags"         elementformdefault= "qualified"  attributeformdefault= "unqualified" >        <xsd:import namespace= "Http://www.springframework.org/schema/beans"  />        <xsd:element name= "Client" >            <xsd:annotation>               < xsd:documentation>connect to mysql</xsd:documentation>       & nbsp;   </xsd:annotation>           <

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.