Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 用默认值替换缺少的元素_Xml_Xsd - Fatal编程技术网

Xml 用默认值替换缺少的元素

Xml 用默认值替换缺少的元素,xml,xsd,Xml,Xsd,我的模式摘录: <xs:complexType name="foo"> <xs:sequence> <xs:element name="bar" type="xs:positiveInteger"/> <xs:element name="baz" type="bax_type" minOccurs="0"/> </xs:sequence> </xs:complexType>

我的模式摘录:

<xs:complexType name="foo">
    <xs:sequence>
        <xs:element name="bar" type="xs:positiveInteger"/>
        <xs:element name="baz" type="bax_type" minOccurs="0"/>
    </xs:sequence>
</xs:complexType>


<xs:simpleType name="baz_type">
    <xs:restriction base="xs:NMTOKEN">
        <xs:enumeration value="none"/>
        <xs:enumeration value="wombat"/>
    </xs:restriction>
</xs:simpleType>
  • 这一个解析正确:

    <foo>
        <bar>1</bar>
        <baz>wombat</baz>
    </foo>
    
    
    1.
    袋熊
    

  • 使用选择指示器,请参考此

    <foo>
        <bar>1</bar>
        <baz>wombat</baz>
    </foo>