嘟嘟

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            26 Posts :: 0 Stories :: 6 Comments :: 0 Trackbacks

          Namespaces are a way to associate a group of elements with each other.
           
           <wire:order xmlns:wire="   <wire:store>
               <wire:shirt xmlns:wire="http:/www.wire-man.com/ns/shirts">                 <!-->覆蓋realname,不能覆蓋localname<-->
                 <wire:color>purple</wire:color>
               </wire:shirt>
             </wire:store>
           </wire:order>

          多個namespaces
           <wire:order xmlns:wire="
             <wire:store>
               <wire:shirt xmlns:stitch="http:/www.wire-man.com/ns/stitch">               <!-->2個<-->
                  <wire:color>
                     <stitch:shade>lavender</stitch:shade>
                  </wire:color>
               </wire:shirt>
             </wire:store>
           </wire:order>

          Namespaces and attributes
           元素前面加prefix,參數前面不用加

          Namespaces and DTDs
           DTD不支持Namespaces,只是當作一個attribute.
           <?xml version="1.0" encoding="UTF-8"?>
           <!DOCTYPE  wire:order [
           <!ELEMENT wire:order (wire:store)>                                            <!-->元素前加上prefix<-->
           <!ATTLIST wire:order xmlns CDATA #FIXED "
           <!ELEMENT wire:store (#PCDATA)>
           ]>

           <wire:order xmlns=" <wire:store>Stitch Store</wire:store>
           </wire:order>

          Namespaces are not technically part of the XML 1.0 spec, thus,namespaces have nothing to do with the validity of an XML document.

          Namespace and XML Schema
            <!-->XML  FILE<-->
            <?xml version="1.0" encoding="UTF-8" ?>
            <pants:order
               xmlns:xsi="
               xsi:noNamespaceSchemaLocation="namespace2.xsd"
               xmlns:pants="
                  <store>30 paisley capri</store>                                        <!-->這個元素不在namespaces中<-->
            </pants:order>

            <!-->XML Schema FILE namespace2.xsd<-->
            <?xml version="1.0" encoding="UTF-8" ?>
            <xsd:schema                                                                  <!-->定義一個namespace所有內容都飽含再一個xsd:schema元素內<-->
           xmlns:xsd="
           targetNamespace=" xmlns:wire="  
           <xsd:element name="order">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="store" type="xsd:string" />
               </xsd:sequence>
              </xsd:complexType>
             </xsd:element>
            </xsd:schema>
           
            ××上面例子中注意xmlns:pants,targetNamespace, xmlns:wire是使用一樣得URI值。

            Assign the namespaces to all elements is elementFormDefault="qualified"
              ...
              <xsd:schema                                                                 
           xmlns:xsd="
           targetNamespace=" xmlns:wire="        elementFormDefault="qualified"> 
              ...
           
            Assign the namespaces to the individule element
              ...
              <xsd:element name="order">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="store" type="xsd:string" form="qualified"/>  <!-->***<-->
               </xsd:sequence>
              </xsd:complexType>
             </xsd:element>
             ...

            Exclude an element from the namespace
              ...
              <xsd:element name="order">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="store" type="xsd:string" form="unqualified"/>  <!-->***<-->
               </xsd:sequence>
              </xsd:complexType>
             </xsd:element>
             ...

          主站蜘蛛池模板: 曲麻莱县| 淮南市| 马山县| 板桥市| 辽阳市| 介休市| 江山市| 平泉县| 绥宁县| 丰原市| 禹城市| 仁化县| 崇左市| 前郭尔| 噶尔县| 白银市| 晋州市| 兰西县| 聂拉木县| 五指山市| 安福县| 法库县| 林芝县| 龙川县| 保定市| 思南县| 宁波市| 车险| 竹山县| 宕昌县| 宜城市| 邢台县| 盐亭县| 桓仁| 诏安县| 平果县| 揭东县| 沧源| 湾仔区| 文化| 杭锦旗|