XSLT Document('') Function does not Return the Stylesheet (Doc ID 1337045.1)

Last updated on FEBRUARY 08, 2017

Applies to:

Oracle Database - Enterprise Edition - Version 11.1.0.7 and later
Information in this document applies to any platform.
***Checked for relevance on 12-Apr-2013***

Symptoms

When an empty string is passed to the XSLT Document() function it should parse the current stylesheet and return a single node, the root node of the stylesheet itself as stated in the W3C Standard (http://www.w3.org/TR/xslt#document).  So when running a transformer in the database using the following XSL with document(''):

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy-of select="document('')"/>
</xsl:template>
</xsl:stylesheet>

The stylesheet should be returned.  Instead we see either <doc/> or <doc><doc/>

Note the W3C Standard states:

12.1 Multiple Source Documents
Function: node-set document(object, node-set?)
...
Note that a zero-length URI reference is a reference to the
document relative to which the URI reference is being resolved;
thus document("") refers to the root node of the stylesheet; the tree
representation of the stylesheet is exactly the same as if the XML
document containing the stylesheet was the initial source document.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms