嘟嘟

            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>
             ...

          主站蜘蛛池模板: 祁门县| 孝昌县| 永定县| 绥滨县| 阆中市| 吉木乃县| 满城县| 长阳| 西贡区| 惠东县| 大庆市| 九龙坡区| 乐业县| 库伦旗| 周宁县| 仁怀市| 和平区| 栖霞市| 雅安市| 两当县| 利辛县| 防城港市| 乐至县| 来凤县| 织金县| 奉节县| 桃源县| 天长市| 莎车县| 华坪县| 荥阳市| 乐亭县| 洛扎县| 淅川县| 木兰县| 郸城县| 抚顺市| 招远市| 兰州市| 西乌珠穆沁旗| 宁化县|