java - Cannot validate xml doc against a xsd schema (Cannot find the declaration of element 'replyMessage') -


I am using the following code to validate an XML file against the XSD schema

  package com.forat.xsd; Import java.io.IOException; Import java.net.URL; Import javax.xml.XMLConstants; Import javax.xml.transform.Source; Import javax.xml.transform.stream.StreamSource; Import javax.xml.validation.Schema; Import javax.xml.validation.SchemaFactory; Import javax.xml.validation.Validator; Import org.xml.sax.ErrorHandler; Import org.xml.sax.SAXException; Import org.xml.sax.SAXParseException; Public class XSDValidate {public zero valid (string xmlFile, string xsd_url) {{SchemaFactory factory =} SchemaFactory.newInstance (XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = factory Envascama (new url (xsd_url)); Validator Validator = Schema. Newfounder (); Validation Handler Handler = New Validation Handler (); Validator.setErrorHandler (handler); Validator.validate (getSource (xmlFile)); If (handler errors found == true) {System.err.println ("verification error:" + handler .exception .getMessage ()); } And {System.out.println ("full"); }} Catch (SAXException e) {e.printStackTrace (); } Hold (IOException e) {e.printStackTrace (); }} Private Source Hotsource (String Resource) (New Streisource (XSD Validate. Clash Gate Class Loader). GetResourceAsStream (resource)); } Private Class Legal Validator applies ErrorHandler {Private Boolean errors = incorrect; Private SAXParseException Exception; Public Zero Error (SAXParseException Exception) throws SAXException {this.errorsFound = true; This.exception = exceptions; } Public Zero Fatal Error (SAXParseException Exception) throws SAXException {this.errorsFound = true; This.exception = exceptions; } Public Zero Alert (SAXParseException Exception) throws SAXException {}} / * * Examination * / Public Fixed Zero Main (string [] args) {New XSDValidate () Valid ("com / forat / xsd / reply.xml", "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.53.xsd"); As it appears, this is a standard code that attempts to validate the following XML file:  
  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Answermax xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" & gt; & Lt; MerchantReferenceCode & gt; XXXXXXXXXXXXX & lt; / MerchantReferenceCode & gt; & Lt; RequestID & gt; XXXXXXXXXXXXX & lt; / RequestID & gt; & Lt; Decision & gt; XXXXXXXXXXXXX & lt; / Decision & gt; & Lt; ReasonCode & gt; XXXXXXXXXXXXX & lt; / ReasonCode & gt; & Lt; RequestToken & gt; XXXXXXXXXXXXX & lt; / RequestToken & gt; & Lt; PurchaseTotals & gt; & Lt; Currency & gt; XXXXXXXXXXXXX & lt; / Currency & gt; & Lt; / PurchaseTotals & gt; & Lt; CcAuthReply & gt; & Lt; ReasonCode & gt; XXXXXXXXXXXXX & lt; / ReasonCode & gt; & Lt; Amount & gt; XXXXXXXXXXXXX & lt; / Zodiac & gt; & Lt; AuthorizationCode & gt; XXXXXXXXXXXXX & lt; / AuthorizationCode & gt; & Lt; AvsCode & gt; XXXXXXXXXXXXX & lt; / AvsCode & gt; & Lt; AvsCodeRaw & gt; XXXXXXXXXXXXX & lt; / AvsCodeRaw> & Lt; AuthorizedDateTime & gt; XXXXXXXXXXXXX & lt; / AuthorizedDateTime & gt; & Lt; ProcessorResponse & gt; 0XXXXXXXXXXXXX & lt; / ProcessorResponse & gt; & Lt; AuthRecord & gt; XXXXXXXXXXXXX & lt; / AuthRecord & gt; & Lt; / CcAuthReply & gt; & Lt; / ReplyMessage & gt;  

Against the following XSD: The error is:

Verification error: cvc-elt.1: The element 'reply message' declaration can not be announced.

Can you please help me

Your XML is invalid, because This name is not in place by the schema:

  targetNamespace = "kalash: schema-cyber resource-com: transaction-data -1.53"  

You need to replace the opening tag for the original element:

   

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -