0

次のスキーマ要素があり、それに属性を追加したいと考えています。

<xsd:ComplexType>
    <xsd:sequence>    
       <xsd:element name="Product" maxOccurs="1" minOccurs="0" >
        <xsd:simpleType>
            <xsd:restriction base="xsd:string">
                <xsd:maxLength value="100" />
            </xsd:restriction>
        </xsd:simpleType>
        </xsd:element>
    </xsd:sequence>
</xsd:ComplexType>

現在、結果の XML は次のようになります。

<Product>This is the Product Translation for 001</Product>

結果の XML を次のようにしたい:

<Product code="001">This is the Product Translation for 001</Product>
4

1 に答える 1

0

これでうまくいくはずです:

<xsd:ComplexType>
    <xsd:sequence>    
        <xsd:element name="Product" maxOccurs="1" minOccurs="0" >
            <xsd:complexType>
                <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="100" />
                </xsd:restriction>
                <xsd:attribute name="code" type="xs:string" use="required"/>
            </xsd:complexType>
        </xsd:element>
    </xsd:sequence>
</xsd:ComplexType>

属性に別のタイプを指定したい場合がありますcode

于 2013-04-22T13:43:57.803 に答える