IBM Support

Set namespace awareness explicitly to transform XML files with namespaces

Troubleshooting


Problem

To properly transform extensible markup language (XML) files with namespaces, the default extensible stylesheet language transformations (XSLT) transfomer, which is included with the IBM® implementation of the Java™ Platform, Standard Edition (Java SE) 6 Java runtime environment (JRE), requires namespace awareness. The IBM implementation of the Java SE 6 JRE requires that you set the namespace awareness explicitly. Prior to Java SE 6, namespace awareness was not required to perform XSL transformations. Thus, code that ran on JREs prior to Java SE 6 might not behave the same on IBM WebSphere® Application Server Version 7.0 products.

Symptom

The default XSLT transformer that is included with versions of the IBM JRE prior to Java SE 6 can perform XSL transformations using namespaces regardless of whether the XML document is namespace-aware. This capability did not comply with the Java API for XML Processing (JAXP) specification and therefore has been fixed in the XSL transformer implementation that is included with the IBM implementation of the Java SE 6 JRE.

However, code that worked on older JREs no longer behaves the same on WebSphere Application Server Version 7.0 products unless namespace awareness is set explicitly.

Resolving The Problem

To enable namespace awareness, use the setNamespaceAware(Boolean) method on the DocumentBuilderFactory instance.

The following example enables namespace awareness for a DocumentBuilderFactory instance:

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();

Related Information

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Java SDK","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0","Edition":"Base;Express;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21318088