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

Announcements

News and Announcements icon
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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans