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 6150451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:36:50+00:00 2026-05-23T19:36:50+00:00

I’m looking for some advice and guidance for validating HR-XML. I’ve written come code

  • 0

I’m looking for some advice and guidance for validating HR-XML.

I’ve written come code to produce an XML file that “should” be correctly formatted as HR-XML but I want to validate it using code before writing it to disk.

Below is a code sample of my validation method and the validation error event handler

/// <summary>
/// Validate the populated XML
/// </summary>
/// <remarks>
/// The schema folder needs to be "HR-XML-3_0" which contains the "org_hr-xml" and "org_openapplications_platform" folders
/// </remarks>
/// <param name="schemaPath">The root path for the HR-XML XSD files for the xml to be validated against</param>
/// <returns>true if the xml is valid, else false</returns>
public bool Validate(string schemaPath)
{
    try
    {
        // Initalise the valid flag
        this.m_FormatValid = false;
        this.m_ValidationErrors.Clear();

        // Check if there is anything to output
        if (this.m_Root.HasElements == true)
        {
            // Validate that the root node has been populated correctly
            XDocument doc = new XDocument(m_Root);

            XmlSchemaSet schemas = new XmlSchemaSet();

            // Add the schemas in the specified folder to the schema set
            schemas.Add(XmlSchema.Read(new StreamReader(Path.Combine(schemaPath, @"org_hr-xml\3_0\Developer\BODs\RespondHRMasterData.xsd")), null));
            schemas.Add(XmlSchema.Read(new StreamReader(Path.Combine(schemaPath, @"org_openapplications_platform\1_1\Common\OAGi\Components\Meta.xsd")), null));

            // Set the valid flag to true prior to validation and let the event handler set it to false if it's not valid
            this.m_FormatValid = true;

            doc.Validate(schemas, HRXML_Validation_Error);
        }
        else
        {
            Log.WriteLine(Category.Info, "No HR-XML data to validate");
        }
    }
    catch (Exception ex)
    {
        this.m_FormatValid = false;
        Log.WriteLine(Category.Warning, "An error was detected whilst validating HR-XML data", ex);
    }

    return this.m_FormatValid;
}



/// <summary>
/// Event handler for XML validation errors
/// </summary>
void HRXML_Validation_Error(Object source, ValidationEventArgs args)
{
    // There is no need to worry about the severity of the validation as they should always be errors
    // The warning appears only to be triggered is no schema has been specified which shouyldn't be the case here

    // Output the message to the validation list
    this.m_ValidationErrors.Add( args.Message );

    //Set the Valid flag to false
    m_FormatValid = false;
}

I added the BOD for responding to HRMasrterData requests into the schema set but this generated an exception because of the imported schema referenced in the RespondHRMasterData.xsd file. The error was
Undefined complexType ‘http://www.openapplications.org/oagis/9:BusinessObjectDocumentType&#8217; is used as a base for complex type extension.

Adding the second file to the schema set resolved the first exception and gave this one.
Type ‘http://www.openapplications.org/oagis/9:NormalizedStringType&#8217; is not declared, or is not a simple type.

What I don’t what to do is add all the HR-XML schema files (unless I really have to) before I get to and “Actual” errors in the created file.

Am I on the right track or is there a better way of doing this?

Thanks.

  • 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-23T19:36:52+00:00Added an answer on May 23, 2026 at 7:36 pm

    The best way I found to validate the HR-XML was to add the node xsi:schemaLocation to the generated xml which points to the required BOD.

    It’s also possible to create an XML Spy project which has all the schema files referenced. If this is done, the schema location is not required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace

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.