Windows® Script Components are XML files and should follow the XML version 1.0 conventions for how elements are defined in the file. Although XML elements superficially resemble HTML tags, XML is a more strictly defined protocol. For example, element names are case-sensitive.

Abiding by XML Standards

To make it easier to create script components, the script component run-time (Scrobj.dll) allows you to specify how strictly you want the XML in your file to be interpreted. Script component XML can be interpreted fairly loosely, allowing the same sorts of variations in tags that HTML does.

However, you can also specify XML validation in your script component file, which causes the script component run-time to check that your script component file's XML conforms closely to the XML standard. If you will ever be using an XML editing tool to work with your script component, you should set XML validation.

When you specify XML validation, you must make sure that your script component file conforms to the following rules.

  • Element types and attribute names are case-sensitive. Element types and attributes names are usually all lowercase, except multipart names such as internalName. In XML files that conform closely to XML standards, all names must follow naming conventions exactly.

  • Attribute values require quotation marks. Values for attributes must be in single or double quotation marks. For example, without XML validation, you can specify language=JScript in a <script> element. But to follow XML rules, the same attribute would be language="JScript".

  • Reserved characters in script elements must be made opaque. Script elements frequently include greater than (<) and less than (>) symbols, the ampersand symbol (&), and other characters that are reserved in XML. If you are creating a closely conformant XML file, you must make sure that these reserved characters do not confuse the XML parser. You can individually mark characters with escape sequences (for example, specify "<" as "&lt;"), or you can make an entire script element opaque by enclosing it in a <![CDATA[ ...]]> section. Without XML validation, the script component XML parser treats <script> elements as opaque by default.


    Do not include a CDATA section in script if you have not specified closely conformant XML parsing. If you do, the script component will report errors when you try to register, instantiate, or call it.

For more details about XML standards, see the XML specification Web site and the Microsoft® XML Web site.

To specify XML conformance

  • Include the <?XML ?> declaration as the first element in your file:

    CopyCode imageCopy Code
    <?XML version="1.0" ?>

    If you create a script component using the Script Component Wizard, the <?XML?> declaration is added to the file, and the script component's XML is parsed strictly.

If this element is missing, the script component run-time assumes that you do not want XML validation. However, you will probably not be able to work with the file using an XML editor.

See Also