exception:必须正确处理根元素后面的文档中的标记。

时间:2017-06-19 05:45:56

标签: xml

这是我的xsd架构。

<xsd:element name="creditcard">

    <xsd:complexType>

        <xsd:sequence>

            <xsd:element maxOccurs="unbounded" minOccurs="1" name="card" type="type"/>

        </xsd:sequence>

    </xsd:complexType>

</xsd:element>

<xsd:complexType name="type">

    <xsd:sequence>

        <xsd:element name="cardnumber" type="xsd:string"/>

        <xsd:element name="fname" type="xsd:string"/>

        <xsd:element name="lname" type="xsd:string"/>

        <xsd:element name="address" type="xsd:string"/>

        <xsd:element name="limit" type="xsd:integer"/>

        <xsd:element maxOccurs="unbounded" minOccurs="0" name="prereqid" type="xsd:string"/>

        <xsd:element maxOccurs="unbounded" minOccurs="1" name="statement" type="statementType"/>

    </xsd:sequence>

</xsd:complexType>

<xsd:complexType name="statementType">

    <xsd:sequence>

        <xsd:element name="stateid" type="xsd:integer"/>

        <xsd:element name="statedate" type="xsd:date"/>

        <xsd:element maxOccurs="unbounded" minOccurs="1" name="statecharge" type="chargeType"/>

    </xsd:sequence>

</xsd:complexType>

<xsd:complexType name="chargeType">

    <xsd:sequence>

        <xsd:element name="cid" type="xsd:string"/>

        <xsd:element name="camount" type="xsd:decimal"/>

        <xsd:element name="cdate" type="xsd:date"/>

        <xsd:element name="cbusiness" type="xsd:string"/>

    </xsd:sequence>

</xsd:complexType>

我想生成一个xml文档。所以我把代码编写为

    <?xml version="1.0" encoding="utf-8"?>
    <creditcard>
    <card>
    <cardnumber>sri1234</cardnumber>
    <fname>sri</fname>
    <lname>nidhi</lname>
    <address>abc street</address>
    <limit>1234</limit>
    <prereqid>sri1234</prereqid>
    <statement>
    <stateid>89</stateid>
    <statedate>2017-06-19</statedate>
    <statecharge>
    <cid>str</cid>
    <camount>9678.7</camount>
    <cdate>2017-09-13</cdate>
    <cbusiness>marketing</cbusiness>
    </statecharge>
    </statement>
    </card>
    </creditcard>

这会产生异常,因为“根元素之后的文档中的标记必须格式正确。”

所以请有人帮我这样做。

1 个答案:

答案 0 :(得分:0)

您的架构文档缺少外部xsd:schema元素。