XML Validation (.dtd or .xsd)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 08:09 AM
We have a requirement to validate the XML in a particular xml field against a DTD file (.dtd).
Is there any way to do this in ServiceNow? We could switch them to .xsd validation if there is an option for that, but .dtd would be preferred.
Thanks,
Justin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 08:24 AM
Hi
This doc should help you :
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:14 PM
Thanks Sundeep. Can you (or anyone here) verify that XmlDocument2 validates against a specified .dtd file? And if so, how do we get the result? (and resulting error message)
We have glide.xml.entity.whitelist.enabled property set to true, and to test, I am using a .dtd file that is also whitelisted by default. (http://java.sun.com/j2ee/dtds/application-client_1_2.dtd)
My test is validating the XML below, which should be considered invalid, because icon is specified multiple times, and the .dtd file does not allow that.
Both xmlDoc.parseXML() and xmlDoc.isValid() both return true.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application-client SYSTEM "http://java.sun.com/j2ee/dtds/application-client_1_2.dtd">
<application-client>
<icon>Icon 1</icon>
<icon>Icon 2</icon>
<icon>Icon 3</icon>
<icon>Icon 4</icon>
</application-client>