Solved

How To View The Contents Of A Node

Posted on 2001-06-26
2
205 Views
Last Modified: 2008-02-01
I have retrieved a node using Oracle Business Components for Java's writeXML method, and I'd like to view its contents.

I have tried to append it to a document (so that I can use xmlOutput.output(document, System.out) to view the node) using appendChild(node), but I get this error:

org.apache.crimson.tree.DomEx: WRONG_DOCUMENT_ERR: That node doesn't belong in this document.

I have also tried to import the node using importNode(node, boolean) but I get this error:

java.lang.IllegalArgumentException: Node is not a rg.apache.crimson.tree implementation.

Lastly, I have tried this:

javax.xml.transform.dom.DOMSource domSource = new javax.xml.transform.dom.DOMSource(xmlNode);
javax.xml.transform.TransformerFactory txnfac = javax.xml.transform.TransformerFactory.newInstance();
File xslfile = new File("C:\\xml\\testoutput.xsl");
StreamSource xslsource = new StreamSource(xslfile);
javax.xml.transform.Transformer txn = txnfac.newTransformer(xslsource);
txn.transform(domSource, new StreamResult(new FileOutputStream("C:\\xml\\result.xml")));

but then I get this error:

java.lang.AbstractMethodError
void org.apache.xalan.transformer.TransformerImpl.transform(javax.xml.transform.Source, javax.xml.transform.Result)

Any help would be greatly appreciated.
0
Comment
Question by:janey88
2 Comments
 
LVL 10

Accepted Solution

by:
Yury_Delendik earned 75 total points
ID: 6227358
You can't use neither appendChild nor importNode.

Try
  javax.xml.transform.TransformerFactory txnfac = javax.xml.transform.TransformerFactory.newInstance();
  javax.xml.transform.Transformer txn = txnfac.newTransformer();
  txn.transform(new javax.xml.transform.dom.DOMSource(yourSourceNode), new javax.xml.transform.dom.DOMResult(yourParentNode));

{ and same }
javax.xml.transform.TransformerFactory.newInstance().newInstance().transform(new javax.xml.transform.dom.DOMSource(yourSourceNode), new javax.xml.transform.dom.DOMResult(yourParentNode));
0
 

Author Comment

by:janey88
ID: 6233751
I tried the code you posted, but there's still an Abstract Method Error.  Anyway, I found a new API that has a method that converts a node directly into a String.  But thanks for your response!  =)



0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CRM 2011 Ribbon Workbench vs RibbonDiffXml 44 344
Test ddwrt:UserLookup 1 67
ebay devID, appID, certID, userToken 2 51
PHP alternative to file_get_contents('php://input') 4 61
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question