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> ...
Copyright @ fyp1210 Powered by: .Text and ASP.NET Theme by: .NET Monster