Understanding the XML LIBNAME Engine Versions: XML and XMLV2

About the XML Engine Versions

SAS provides two versions of XML LIBNAME engine functionality by implementing engine nicknames in the LIBNAME statement.
  • By specifying the engine nickname XML, you access the SAS 9.1.3 XML engine functionality.
  • By specifying the engine nickname XMLV2, you access XML engine functionality with enhancements and changes after SAS 9.1.3. For example, the XMLV2 version provides enhanced LIBNAME statement functionality, new XMLMap functionality, and diagnostics of obsolete syntax.
The major differences between the versions include the following:
  • The XMLV2 version is XML compliant.
  • LIBNAME statement functionality for XMLV2 includes the XMLMAP markup type, additional options, and the ability to assign a libref to a SAS library.
  • XMLMap functionality for XMLV2 includes the ability to use an XMLMap for exporting and support for XML namespaces.

Comparing the XML Engine Versions: XMLV2 and XML

XML Compliance

The XMLV2 version is XML compliant, which means that XMLV2 requires XML markup to be well-formed and in valid construction that is in compliance with the W3C specifications. Because the XMLV2 version is XML compliant, using XMLV2 could affect the following situations:
  • XML documents that are imported with the XML version might not pass the more strict parsing rules in the XMLV2 version. For example, like XML markup, the XMLV2 version is case sensitive. Opening and closing tags must be written in the same case, such as <BODY> ...</BODY> and <Message>...</Message>. For the XMLV2 version, the tag <Letter> is different from the tag <letter>. Attribute names are also case sensitive, and the attribute value must be enclosed in quotation marks, such as <Note date="09/24/1975">.
  • XMLMap files that are accepted by the XML version might not work with the XMLV2 version. The XMLV2 version requires that XMLMap files be XML compliant, which means that the markup is case sensitive. In addition, the XMLMap markup must follow the specific XMLMap rules. Tag names must be uppercase. Element attributes must be lowercase. An example is <SXLEMAP version="2.1">. In addition, the supported XPath syntax is case sensitive.

XMLMap Files

The XML version supports all XMLMap files starting with XMLMap version 1.0. The XMLV2 version supports XMLMap files starting with XMLMap version 1.2. The documented XMLMap syntax version is 2.1. See XMLMap Syntax: Overview.

LIBNAME Statement Functionality Enhancements for XMLV2

The XMLV2 version provides the following LIBNAME statement functionality:
  • The ability to assign a libref to a SAS library, rather than assigning the libref to a specific XML document.
  • The XMLMAP markup type.
  • Additional options. For a list of the LIBNAME statement options that are available for the XML and XMLV2 nicknames, see LIBNAME Statement Options.
  • Using the XMLV2 nickname and the GENERIC markup type, you can export an XML document from multiple SAS data sets. For example, if you have two SAS data sets named Grades.Fred and Grades.Wilma, the following code exports an XML document named Grades.xml that includes the grades from both SAS data sets:
    libname stones xmlv2 'c:\Grades.xml';
    
    data stones.fred;
       set grades.fred;
    run;
    
    data stones.wilma;
       set grades.wilma;
    run;