美文网首页dubbo学习之路
自定义spring标签(二)

自定义spring标签(二)

作者: 知_秋_ | 来源:发表于2017-03-25 17:35 被阅读0次
    关键词:schema xsd标签

    摘:当导入的模式具有 targetNamespace 时,将使用 <import />,而当包含的模式未声明 targetNamespace 时,将使用 <include />。

    复杂类型
    <xsd:complexType name="identifiedType" abstract="true">
    <xsd:attribute name="id" type="xsd:string">
    </xsd:attribute>
    </xsd:complexType>

    注释(可对其他标签进行注释)
    <xsd:annotation>
    <xsd:documentation>
    <![CDATA[annotation content]]>
    </xsd:documentation>
    </xsd:annotation>
    element(该namespace下的标签)
    <xsd:element name="import" type="identifiedType">
    </xsd:element>
    属性扩展和限制
    <xsd:restriction base="xsd:anyType">
    <xsd:attribute name="name" type="xsd:string">
    <xsd:annotation>
    <xsd:documentation>
    <![CDATA[“重写”属性]]>
    </xsd:documentation>
    </xsd:annotation>
    </xsd:attribute>
    </xsd:restriction>
    extension是来扩展属性

    • 使用标签:
      <mytag:user id="myuser" name="hello world"/>

      xmlns:mytag="http://demo/schema/user"
      
      xsi:schemaLocation="http://demo/schema/user
          http://demo/schema/user/user.xsd">
      
    • 思考:
      自定义标签学习是对spring集成xml文件时遵循的命名规则的探索。。。
      spring自定义标签可以清晰方便的获取bean。。。

    相关文章

      网友评论

        本文标题:自定义spring标签(二)

        本文链接:https://www.haomeiwen.com/subject/hvmcottx.html