pzxsheng

          有種相見不敢見的傷痛,有種愛還埋藏在心中

          elementFormDefault

          elementFormDefault取值:qualified 或者 unqualified

           

          http://www.velocityreviews.com/forums/t292290-xsd-what-is-elementformdefault-qualified-for.html這個網站,發現Boris的回答:

          All"qualified" elements and attributes are in the targetNamespace of the
          schema and all "unqualified" elementsand attributes are in no namespace.
          All global elements and attributes are qualified.

           

          意思是這樣的:

          1、在xml中,所有引用xsd的全局的元素都必須加上命名空間的前綴

          (例如xmlns:aa=http://www.example.org/classroom,全局元素都得加上aa)。

          2、非全局的元素當設置為qualified時,必須添加命名空間的前綴。

          3、非全局的元素當設置為unqualified時,不必也不能添加前綴。

           

          下面是一個簡單的例子:

          a.  當設置為unqualified時,user為全局元素(可作為根元素)必須添加前綴,非全局元素

          (id,name)不必添加前綴。



          b.  當設置為qualified時,所有的元素都必須添加前綴。



          其實elementFormDefault的qualified/unqualified還與schema的設計模式有關系,目前常用的有Russian Roll , Salami Slice , Venetian Blind

          詳細及最佳實踐可以參照:http://www.xfront.com/GlobalVersusLocal.html#BestPractice

           

          Salami Slice這種schema的設計模式,將所有的元素設置為全局元素,設置不設置elementFormDefault是沒有任何意義的,文章的開通說過,所有的全局元素必須添加前綴。

          http://www.xfront.com/GlobalVersusLocal.html#BestPractice

          上網站中提到的Venetian Blind的優勢之一:

          UseelementFormDefault to act as a switch for controlling namespaceexposure - if you want element namespaces exposed in instance documents, simplyturn the elementFormDefault switch to "on" (i.e, setelementFormDefault= "qualified"); if you don't want elementnamespaces exposed in instance documents, simply turn the elementFormDefaultswitch to "off" (i.e., setelementFormDefault="unqualified").

          posted on 2014-10-15 15:37 科菱財神 閱讀(242) 評論(0)  編輯  收藏 所屬分類: Webservice

          導航

          <2014年10月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          統計

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 金寨县| 华池县| 石柱| 花垣县| 武平县| 台北县| 常州市| 延津县| 南雄市| 桐梓县| 遵义县| 来宾市| 墨竹工卡县| 综艺| 泾阳县| 兰州市| 漯河市| 阿尔山市| 宝山区| 平定县| 安宁市| 安丘市| 安达市| 镇远县| 崇义县| 晋州市| 德格县| 成安县| 宁远县| 库车县| 宁城县| 中牟县| 双柏县| 克拉玛依市| 出国| 和静县| 顺义区| 天津市| 黄骅市| 乌审旗| 唐海县|