XMLTRANSFORM appears to override indent="no" in xsl sheet
I am using Oracle Database 10g Enterprise Edition Release 10.2.0.1.0. I need to transform XML files stored as XDB resources to load then into Frame Maker 8.0. So I use
SELECT XMLTRANSFORM(l_xmldata, l_xsldata) INTO l_resultdata
FROM DUAL;
and store the l_resultdata also as a XDB resource.
I need to import these XML files into Frame Maker, which considers any whitespace from XML pretty printing (indenting) into WHITESPACE tags which causes formating problems. For example:
<body>
<h1>title</h1>
<p>some text</p>
<p>more text</p>
</body>
When imported into Frame, the space characters at the start of the lines are significant. If I remove all the leading spaces with an editor Frame maker is happy.
I had hoped, if I use a xsl sheet of the form below I would avoid indenting spaces:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:output indent="no"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
And if I test my XSLT transformations outside Oracle using other XSLT engines such as XALAN and Altova output XML do no contain any leading indenting spaces.
I then assumed the problem was simply with Oracle XMLTRANSFORM so I replaced it with a Jave stored procedure which used the Oracle JVM
javax.xml.transform.Transformer XSLT. The Java code worked as expected outside Oracle using files input / output but when I converted it to used CLOBs as input /output and put it into the Oracle JVM, my output XML became indented once more.
Is it possible the problem is more complex in that it is not the XSLT engine incorrectly serializing the XML, but some post formating when the XML is passed into a XMLTYPE or when the XMLTYPE is used to create a XBD resource.
I have moved a lot of XML records from SQL tables with XMLTYPE columns to XDB resources without seeing any reformating of the XML. The problem only appears when XSLT is involved. However I will next attempt to remove the XDB component from the equation and use a .Net program to pass in the XML and XSL content as input the the Oracle XSLT engine.
Any advice would be much appreciated. See a full sample of what I am trying to do below files are all located in XDB:
DECLARE
l_xmlfile VARCHAR2(128);
l_xslfile VARCHAR2(128);
l_resultfile VARCHAR2(128);
l_xmldata XMLTYPE;
l_xsldata XMLTYPE;
l_resultdata XMLTYPE;
l_ret BOOLEAN;
BEGIN
l_xmlfile := '&1';
l_xslfile := '&2';
l_resultfile := '&3';
SELECT XDBURIType(l_xmlfile).getXML()
INTO l_xmldata FROM DUAL;
SELECT XDBURIType(l_xslfile).getXML()
INTO l_xsldata FROM DUAL;
IF (DBMS_XDB.existsResource(l_resultfile)) THEN
DBMS_XDB.deleteResource(l_resultfile,
DBMS_XDB.DELETE_RESOURCE);
END IF;
SELECT XMLTRANSFORM(l_xmldata, l_xsldata) INTO l_resultdata
FROM DUAL;
l_ret := DBMS_XDB.createResource(l_resultfile, l_resultdata);
END;
/