私は 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>
ご覧のとおり、minOccurs = 0 および maxOccurs= unbounded の各Concepto に新しい要素 (optDetail) を追加したいと考えています。これは、InformacionAduanera ノードとほぼ同じものです (ここでの定義を示すポイントがわかりません)。このタイプ) ただし、InformacionAduanera は Choice 制限の下にあります。
だから私がしたことは、最初に自分のタイプを定義したことです
<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 に追加しようとしましたが、成功しませんでした。要素ノードの配置が間違っている、または要素タグの出現回数が多すぎるなどのエラーが発生しました。
ありがとう!!