This module contains helper functions for working with XML doctype declarations.
To use this module, you must import it to your DataWeave code, for example,
by adding the line import * from dw::xml::Dtd
to the header of your
DataWeave script.
Functions
docTypeAsString
docTypeAsString(docType: DocType): String
Transforms a DocType
value to a string representation.
Parameters
Name | Type | Description |
---|---|---|
docType |
DocType |
The |
Example
This example transforms a DocType
value that includes a systemId
to a string representation.
Source
1
2
3
4
5
%dw 2.0
import * from dw::xml::Dtd
output application/json
---
docTypeAsString({rootName: "cXML", systemId: "http://xml.cxml.org/schemas/cXML/1.2.014/cXML.dtd"})
Output
1
"cXML SYSTEM http://xml.cxml.org/schemas/cXML/1.2.014/cXML.dtd"
Example
This example transforms a DocType
value that includes a publicId
and systemId
to a string representation.
Source
1
2
3
4
5
%dw 2.0
import * from dw::xml::Dtd
output application/json
---
docTypeAsString({rootName: "html", publicId: "-//W3C//DTD XHTML 1.0 Transitional//EN", systemId: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"})
Output
1
"html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
Types
DocType
DataWeave type for representing a doctype declaration that is part of an XML file. Supports the following fields:
-
rootName
: Root element of the declaration. -
publicId
: Publicly available standard (optional). -
systemId
: Local URL (optional). -
internalSubset
: Internal DTD subset (optional).
1
{ rootName: String, publicId?: String, systemId?: String, internalSubset?: String }