Я работаю над схемой XSD, меня попросили добавить новый сложный тип в узел понятий, он выглядит так:
<xs:element name="Conceptos">
<xs:complexType>
<xs:sequence>
<xs:element name="Concepto" maxOccurs="unbounded">
<xs:complexType>
<xs:choice minOccurs="0">
<xs:element name="InformacionAduanera" type="cfdi:t_InformacionAduanera" minOccurs="0" maxOccurs="unbounded">
</xs:element>
<xs:element name="CuentaPredial" minOccurs="0">
<xs:annotation>
<xs:documentation>Nodo opcional para asentar el número de cuenta predial con el que fue registrado el inmueble, en el sistema catastral de la entidad federativa de que trate.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="numero" use="required">
<xs:annotation>
<xs:documentation>Atributo requerido para precisar el número de la cuenta predial del inmueble cubierto por el presente concepto en caso de recibos de arrendamiento.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse"/>
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="cantidad" use="required">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="unidad" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse"/>
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="noIdentificacion" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="descripcion" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="valorUnitario" type="cfdi:t_Importe" use="required">
</xs:attribute>
<xs:attribute name="importe" type="cfdi:t_Importe" use="required">
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Эта часть XSD проверяет следующий фрагмент XML
<cfdi:Conceptos>
<cfdi:Concepto cantidad="1.0" noIdentificacion="15" descripcion="Autotransporte terrestre de bienes" valorUnitario="10" importe="10" />
<cfdi:Concepto cantidad="1.0" noIdentificacion="19" descripcion="PF a PM Retencion 2/3 IVA" valorUnitario="10" importe="10">
<cfdi:InformacionAduanera numero="123456" fecha="2011-07-13" aduana="Nuevo Laredo"/>
</cfdi:Concepto>
Итак, я хочу добавить новый элемент, чтобы xml выглядел следующим образом:
<cfdi:Conceptos>
<cfdi:Concepto cantidad="1.0" noIdentificacion="15" descripcion="Autotransporte terrestre de bienes" valorUnitario="10" importe="10" />
<cfdi:Concepto cantidad="1.0" noIdentificacion="19" descripcion="PF a PM Retencion 2/3 IVA" valorUnitario="10" importe="10">
<cfdi:InformacionAduanera numero="123456" fecha="2011-07-13" aduana="Nuevo Laredo"/>
<cfdi:OptDetail name="TransID" value="34545" />
<cfdi:OptDetail name="Purchase" value="8745" />
<cfdi:OptDetail name="StoreID" value="1" />
<cfdi:OptDetail name="someName" value="SomeValue" />
<cfdi:OptDetail name="XXXX" value="YYYY" />
.
.
.
N
</cfdi:Concepto>
Как видите, я хочу добавить новый элемент (optDetail) для каждого Concepto с minOccurs = 0 и maxOccurs = unbouded. Это почти то же самое, что и узел InformacionAduanera (я не см. смысл показывать здесь определение этого типа), но InformacionAduanera находится под ограничением выбора,
Итак, что я сделал, я сначала определил свой тип
<xs:complexType name="optDetail">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="value" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
Я пытался добавить XSD, но безуспешно, я получил ошибки, такие как узел элемента смещен или слишком много вхождений для тега элемента, поэтому вопрос в том, где я должен поместить его для проверки моего xml, показанного выше ???
Спасибо !!