Detection Settings - Identify XML File Type by Content

Multiple XML file types can have the same file name extension (typically .xml). SDL file support software distinguishes between these file types by matching the contents of the file with detection settings for the file type. A simple example of a detection setting is the root element required for a specific XML file type. You can specify detection settings in the Detection page of the XML file type settings.

The Detection page allows you to use any combination of the following XML items to identify a file type:
Root elements
One or more names used for the root element, for example my_root.
DOCTYPE declaration
For example:
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
xsi:schemaLocation
A URL used to specify the schema location. This matches schemaLocation or no NamespaceSchemaLocation attribute in the file.
xmlns: declaration
One or more namespace URLs.
XPath rules
One or more XPath rules.

Example - Specifying a root element

To specify a root element use the element name (no angle brackets), for example:
email
With this, the SDL file support software will match any XML file that has the root <email>, for example:
<email>
	<sendto> John Brown </sendto>
</email>

Example - Specifying a schemaLocation URL

If you provide a schemaLocation: http://www.sdl.com/xml/SdlExample.xsd, then the SDL file support software will match any XML file that uses either of the following schemaLocations:
xsi:schemaLocation="http://www.sdl.com/xml/SdlExample.xsd"
xsi:noNamespaceSchemaLocation="http://www.sdl.com/xml/SdlExample.xsd"

Example - Specifying a namespace URL

If you provide a namespace http://www.w3.org/1999/ xhtml, then the SDL file support software will match any XML file that includes <html xmlns="http://www.w3.org/1999/ xhtml">

Example - Specifying multiple root elements

If you specify two root elements, for example:
email
post
Then both the following XML files will match the new file type:
<email>
	 <sendto>Mary Brown</sendto>
</email>
<post>
	 <sendto>John Brown</sendto>
</post>

Example - Specifying any XML document

If you provide a root element name
*
(that is, an asterisk), any XML document will match this file type. Usually, if you have such a catch-all specification, you would position it at the bottom of the list of XML file types, so that more specific specifications take precedence.