XML DTD Validator
Use the XML DTD Validator policy to validate a request against an XML Document Type Definition (DTD) schema. You can upload an XML DTD schema file in the Policy dialog as a valid Swagger XML document. If an invalid path or parameter or object is not defined in the DTD schema, the client receives a Schema Validation Failed
error.
Alternatively, you can use the specification that you upload to create an API.
Policy Execution Order
This XML DTD Validator policy executes after the request has been authenticated. You can use both the XML DTD and XML XSD policies concurrently as long as the schemas do not conflict.
Policy Settings
Expression Enabled Fields in API Policies
All expression enabled fields take expressions from the SnapLogic Expression Language and the API Policy Manager functions.
Parameter Name | Description | Default Value | Example |
---|---|---|---|
Label | Required. The name for the API policy. | XML DTD Validator | DTD Validator |
When this policy should be applied | An expression enabled field that determines the condition to be fulfilled for the API policy to execute. For example, if the value in this field is request.method == "POST", the API policy is executed only if the request method is a POST. | True | request.method == "POST" |
Edit DTD | Launches the XML editor which allows you to define XML. The editor loads an existing XML document if defined previously. The editor lets you save XML in SnapLogic's file system or import existing XML documents from it. | Empty XML file | <!ELEMENT bibliography (book+)>
<!ELEMENT book (title, author*, publisher?, year?, extraAttribute, content, section*)>
<!ATTLIST book ISBN CDATA #REQUIRED>
<!ATTLIST book price CDATA #IMPLIED>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT extraAttribute (#PCDATA)>
<!ELEMENT content (#PCDATA|extraAttribute)*>
<!ELEMENT section (title, content?, section*)> |
Hide/Render WhiteSpace: Formats XML with watermarked dots or plain white space between the characters. |
|
| |
Format Code: Formats text in XML |
|
| |
Status | Indicates whether the API policy is enabled or disabled. | Enabled | Disabled |
Usage Guidelines
Support for inline declared definitions
You can enter a schema by clicking Edit DTD to open the XML editor. If the editor is empty, the policy will evaluate the Document Type Definitions declared inline, as shown in the following example:
<?xml version="1.0"?>
<!DOCTYPE books [
<!ELEMENT books (book+)>
<!ELEMENT book (author, title, genre, price, pub_date, review+)>
<!ATTLIST book id CDATA #REQUIRED>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT genre (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT pub_date (#PCDATA)>
<!ELEMENT review (#PCDATA)>
]>
<books>
<book id="bk001">
<author>Famous Author</author>
<title>Computer Science</title>
<genre>Education</genre>
<price>100.00</price>
<pub_date>2000-10-01</pub_date>
<review>Test Review</review>
</book>
</books>
DTD Guidelines
The following guidelines apply DTD schemas entered into the editor and their HTTP clients making the request:
HTTP Clients are expected to provide a
<!DOCTYPE>
tag to indicate validation against Document Type Definitions. Without the tag, validation fails.The parameter just after
!DOCTYPE
is expected to be the same as the outermost tag in the XML. If not, validation fails.Externally referenced DTDs are declared with the following system callout:
SYSTEM "policy.dtd"
<!DOCTYPE outermost_object SYSTEM "external_reference.dtd">
is the standard callout format for specifying DTD validation against external references.For validation against the policy’s Document Type Definitions, HTTP clients are required to specify the
SYSTEM
declaration.As the API admin, you can instruct clients to use any
SYSTEM
parameter following the callout. Any value can be specified. See the"policy.dtd"
callout.Regardless of the value, the XML DTD Validator uses the definitions specified in the policy to validate external references.
<!DOCTYPE books SYSTEM "policy.dtd">
<books>
<book id="bk001">
...
</book>
</books>
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2024 SnapLogic, Inc.