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)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 中西区| 阳新县| 上饶县| 石首市| 屯昌县| 若羌县| 香格里拉县| 合肥市| 夏津县| 三台县| 葫芦岛市| 恭城| 桃园市| 呼图壁县| 乌兰浩特市| 曲靖市| 天等县| 明溪县| 嘉善县| 黑山县| 子洲县| 南平市| 东阳市| 通道| 正阳县| 阿瓦提县| 行唐县| 三都| 呼玛县| 班戈县| 澜沧| 瑞昌市| 南川市| 普洱| 邹平县| 宁南县| 班玛县| 富蕴县| 武定县| 陇南市| 新河县|