Stryder wrote:
> I'm trying to do something that should be simple. In Oracle 11g, I'm
> trying to write a Java stored procedure that applies an XSLT
> stylesheet to an XML document and returns it as type XMLType.
>
> Here's a snippet that shows the question...
>
> public static XMLType bwdtransform(oracle.sql.CLOB documentText)
> throws Exception {
> // ==============================
> // This works - oracle.xml.parser.v2.DOMParser parses the incoming
> CLOB into an
> // oracle.xml.parser.v2.XMLDocument
> // ==============================
> parser.parse(documentText.getCharacterStream());
> XMLDocument xmlDocument = (XMLDocument) parser.getDocument();
>
> // ==============================
> // This works - applies adopterXSLT, which is a
> oracle.xml.parser.v2.XSLStylesheet,
> // to the XMLDocument, returning an XMLDocumentFragment. It'd
> solve the problem
> // if this could return an XMLDocument, but it doesn't
> // ==============================
> XMLDocumentFragment xmlDocumentFragment = processor.processXSL
> (adopterXSLT, xmlDocument);
Does
XMLDocument doc = (XMLDocument)xmlDocumentFragment.getOwnerDocument( );
give you an object? Or is that null? If it is not null and is an empty
document then you could simply do
doc.appendChild(xmlDocumentFragment);
assuming your XSLT stylesheet does indeed create a document with a
single root element.
Or create a new document
XMLDocument doc = new XMLDocument();
and do
doc.appendChild(doc.adoptNode(xmlDocumentFragment) );
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/