i getting error "cannot find declaration of element soapenv:envelope"
working fine other xml files xsd..issue following ones..
my xml file :-
<?xml version="1.0" encoding="utf-8"?> <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/ /tmp/checkxsd.xsd"> <soapenv:body> <ns:getentitiesbyfilterresponse xmlns:ns="http://services" xmlns:ax21="http://objects.services/xsd"> <ns:return xsi:type="ax21:entityobj"> <ax21:entityid>1065798192</ax21:entityid> <ax21:entitytypeid>4</ax21:entitytypeid> <ax21:methodvalues xsi:type="ax21:valuepair"> <ax21:elementvalue>project soapui 001</ax21:elementvalue> <ax21:id>436</ax21:id> </ax21:methodvalues> <ax21:methodvalues xsi:type="ax21:valuepair"> <ax21:elementvalue>project soapui 001</ax21:elementvalue> <ax21:id>100461</ax21:id> </ax21:methodvalues> <ax21:methodvalues xsi:type="ax21:valuepair"> <ax21:elementvalue>project soapui 001</ax21:elementvalue> <ax21:id>400015</ax21:id> </ax21:methodvalues> </ns:return> <ns:return xsi:type="ax21:entityobj"> <ax21:entityid>1065835163</ax21:entityid> <ax21:entitytypeid>4</ax21:entitytypeid> <ax21:methodvalues xsi:type="ax21:valuepair"> <ax21:elementvalue>project soapui 002</ax21:elementvalue> <ax21:id>436</ax21:id> </ax21:methodvalues> <ax21:methodvalues xsi:type="ax21:valuepair"> <ax21:elementvalue>project soapui 002</ax21:elementvalue> <ax21:id>100461</ax21:id> </ax21:methodvalues> <ax21:methodvalues xsi:type="ax21:valuepair"> <ax21:elementvalue>project soapui 002</ax21:elementvalue> <ax21:id>400015</ax21:id> </ax21:methodvalues> </ns:return> <ns:return xsi:type="ax21:entityobj"> <ax21:entityid>1317237376</ax21:entityid> <ax21:entitytypeid>4</ax21:entitytypeid> <ax21:methodvalues xsi:type="ax21:valuepair"> <ax21:elementvalue>copytask_project_1448004605927</ax21:elementvalue> <ax21:id>436</ax21:id> </ax21:methodvalues> <ax21:methodvalues xsi:type="ax21:valuepair"> <ax21:elementvalue>copytask_project_1448004605927</ax21:elementvalue> <ax21:id>100461</ax21:id> </ax21:methodvalues> <ax21:methodvalues xsi:type="ax21:valuepair"> <ax21:elementvalue>copytask_project_1448004605927</ax21:elementvalue> <ax21:id>400015</ax21:id> </ax21:methodvalues> </ns:return> </ns:getentitiesbyfilterresponse></soapenv:body></soapenv:envelope>
please find xsd below : -
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" attributeformdefault="unqualified" elementformdefault="qualified" targetnamespace="http://objects.services/xsd"> <xs:element name="entityid"> <xs:simpletype> <xs:restriction base="xs:int"> <xs:enumeration value="1065798192" /> <xs:enumeration value="1065835163" /> <xs:enumeration value="1317237376" /> </xs:restriction> </xs:simpletype> </xs:element> <xs:element name="entitytypeid" type="xs:byte" /> <xs:element name="methodvalues"> <xs:complextype> <xs:sequence> <xs:element name="elementvalue"> <xs:simpletype> <xs:restriction base="xs:string"> <xs:enumeration value="project soapui 001" /> <xs:enumeration value="project soapui 002" /> <xs:enumeration value="copytask_project_1448004605927" /> </xs:restriction> </xs:simpletype> </xs:element> <xs:element name="id"> <xs:simpletype> <xs:restriction base="xs:int"> <xs:enumeration value="436" /> <xs:enumeration value="100461" /> <xs:enumeration value="400015" /> </xs:restriction> </xs:simpletype> </xs:element> </xs:sequence> </xs:complextype> </xs:element> </xs:schema>
my java code validate xsd against xml follows : -
schemafactory factory = schemafactory.newinstance(xmlconstants.w3c_xml_schema_ns_uri); schema schema = factory.newschema(new file("/tmp/checkxsd.xsd")); validator validator = schema.newvalidator(); validator.validate(new streamsource(new file("/home/my-pc/myxmlfile.xml"))
any appreciated. stuck this.
the message seeing invariably means validator not loading schema; in turn, invariably because can't find it; in turn because of error in specifying locations of schema documents processed.
once over-long lines in example broken , start-tag outermost element can read conveniently without scrolling right , left, 1 source of problem (not one) seems clear. believe meaning of attribute-value specification
xsi:schemalocation="http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/ /tmp/checkxsd.xsd">
(at point, expect either have head-slap experience or raise eyebrows in puzzlement. if latter, suggest consult documentation.)
Comments
Post a Comment