Web services 找不到元素';emp公司';
在验证这个XML时,我似乎遇到了一些问题 这是我创建的XMLWeb services 找不到元素';emp公司';,web-services,xsd,xsd-validation,Web Services,Xsd,Xsd Validation,在验证这个XML时,我似乎遇到了一些问题 这是我创建的XML <?xml version="1.0" encoding="UTF-8"?> <emp_comp xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="http://localhost:9080/ermWeb/WebContent/XSD/Compensation.xsd"> <emp>
<?xml version="1.0" encoding="UTF-8"?>
<emp_comp xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="http://localhost:9080/ermWeb/WebContent/XSD/Compensation.xsd">
<emp>
<row_id>0</row_id>
<emp_code>002</emp_code>
<emp_compdt>01-04-2014</emp_compdt>
<emp_cdata>
<emp_cname>Basic</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>100.00</emp_camt>
</emp_cdata>
</emp>
</emp_comp>
0
002
01-04-2014
基本的
印度卢比
100
对应的模式是
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="emp_comp">
<xs:complexType>
<xs:sequence>
<xs:element name="emp" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="row_id" type="xs:int" />
<xs:element name="emp_code" type="xs:string"
minOccurs="0" />
<xs:element name="emp_compdt"
minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern
value="|([0-3][0-9][\-](Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[\-][0-9]{4})" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="emp_cdata" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="emp_cname"
type="xs:string" minOccurs="0" />
<xs:element name="emp_ccurr"
type="xs:string" minOccurs="0" />
<xs:element name="emp_camt" minOccurs="0" > <!-- ^\d+\.\d{0,2}$ -->
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]+(\.[0-9][0-9]?)?" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
我得到的错误是找不到元素“emp_comp”的声明
这可能是什么原因。问题
问题出在第一个标记上,请删除此声明
xmlns:xsi=”http://www.w3.org/2001/XMLSchema“xsi:noNamespaceSchemaLocation=”http://localhost:9080/ermWeb/WebContent/XSD/Compe豁免.xsd“
和修复2014年4月1日
可能的解决办法 在XSD
targetNamespace=”上定义名称空间http://namespace“
XML可以是
<ns1:emp_comp xmlns:ns1="http://namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://namespace http://localhost:9080/ermWeb/WebContent/XSD/Compensation.xsd">
<emp>
<row_id>0</row_id>
<emp_code>002</emp_code>
<emp_compdt>01-APR-2014</emp_compdt>
<emp_cdata>
<emp_cname>Basic</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>100.00</emp_camt>
</emp_cdata>
</emp>
</ns1:emp_comp>
0
002
2014年4月1日
基本的
印度卢比
100
问题
问题出在第一个标记上,请删除此声明
xmlns:xsi=”http://www.w3.org/2001/XMLSchema“xsi:noNamespaceSchemaLocation=”http://localhost:9080/ermWeb/WebContent/XSD/Compe豁免.xsd“
和修复2014年4月1日
可能的解决办法 在XSD
targetNamespace=”上定义名称空间http://namespace“
XML可以是
<ns1:emp_comp xmlns:ns1="http://namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://namespace http://localhost:9080/ermWeb/WebContent/XSD/Compensation.xsd">
<emp>
<row_id>0</row_id>
<emp_code>002</emp_code>
<emp_compdt>01-APR-2014</emp_compdt>
<emp_cdata>
<emp_cname>Basic</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>100.00</emp_camt>
</emp_cdata>
</emp>
</ns1:emp_comp>
0
002
2014年4月1日
基本的
印度卢比
100
更改:
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
致:
然后,假设您的XSD位于http://localhost:9080/ermWeb/WebContent/XSD/Compensation.xsd
,它会工作的。在浏览器中将其向上拉以确保。更改:
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
致:
然后,假设您的XSD位于
http://localhost:9080/ermWeb/WebContent/XSD/Compensation.xsd
,它会工作的。在浏览器中打开它以确定。好的,这可能是我第一次回答我自己的问题
<?xml version="1.0" encoding="UTF-8"?>
<emp_comp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://localhost:9080/ermWeb/XSD/Compensation.xsd">
<emp>
<row_id>0</row_id>
<emp_code>002</emp_code>
<emp_compdt>01-Jan-2014</emp_compdt>
<emp_cdata>
<emp_cname>Basic</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>100.00</emp_camt>
</emp_cdata>
<emp_cdata>
<emp_cname>VPF</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>120.00</emp_camt>
</emp_cdata>
<emp_cdata>
<emp_cname>Employer NPS</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>130.00</emp_camt>
</emp_cdata>
<emp_cdata>
<emp_cname>Employee NPS</emp_cname>
<emp_ccurr>INR</emp_ccurr>
<emp_camt>140.00</emp_camt>
</emp_cdata>
</emp>
</emp_comp>
0
002
2014年1月1日
基本的
印度卢比
100
VPF
印度卢比
120
雇主核动力源
印度卢比
130
雇员核动力源
印度卢比
140
正如其他答案所指出的,有3个错误。
1) 01-04-2014不正确,04必须替换为APR
2) xmlns:xsi=”http://www.w3.org/2001/XMLSchema,最后必须添加-instance
和
3) 我需要在名称空间中使用XSD资源,为此我必须添加noNamespace be