Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 843081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:04:04+00:00 2026-05-15T06:04:04+00:00

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

  • 0

I am using the following code to validate an an XML file against a 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 void validate(String xmlFile, String xsd_url) {
  try {
   SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
   Schema schema = factory.newSchema(new URL(xsd_url));
   Validator validator = schema.newValidator();
   ValidationHandler handler = new ValidationHandler();
   validator.setErrorHandler(handler);
   validator.validate(getSource(xmlFile));

   if (handler.errorsFound == true) {
    System.err.println("Validation Error : "+ handler.exception.getMessage());
   }else {
    System.out.println("DONE");
   }
  } catch (SAXException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }

 private Source getSource(String resource) {
  return new StreamSource(XSDValidate.class.getClassLoader().getResourceAsStream(resource));
 }

 private class ValidationHandler implements ErrorHandler {
  private boolean errorsFound = false;
  private SAXParseException exception;

  public void error(SAXParseException exception) throws SAXException {
   this.errorsFound = true;
   this.exception = exception;
  }

  public void fatalError(SAXParseException exception) throws SAXException {
   this.errorsFound = true;
   this.exception = exception;
  }

  public void warning(SAXParseException exception) throws SAXException {
  }
 }

 /*
  * Test
  */
 public static void main(String[] args) {
  new XSDValidate().validate("com/forat/xsd/reply.xml", 
    "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.53.xsd"); // return error
 }

}

As appears, It is a standard code that try to validate the following XML file:

<?xml version="1.0" encoding="UTF-8"?>
<replyMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <merchantReferenceCode>XXXXXXXXXXXXX</merchantReferenceCode>
 <requestID>XXXXXXXXXXXXX</requestID>
 <decision>XXXXXXXXXXXXX</decision>
 <reasonCode>XXXXXXXXXXXXX</reasonCode>
 <requestToken>XXXXXXXXXXXXX
 </requestToken>
 <purchaseTotals>
  <currency>XXXXXXXXXXXXX</currency>
 </purchaseTotals>
 <ccAuthReply>
  <reasonCode>XXXXXXXXXXXXX</reasonCode>
  <amount>XXXXXXXXXXXXX</amount>
  <authorizationCode>XXXXXXXXXXXXX</authorizationCode>

  <avsCode>XXXXXXXXXXXXX</avsCode>
  <avsCodeRaw>XXXXXXXXXXXXX</avsCodeRaw>
  <authorizedDateTime>XXXXXXXXXXXXX</authorizedDateTime>
  <processorResponse>0XXXXXXXXXXXXX</processorResponse>
  <authRecord>XXXXXXXXXXXXX
  </authRecord>
 </ccAuthReply>
</replyMessage>

Against the following XSD:

https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.53.xsd

The error is :

Validation Error : cvc-elt.1: Cannot find the declaration of element ‘replyMessage’.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:04:05+00:00Added an answer on May 15, 2026 at 6:04 am

    Your XML is invalid, because it is not in the namespace required by the schema:

    targetNamespace="urn:schemas-cybersource-com:transaction-data-1.53"
    

    You need to change the opening tag of the root element to:

    <replyMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns="urn:schemas-cybersource-com:transaction-data-1.53">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 489k
  • Answers 489k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Sencha touch is a little more complicated for those used… May 16, 2026 at 9:02 am
  • Editorial Team
    Editorial Team added an answer You have the right idea. These values are the width… May 16, 2026 at 9:02 am
  • Editorial Team
    Editorial Team added an answer Why use that instead of directly accessing the object as… May 16, 2026 at 9:02 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am trying to use dom4j to validate the xml at http://www.w3schools.com/Schema/schema_example.asp using the
Is it possible to validate the following xml with the following schema? I'd like
I have the following (as an example) XML file and XSD. <?xml version=1.0 encoding=utf-8
I have the following XML Parsing code in my application: public static XElement Parse(string
I'm running into real difficulties validating XML with XSD . I should prefix all
I have the following (errorous) Xml: <jobs> <job> <id>1</id> <state><![CDATA[IL]]></state> </job> <job> <id>2</id> </job>
I have a XML file that looks like this <Licence> <Name>Test company</Name> <Version>1.1.1.1</Version> <NumberOfServer>2</NumberOfServer>
I'm trying to download a file from my provider. The url is protected with
I have started to play with xVal as my validation framework for an ASP.Net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.