Xml 将名称空间添加到单个元素不会';不符合xsd
我只想在单个元素中添加一个名称空间,Xml 将名称空间添加到单个元素不会';不符合xsd,xml,xsd,xmlspy,Xml,Xsd,Xmlspy,我只想在单个元素中添加一个名称空间,S\u NO,但我想不出来。我们将不胜感激。当我在元素上添加前缀和内容时,总是会出错。当使用XMLSpy时,它不会识别XSD中调用的元素 XML代码: <MSG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/test_xml/izzypod5/test_input.xsd"> <BODY>
S\u NO
,但我想不出来。我们将不胜感激。当我在元素上添加前缀和内容时,总是会出错。当使用XMLSpy时,它不会识别XSD中调用的元素
XML代码:
<MSG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/test_xml/izzypod5/test_input.xsd">
<BODY>
<bar:S_NO xmlns:bar="http://www.bar.org/">4423</bar:S_NO>
</BODY>
</MSG>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bar="http://www.bar.org/">
<!-- Element Declarations -->
<xs:element name="S_NO" type="S_NOType" nillable="true">
<xs:annotation>
<xs:documentation>S_No; Mandatory Field</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="BODY" type="BODYType">
<xs:annotation>
<xs:documentation>Body</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MSG" type="MSGType">
<xs:annotation>
<xs:documentation>Message encapsulates Body</xs:documentation>
</xs:annotation>
</xs:element>
<xs:simpleType name="S_NOType">
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="15"/>
</xs:restriction>
</xs:simpleType>
<!-- Complex Type Declarations -->
<xs:complexType name="BODYType">
<xs:sequence>
<xs:element ref="S_NO"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MSGType">
<xs:sequence>
<xs:element ref="BODY"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="REQUEST_MSGType">
<xs:sequence>
<xs:element ref="MSG"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<MSG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file:///C:/test_xml/izzypod5/test_input.xsd"
xmlns:bar="http://www.bar.org/">
<BODY>
<bar:S_NO xmlns:bar="http://www.bar.org/">4423</bar:S_NO>
</BODY>
</MSG>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bar="http://www.bar.org/">
<xs:import namespace="http://www.bar.org/" schemaLocation="bar.xsd"/>
<!-- Element Declarations -->
<xs:element name="BODY" type="BODYType">
<xs:annotation>
<xs:documentation>Body</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MSG" type="MSGType">
<xs:annotation>
<xs:documentation>Message encapsulates Body</xs:documentation>
</xs:annotation>
</xs:element>
<!-- Complex Type Declarations -->
<xs:complexType name="BODYType">
<xs:sequence>
<xs:element ref="bar:S_NO"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MSGType">
<xs:sequence>
<xs:element ref="BODY"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="REQUEST_MSGType">
<xs:sequence>
<xs:element ref="MSG"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bar="http://www.bar.org/"
targetNamespace="http://www.bar.org/">
<xs:element name="S_NO" type="bar:S_NOType" nillable="true">
<xs:annotation>
<xs:documentation>S_No; Mandatory Field</xs:documentation>
</xs:annotation>
</xs:element>
<xs:simpleType name="S_NOType">
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="15"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
4423
XSD代码:
<MSG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/test_xml/izzypod5/test_input.xsd">
<BODY>
<bar:S_NO xmlns:bar="http://www.bar.org/">4423</bar:S_NO>
</BODY>
</MSG>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bar="http://www.bar.org/">
<!-- Element Declarations -->
<xs:element name="S_NO" type="S_NOType" nillable="true">
<xs:annotation>
<xs:documentation>S_No; Mandatory Field</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="BODY" type="BODYType">
<xs:annotation>
<xs:documentation>Body</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MSG" type="MSGType">
<xs:annotation>
<xs:documentation>Message encapsulates Body</xs:documentation>
</xs:annotation>
</xs:element>
<xs:simpleType name="S_NOType">
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="15"/>
</xs:restriction>
</xs:simpleType>
<!-- Complex Type Declarations -->
<xs:complexType name="BODYType">
<xs:sequence>
<xs:element ref="S_NO"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MSGType">
<xs:sequence>
<xs:element ref="BODY"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="REQUEST_MSGType">
<xs:sequence>
<xs:element ref="MSG"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<MSG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file:///C:/test_xml/izzypod5/test_input.xsd"
xmlns:bar="http://www.bar.org/">
<BODY>
<bar:S_NO xmlns:bar="http://www.bar.org/">4423</bar:S_NO>
</BODY>
</MSG>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bar="http://www.bar.org/">
<xs:import namespace="http://www.bar.org/" schemaLocation="bar.xsd"/>
<!-- Element Declarations -->
<xs:element name="BODY" type="BODYType">
<xs:annotation>
<xs:documentation>Body</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MSG" type="MSGType">
<xs:annotation>
<xs:documentation>Message encapsulates Body</xs:documentation>
</xs:annotation>
</xs:element>
<!-- Complex Type Declarations -->
<xs:complexType name="BODYType">
<xs:sequence>
<xs:element ref="bar:S_NO"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MSGType">
<xs:sequence>
<xs:element ref="BODY"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="REQUEST_MSGType">
<xs:sequence>
<xs:element ref="MSG"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bar="http://www.bar.org/"
targetNamespace="http://www.bar.org/">
<xs:element name="S_NO" type="bar:S_NOType" nillable="true">
<xs:annotation>
<xs:documentation>S_No; Mandatory Field</xs:documentation>
</xs:annotation>
</xs:element>
<xs:simpleType name="S_NOType">
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="15"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
苏诺;必填字段
身体
消息封装了正文
对于希望在不同命名空间中包含的元素,必须使用另一个XSD。
XML文档实例:
<MSG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/test_xml/izzypod5/test_input.xsd">
<BODY>
<bar:S_NO xmlns:bar="http://www.bar.org/">4423</bar:S_NO>
</BODY>
</MSG>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bar="http://www.bar.org/">
<!-- Element Declarations -->
<xs:element name="S_NO" type="S_NOType" nillable="true">
<xs:annotation>
<xs:documentation>S_No; Mandatory Field</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="BODY" type="BODYType">
<xs:annotation>
<xs:documentation>Body</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MSG" type="MSGType">
<xs:annotation>
<xs:documentation>Message encapsulates Body</xs:documentation>
</xs:annotation>
</xs:element>
<xs:simpleType name="S_NOType">
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="15"/>
</xs:restriction>
</xs:simpleType>
<!-- Complex Type Declarations -->
<xs:complexType name="BODYType">
<xs:sequence>
<xs:element ref="S_NO"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MSGType">
<xs:sequence>
<xs:element ref="BODY"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="REQUEST_MSGType">
<xs:sequence>
<xs:element ref="MSG"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<MSG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file:///C:/test_xml/izzypod5/test_input.xsd"
xmlns:bar="http://www.bar.org/">
<BODY>
<bar:S_NO xmlns:bar="http://www.bar.org/">4423</bar:S_NO>
</BODY>
</MSG>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bar="http://www.bar.org/">
<xs:import namespace="http://www.bar.org/" schemaLocation="bar.xsd"/>
<!-- Element Declarations -->
<xs:element name="BODY" type="BODYType">
<xs:annotation>
<xs:documentation>Body</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MSG" type="MSGType">
<xs:annotation>
<xs:documentation>Message encapsulates Body</xs:documentation>
</xs:annotation>
</xs:element>
<!-- Complex Type Declarations -->
<xs:complexType name="BODYType">
<xs:sequence>
<xs:element ref="bar:S_NO"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MSGType">
<xs:sequence>
<xs:element ref="BODY"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="REQUEST_MSGType">
<xs:sequence>
<xs:element ref="MSG"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bar="http://www.bar.org/"
targetNamespace="http://www.bar.org/">
<xs:element name="S_NO" type="bar:S_NOType" nillable="true">
<xs:annotation>
<xs:documentation>S_No; Mandatory Field</xs:documentation>
</xs:annotation>
</xs:element>
<xs:simpleType name="S_NOType">
<xs:restriction base="xs:string">
<xs:minLength value="0"/>
<xs:maxLength value="15"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
我有一种感觉,我可能不得不使用另一个xsd导入ok谢谢