Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) problem with  flowChart.saveToXml(doc)   (Read 10667 times)
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
problem with  flowChart.saveToXml(doc)  
Feb 10th, 2009 at 5:14am
Print Post  
Hi,

   I am trying to save graph in Document using saveToXml().  My code look like

DocumentBuilderFactory   fact;
DocumentBuilder   bd ;
Document  doc;

try {
fact = DocumentBuilderFactory.newInstance();
       bd = fact.newDocumentBuilder();
doc = bd.newDocument(); 
}catch (ParserConfigurationException e){
   e.printStackTrace();
}

on a button click I am trying following;
diag.saveToXml(doc);

Now I am trying to print doc.toString() but it shows following string;
[#document: null]

I want the graph xml file for process purpose.
Where I am going wrong ?

Thank you
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: problem with  flowChart.saveToXml(doc) &n
Reply #1 - Feb 10th, 2009 at 9:39am
Print Post  
Hi,

   I need this to be solved soon, can you please suggest what to do ?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem with  flowChart.saveToXml(doc)  
Reply #2 - Feb 10th, 2009 at 10:03am
Print Post  
Can you see any exceptions printed in the console?
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: problem with  flowChart.saveToXml(doc) &n
Reply #3 - Feb 10th, 2009 at 10:17am
Print Post  
hi ,


    No exceptions, The doc.toString() prints following
[#document: null]
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem with  flowChart.saveToXml(doc)  
Reply #4 - Feb 10th, 2009 at 10:57am
Print Post  
This is how JDiagram saves XML files:

Code
Select All
// in the saveToXml(stream) method:
DocumentBuilder builder = XmlDom.createBuilder();
Document document = builder.newDocument();
saveToXml(document, includeUnalteredProperties);
XmlDom.saveDOM(document, new StreamResult(new OutputStreamWriter(stream, "UTF-16")));

the XmlDom.createBuilder method:
static DocumentBuilder createBuilder()
	throws XmlException
{
	try
	{
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		factory.setValidating(false);
		factory.setNamespaceAware(false);
		return factory.newDocumentBuilder();
	}
	catch (ParserConfigurationException ex)
	{
		throw new XmlException(ex);
	}
}
 



Try using the same xml properties in your code.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: problem with  flowChart.saveToXml(doc) &n
Reply #5 - Feb 10th, 2009 at 1:35pm
Print Post  
Hi,

I have tried with the same properties you have mentioned, then also same thing is happening.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem with  flowChart.saveToXml(doc)  
Reply #6 - Feb 10th, 2009 at 2:06pm
Print Post  
Are you sure doc.toString() should display anything different? I don't think it will return the XML markup for the whole document.
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: problem with  flowChart.saveToXml(doc) &n
Reply #7 - Feb 11th, 2009 at 5:23am
Print Post  
Hi,


   I am checking doc == null after   diag.saveToXml(doc); and found that it is null.

It means some thing is going wrong in saveToXml(doc) as XML dom is not saved in doc.

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem with  flowChart.saveToXml(doc)  
Reply #8 - Feb 11th, 2009 at 9:27am
Print Post  
There is no way for saveToXml to change its doc argument to null. More likely the doc variable is null even before that. Are you sure the code that instantiates the doc object has executed at the time your button click handler runs?
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: problem with  flowChart.saveToXml(doc) &n
Reply #9 - Feb 11th, 2009 at 10:05am
Print Post  
Hi,
   
   What i got from diag.saveToXml(document); method is that it takes a Document doc argument and saves graph in doc as DOM.

   I am doing simple thing as i had mentioned previously like creating a Document instance as following,
   
DocumentBuilderFactory  fact = DocumentBuilderFactory.newInstance();
   fact.setValidating(false);
   fact.setNamespaceAware(false);
DocumentBuilder bd = fact.newDocumentBuilder();
Document doc = bd.newDocument();

and now saving diagram DOM in it as following

diag.saveToXml(doc);

but processing doc shows its null. How?

What is going wrong I am not getting ?

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem with  flowChart.saveToXml(doc)  
Reply #10 - Feb 11th, 2009 at 10:51am
Print Post  
Is the doc variable null, just after calling bd.newDocument()? That is, comparing doc == null returns true?
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: problem with  flowChart.saveToXml(doc) &n
Reply #11 - Feb 11th, 2009 at 11:00am
Print Post  
hi,

   what  diag.saveToXml(doc); doing then
I am checking doc after diag.saveToXml(doc); statement.  So there should be xml dom in doc.



  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem with  flowChart.saveToXml(doc)  
Reply #12 - Feb 11th, 2009 at 11:20am
Print Post  
Why have you decided there aren't any elements in the document? Use the XML API to check if there is anything there, instead of just calling toString(). Document.toString() might be the default implementation from Object, and would not return the full XML markup in that case.
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: problem with  flowChart.saveToXml(doc) &n
Reply #13 - Feb 11th, 2009 at 12:01pm
Print Post  
Hi,
   Ohh.. sorry I had not mentioned but i have also checked it using following ;
doc.hasChildNodes()
doc.getFirstChild()

   But it shows same thing.
  
Back to top
 
IP Logged
 
jay
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 59
Joined: Feb 4th, 2009
Re: problem with  flowChart.saveToXml(doc) &n
Reply #14 - Feb 11th, 2009 at 12:27pm
Print Post  
Hi,

  One more thing that following works well,
  diag.saveToXml("c:\\temp.xml");


  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint