Xml XSD限制partent元素的子元素数量

Xml XSD限制partent元素的子元素数量,xml,xsd,Xml,Xsd,因此,我试图为我们将在程序中使用的XML文件定义一个模式。有一个元素具有子元素,该子元素定义整个文件的源语言和任何目标语言。始终只有一种源语言,并且每个translationUnit中的源语言必须相同。可以有任意数量的targetLanguages,但每个translationUnit必须具有完全相同的targetLanguages,它们不能不同 是否有一种XSD或其他模式格式的方法可以: a) 是否要求每个translationUnits的sourceSegment的langLocale与jo

因此,我试图为我们将在程序中使用的XML文件定义一个模式。有一个元素具有子元素,该子元素定义整个文件的源语言和任何目标语言。始终只有一种源语言,并且每个translationUnit中的源语言必须相同。可以有任意数量的targetLanguages,但每个translationUnit必须具有完全相同的targetLanguages,它们不能不同

是否有一种XSD或其他模式格式的方法可以:

a) 是否要求每个translationUnits的sourceSegment的langLocale与jobLanguages元素中的sourceLang相同

b) 是否要求每个translationUnits的targetSegment元素的langLocale属性与jobLanguages元素的targetLang元素的langLocales匹配

本质上,随XML发送的每个请求必须在整个文档中保持一致,某些TranslationUnit不能有不同的源语言或一组不同的目标语言

示例XML文件:

<?xml version="1.0" encoding="utf-8"?>
<translationBody>
    <translationJob>
        <jobLanguages>
            <sourceLang>en-US</sourceLang>
            <targetLang>ja-JP</targetLang>
            <targetLang>ko-KR</targetLang>
            <targetLang>es-ES</targetLang>
            <targetLang>de-DE</targetLang>
            <targetLang>fr-FR</targetLang>
            <targetLang>ru-RU</targetLang>
            <targetLang>zh-CN</targetLang>
            <targetLang>zh-TW</targetLang>
            <targetLang>ar-AA</targetLang>
        </jobLanguages>
        <translationUnit active="true" key="introText" notes="Notes for translator" lenRestriction="25">
            <sourceSegment langLocale="en-US">Some text for translation.</sourceSegment>
            <targetSegment langLocale="ja-JP">翻訳用テキスト</targetSegment>
            <targetSegment langLocale="ko-KR">번역을위한 일부 텍스트"</targetSegment>
            <targetSegment langLocale="es-ES">Algunos textos para traducción</targetSegment>
            <targetSegment langLocale="de-DE">Irgendein Text für Übersetzung</targetSegment>
            <targetSegment langLocale="fr-FR">Quelques textes pour la traduction</targetSegment>
            <targetSegment langLocale="ru-RU">Некоторый текст для перевода</targetSegment>
            <targetSegment langLocale="zh-CN">一些翻译文字</targetSegment>
            <targetSegment langLocale="zh-TW">一些翻譯文字</targetSegment>
            <targetSegment langLocale="ar-AA">بعض النصوص للترجمة</targetSegment>
        </translationUnit>
        <translationUnit active="true" key="headerText" notes="Notes for translator">
            <sourceSegment langLocale="en-US">New text for translation.</sourceSegment>
            <targetSegment langLocale="ja-JP"></targetSegment>
            <targetSegment langLocale="ko-KR"></targetSegment>
            <targetSegment langLocale="es-ES"></targetSegment>
            <targetSegment langLocale="de-DE"></targetSegment>
            <targetSegment langLocale="fr-FR"></targetSegment>
            <targetSegment langLocale="ru-RU"></targetSegment>
            <targetSegment langLocale="zh-CN"></targetSegment>
            <targetSegment langLocale="zh-TW"></targetSegment>
            <targetSegment langLocale="ar-AA"></targetSegment>
        </translationUnit>
        <translationUnit active="false" key="buttonText" notes="Text that is no longer active">
            <sourceSegment langLocale="en-US">New text for translation.</sourceSegment>
            <targetSegment langLocale="ja-JP"></targetSegment>
            <targetSegment langLocale="ko-KR"></targetSegment>
            <targetSegment langLocale="es-ES"></targetSegment>
            <targetSegment langLocale="de-DE"></targetSegment>
            <targetSegment langLocale="fr-FR"></targetSegment>
            <targetSegment langLocale="ru-RU"></targetSegment>
            <targetSegment langLocale="zh-CN"></targetSegment>
            <targetSegment langLocale="zh-TW"></targetSegment>
            <targetSegment langLocale="ar-AA"></targetSegment>
        </translationUnit>
    </translationJob>
</translationBody>

恩美
日语
朝鲜语
西班牙语
德德
法语
茹茹
中弘中国
繁体中文
ar AA
一些文本用于翻译。
翻訳用テキスト
번역을위한 일부 텍스트"
Algunos textos para traducción
伊尔根丹文本fürÜbersetzung
这是一种传统
Некоторый текст для перевода
一些翻译文字
一些翻譯文字
بعض النصوص للترجمة
翻译的新文本。
翻译的新文本。
当前XSD:

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleType name="sourceString">
    <xs:annotation id="SourceStringDesc"><xs:documentation>This is a type setup to ensure that the length of the sourcString is greater than 0. Essentially, it is not ok to have a blank sourceSegment.</xs:documentation></xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="langString">
    <xs:annotation id="langStringDesc"><xs:documentation>This is a type setup to ensure that the length of the langString is greater than 0. Essentially, it is not ok to have a blank langString.</xs:documentation></xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
      <xs:pattern value="da-DK|ms-MY|it-IT|pt-BR|zh-CN|es-US|ko-KR|fr-CA|pt-PT|fr-FR|ja-JP|es-ES|de-DE|en-US|ru-RU|es-419|en-GB|zh-TW|tr-TR|nl-NL|th-TH|az-AZ-Cyrl|az-AZ-Latn|ba-RU|eu-ES|hmv|br-FR|bg-BG|my-BU|cal|ca-ES|ceb|ch|ny-MW|am-ET|zh-HK|zh-SG|bn|fr|fu|hr-HR|cs-CZ|ht|prs-AF|en|bal-IR|en-AU|eo|en-BZ|en-CA|en-CB|en-IE|en-JM|en-NZ|en-PH|en-ZA|en-CH|en-TT|en-ZW|et-EE|fo-FO|fa-IR|fj-FJ|sm-WS|fr-BE|nl|ar-DZ|mh|ar-AA|as-IN|ab|fy|fr-LU|ik|fr-MC|tet-ID|fr-CH|gd-GB|gl-ES|ka-GE|ar-IQ|ar-LY|ar-LB|ar-JO|ga-IE|lv-LV|ar-KW|he-IL|ar-MA|de-AT|sla-ME|de-LU|pau|de-CH|el-GR|kl-GL|grn|is-IS|es|ha-NG|hi-IN|id-ID|ia|ie|iu|zu-ZA|kk-KZ|jv-ID|kn-IN|ks|lo-LA|rw-RW|kg-CG|kok-IN|ku-TR|ln-CG|lt-LT|lb|mk-MK|mg-MG|mt-MT|mi-NZ|mn-MN|na-NR|nd-ZW|nb-NO|nn-NO|oc-FR|ps|pl-PL|qu-PE|ro-RO|rn|sg|sa-IN|sr-CY|sr-LA|sr-YU|st|sn|it-CH|ne-NP|pa-PA|ml-IN|yi|la|mo-MD|mr-IN|sk-SK|sl-SI|ar-OM|ar-QA|es-CU|ar-SA|apd-SD|ar-SY|sd|syr-TR|so-DJ|so-ET|tk-TM|so-KE|so-SO|dsb-DE|hsb-DE|es-AR|es-BO|es-CL|es-CO|es-CR|es-EC|es-SV|es-GT|es-HN|es-MX|es-NI|es-PA|es-PY|es-PE|es-PR|rm-CH|be-BY|so|sv|tt-RU|cy-GB|yi-IL|yo-NG|ta-IN|te-IN|ar-TN|bo|es-UY|es-VE|su|sw-KE|ss|sv-FI|sv-SE|tl-PH|tg-TJ|ts-ZA|tn-BW|uz-UZ-Latn|tn-ZA|tw|ug-CN|uk-UA|ur-IN|vi-VN|vo|xh-ZA|za|gu-IN|km-KH|zh-MO|or-IN|co-FR|de-LI|it|no|nl-BE|si-LK|de|pt|sq-AL|tz|nai|ti|ky|CHR|fil|nso-ZA|wo|fr-SN|ig|en-SG|ps-IR|to-TO|en-IN|ls|bs-BS-Cyrl|om-ET|hy-AM|dv-IN|fi-FI|hu-HU|es-DO|bs-BS-Latn|aa-ET|af-ZA|ar-BH|ar-EG|bn_IN|bn_BD|bi-VU|ar-AE|ar-YE"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="translationBody">
    <xs:annotation id="translationBodyDesc"><xs:documentation>This is the main body of the translation text. There are no allowed attributes or restrictions. There must be at least one translationUnit element.</xs:documentation></xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="translationJob" maxOccurs="1" minOccurs="1">
          <xs:complexType>
           <xs:sequence>
             <xs:element name="jobLanguages" maxOccurs="1" minOccurs="1">
               <xs:annotation>
                 <xs:documentation>This element encapsulates the languages for the project. All the languages listed here should match the languages indicated in each translationUnit.</xs:documentation>
               </xs:annotation>
               <xs:complexType>
                 <xs:sequence>
             <xs:element name="sourceLang" maxOccurs="1" minOccurs="1" nillable="false">
               <xs:annotation>
                 <xs:documentation>This element encapsulates the source language of the project, and should match the source language of each translationUnit. There can and must be only 1 of these elements</xs:documentation>
               </xs:annotation>
               <xs:complexType>
                 <xs:simpleContent>
                   <xs:extension base="langString">
                   </xs:extension>
                 </xs:simpleContent>
               </xs:complexType>
             </xs:element>
             <xs:element name="targetLang" maxOccurs="unbounded" minOccurs="1" nillable="false">
               <xs:annotation>
                 <xs:documentation>This element encapsulates the target languages of the project. Each translationUnit should have each of these target languages, no exceptions. There must be at least 1 targetLanguage specified, but there is no limit as to how many targetLanguages there can be. Each target language must be unique, and the targetLanguage should not equal the sourceLanguage.</xs:documentation>
               </xs:annotation>
               <xs:complexType>
                 <xs:simpleContent>
                   <xs:extension base="langString">
                   </xs:extension>
                 </xs:simpleContent>
               </xs:complexType>
             </xs:element>
                 </xs:sequence>
               </xs:complexType>
               <xs:unique name="uniqueJobLangs">
                 <xs:selector xpath="*"/>
                 <xs:field xpath="@langString"/>
               </xs:unique>
             </xs:element>
        <xs:element name="translationUnit" maxOccurs="unbounded" minOccurs="1">
          <xs:annotation id="translationUnitDesc"><xs:documentation>This is the main unit for translation and comprises language combination(s). There should be only one sourceSegment element, and at least one targetSegment element. The langLocale attribute on each targetSegment element must be unique. In other words, there can only be one targetSegment per language. Also, no targetSegment can have the same langLocale as the sourceSegment. If no translation exists yet, targetSegments should be left blank, but they MUST be included in the file</xs:documentation></xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="sourceSegment" maxOccurs="1" minOccurs="1" nillable="false">
                <xs:annotation id="sourceSegmentDesc"><xs:documentation>Text for translation is placed in this element. Must be 1 per translationUnit element. Cannot be null, also cannot be less than 1 character long.</xs:documentation></xs:annotation>
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="sourceString">
                      <xs:attribute name="langLocale" use="required">
                        <xs:annotation id="langLocaleDesc"><xs:documentation>This is the language-locale combination for the source. All sourceString must have the same langLocale</xs:documentation></xs:annotation>
                        <xs:simpleType>
                          <xs:restriction base="xs:string">
                            <xs:annotation id="langRestrictionDesc"><xs:documentation>The available options for language locale combos are limited certain values based on our API. Please see Glyph Best Practices API Documentation for more details.</xs:documentation></xs:annotation>
                            <xs:pattern value="da-DK|ms-MY|it-IT|pt-BR|zh-CN|es-US|ko-KR|fr-CA|pt-PT|fr-FR|ja-JP|es-ES|de-DE|en-US|ru-RU|es-419|en-GB|zh-TW|tr-TR|nl-NL|th-TH|az-AZ-Cyrl|az-AZ-Latn|ba-RU|eu-ES|hmv|br-FR|bg-BG|my-BU|cal|ca-ES|ceb|ch|ny-MW|am-ET|zh-HK|zh-SG|bn|fr|fu|hr-HR|cs-CZ|ht|prs-AF|en|bal-IR|en-AU|eo|en-BZ|en-CA|en-CB|en-IE|en-JM|en-NZ|en-PH|en-ZA|en-CH|en-TT|en-ZW|et-EE|fo-FO|fa-IR|fj-FJ|sm-WS|fr-BE|nl|ar-DZ|mh|ar-AA|as-IN|ab|fy|fr-LU|ik|fr-MC|tet-ID|fr-CH|gd-GB|gl-ES|ka-GE|ar-IQ|ar-LY|ar-LB|ar-JO|ga-IE|lv-LV|ar-KW|he-IL|ar-MA|de-AT|sla-ME|de-LU|pau|de-CH|el-GR|kl-GL|grn|is-IS|es|ha-NG|hi-IN|id-ID|ia|ie|iu|zu-ZA|kk-KZ|jv-ID|kn-IN|ks|lo-LA|rw-RW|kg-CG|kok-IN|ku-TR|ln-CG|lt-LT|lb|mk-MK|mg-MG|mt-MT|mi-NZ|mn-MN|na-NR|nd-ZW|nb-NO|nn-NO|oc-FR|ps|pl-PL|qu-PE|ro-RO|rn|sg|sa-IN|sr-CY|sr-LA|sr-YU|st|sn|it-CH|ne-NP|pa-PA|ml-IN|yi|la|mo-MD|mr-IN|sk-SK|sl-SI|ar-OM|ar-QA|es-CU|ar-SA|apd-SD|ar-SY|sd|syr-TR|so-DJ|so-ET|tk-TM|so-KE|so-SO|dsb-DE|hsb-DE|es-AR|es-BO|es-CL|es-CO|es-CR|es-EC|es-SV|es-GT|es-HN|es-MX|es-NI|es-PA|es-PY|es-PE|es-PR|rm-CH|be-BY|so|sv|tt-RU|cy-GB|yi-IL|yo-NG|ta-IN|te-IN|ar-TN|bo|es-UY|es-VE|su|sw-KE|ss|sv-FI|sv-SE|tl-PH|tg-TJ|ts-ZA|tn-BW|uz-UZ-Latn|tn-ZA|tw|ug-CN|uk-UA|ur-IN|vi-VN|vo|xh-ZA|za|gu-IN|km-KH|zh-MO|or-IN|co-FR|de-LI|it|no|nl-BE|si-LK|de|pt|sq-AL|tz|nai|ti|ky|CHR|fil|nso-ZA|wo|fr-SN|ig|en-SG|ps-IR|to-TO|en-IN|ls|bs-BS-Cyrl|om-ET|hy-AM|dv-IN|fi-FI|hu-HU|es-DO|bs-BS-Latn|aa-ET|af-ZA|ar-BH|ar-EG|bn_IN|bn_BD|bi-VU|ar-AE|ar-YE"/>
                          </xs:restriction>
                        </xs:simpleType>
                      </xs:attribute>
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
              <xs:element name="targetSegment" maxOccurs="unbounded" minOccurs="1" nillable="true">
                <xs:annotation id="targetSegmentDesc"><xs:documentation>This is the element that holds any translated text or is the place holder for translated text. It can be empty, but there must be at least one in each translationUnit. In other words, there must be at least one language combination in the file.</xs:documentation></xs:annotation>
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute name="langLocale" use="required">
                        <xs:annotation id="langLocaleDesc2"><xs:documentation>This is the language-locale combination for the source. All sourceString must have the same langLocale</xs:documentation></xs:annotation>
                        <xs:simpleType>
                          <xs:restriction base="xs:string">
                            <xs:annotation id="langRestrictionDesc2"><xs:documentation>The available options for language locale combos are limited certain values based on our API. Please see Glyph Best Practices API Documentation for more details.</xs:documentation></xs:annotation>
                            <xs:pattern value="da-DK|ms-MY|it-IT|pt-BR|zh-CN|es-US|ko-KR|fr-CA|pt-PT|fr-FR|ja-JP|es-ES|de-DE|en-US|ru-RU|es-419|en-GB|zh-TW|t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ZA|za|gu-IN|km-KH|zh-MO|or-IN|co-FR|de-LI|it|no|nl-BE|si-LK|de|pt|sq-AL|tz|nai|ti|ky|CHR|fil|nso-ZA|wo|fr-SN|ig|en-SG|ps-IR|to-TO|en-IN|ls|bs-BS-Cyrl|om-ET|hy-AM|dv-IN|fi-FI|hu-HU|es-DO|bs-BS-Latn|aa-ET|af-ZA|ar-BH|ar-EG|bn_IN|bn_BD|bi-VU|ar-AE|ar-YE"/>
                          </xs:restriction>
                        </xs:simpleType>
                      </xs:attribute>
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="active" use="required">
              <xs:annotation id="activeDesc"><xs:documentation>This indicates whether this translationUnit is active. If you do not want this to be translated or processed, set to false. Default should be true</xs:documentation></xs:annotation>
              <xs:simpleType>
                <xs:restriction base="xs:string">
                  <xs:enumeration value="true"/>
                  <xs:enumeration value="false"/>
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
            <xs:attribute type="xs:string" name="key" use="required">
            <xs:annotation id="keyDesc"><xs:documentation>key is a required element. It should be a unique identifier for your string.</xs:documentation></xs:annotation>
            </xs:attribute>
              <xs:attribute type="xs:string" name="notes" use="required">
                <xs:annotation id="notesDesc"><xs:documentation>The notes attribute MUST be included, even if it is left blank (=""). Put any notes about context or information the translators should know. The notes will be presented to all langauges. At this time, we don't support langauge specific notes.</xs:documentation></xs:annotation>
              </xs:attribute>
            <xs:attribute name="lenRestriction" use="required">
              <xs:annotation id="lenRestrictionDesc"><xs:documentation>The notes attribute MUST be included, and cannot be left blank. The value should be 0 if no length restriction is desired. This attribute is used to tells the translator the maximum number of characters allowed for this string. If used, it must be an integer of 1 or greater. If used, the translator will be forced to validate the length or change their translation prior to delivery.</xs:documentation></xs:annotation>
              <xs:simpleType>
                <xs:restriction>
                  <xs:minInclusive value="0" />
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
          </xs:complexType>
          <xs:unique name="uniqueLang">
            <xs:selector xpath="*"/>
            <xs:field xpath="@langLocale"/>
          </xs:unique>
          <xs:unique name="uniqueKey">
            <xs:selector xpath="*"></xs:selector>
            <xs:field xpath="@key"></xs:field>
          </xs:unique>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

这是一种类型设置,用于确保sourcString的长度大于0。本质上,使用空白sourceSegment是不正确的。
这是一种类型设置,用于确保langString的长度大于0。实际上,使用空白langString是不合适的。
这是翻译文本的主体。没有允许的属性或限制。必须至少有一个translationUnit元素。
此元素封装项目的语言。此处列出的所有语言应与每个translationUnit中指示的语言匹配。
此元素封装了项目的源语言,并且应该与每个translationUnit的源语言匹配。这些元素中只能有一个,而且必须只有一个
此元素封装了项目的目标语言。每个translationUnit都应该有这些目标语言,没有例外。必须至少指定1种targetLanguage,但不能限制可以有多少种targetLanguage。每个目标语言必须是唯一的,并且targetLanguage不应等于sourceL语言。
这是翻译的主要单位,包括语言组合。应该只有一个sourceSegment元素,并且至少有一个targetSegment元素。每个targetSegment元素上的langLocale属性必须是唯一的。换句话说,每种语言只能有一个targetSegment。此外,任何targetSegment都不能与sourceSegment具有相同的langLocale。如果尚未存在翻译,则targetSegments应uld为空,但必须包含在文件中
用于翻译的文本放置在此元素中。每个translationUnit元素必须为1。不能为null,长度也不能小于1个字符。
这是源的语言区域设置组合。所有sourceString必须具有相同的语言区域设置
基于我们的API,语言区域设置组合的可用选项仅限于某些值。有关更多详细信息,请参阅Glyph最佳实践API文档。
这是保存任何翻译文本的元素或翻译文本的占位符。它可以为空,但每个translationUnit中必须至少有一个。换句话说,文件中必须至少有一种语言组合。
这是源的语言区域设置组合。所有sourceString必须具有相同的语言区域设置
基于我们的API,语言区域设置组合的可用选项仅限于某些值。请参阅Glyph最佳实践API文档