Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Oracle XSLProcessor returns an XMLDocumentFragment and I need anXMLDocument (or XMLType) (or even String)

Reply
Thread Tools

Oracle XSLProcessor returns an XMLDocumentFragment and I need anXMLDocument (or XMLType) (or even String)

 
 
Stryder
Guest
Posts: n/a
 
      04-16-2009
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);

// ==============================
// This DOES NOT work. XMLType requires an XMLDocument, not an
XMLDocumentFragment
// as its second parameter. I can find no way to translate an
XMLDocumentFragment into
// an XMLDocument, an XMLType, or even serialize it to a string.
// ==============================
return new XMLType(conn, xmlDocumentFragment);
}

Any help in returning the result of applying the stylesheet as an
XMLType would be very
very greatly appreciated.

Thanks.

Ralph
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      04-16-2009
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/
 
Reply With Quote
 
 
 
 
Stryder
Guest
Posts: n/a
 
      04-16-2009
On Apr 16, 1:36*pm, Martin Honnen <mahotr...@yahoo.de> wrote:
> 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/


The second option did it. Thank you thank you thank you.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU Usage frequently 100% even though it seems not even close tototal memory Newcomer Computer Support 3 11-15-2009 06:51 AM
Why my working ps/2 mouse freezes and even don't even get recon.after reboot ? demi General Computer Support 0 08-03-2007 05:30 AM
Why my working ps/2 mouse freezes and even don't even get recon.after reboot ? demi General Computer Support 0 08-03-2007 05:28 AM
install_driver(Oracle) failed: Can't load 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified procedure could not be found at C:/Perl/lib/DynaLoader.pm line 230. Feyruz Perl Misc 4 10-14-2005 06:47 PM
Even older fart, even newer newbie Stan Goodman Java 11 07-04-2003 07:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57