web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Validate XML against XSD located in a web

(0) ShareShare
ReportReport
Posted on by 350

I have an XML file that points to its XSD located on a web server.

 

<order xsi:noNamespaceSchemaLocation="http://something.somewhere.com>

 

In AXv3, validation was simple -- xmlDoc = XMLDocument::newXML(xml, true, true)

 

Although XMLDocument::newXML in AX 2009 still has a parameter for validation, it does not appear to work. No error, no warning, nothing when I step on some values.

 

What is the trick in AX 2009 for validating XML against an XSD housed in a web when the XSD is referenced in the XML?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Denis Patrakov Profile Picture
    on at

    I'm afraid  in AX 2009 to validate an XML file against its XSD you'll have to load the schema by yourself. You can use XmlReader to validate an XML file - see \Classes\AifRequestProcessor\validateParameterSchema for an example:

    
    XmlTextReader xmlReader = XmlTextReader::newXml(xmlText);
    XmlSchemaValidationError xmlError = xmlReader.validate(xsdText);
    if (xmlError) // ...

     

  • ACO Profile Picture
    350 on at

    Not quite what I was looking for.  I ended up pulling the expected attribute (xsi:noNamespaceSchemaLocation) from the XML and using XMLSchema.sourceUri() to retrieve it:

     

    xmlReader.moveToAttribute2("xsi:noNamespaceSchemaLocation");
    tempStr = xmlReader.value();
    if (tempStr)
        xmlSchema.sourceUri(tempStr);

     

    Still running into trouble though. I have verified that xmlSchema contains the schema using:

     

    tempStr = xmlSchema.writeToString();

     

    But when I call:

     

    validationError = xmlReader.validate(xmlSchema.writeToString());

     

    I constantly get the error: "The 'myroot' element is not declared." where 'myroot' is the name of the outermost element in the XML.

     

    Any ideas on how to resolve or at least debug this?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans