Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic read tags from XML document (Read 3453 times)
tmtton
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 39
Joined: May 9th, 2008
read tags from XML document
Aug 1st, 2008 at 8:29pm
Print Post  
I have a XML document that contains tags serialized by the FlowChart.NET-based program. I need to retrieve the tag data from the JDiagram2-based program. The problem is that the deserializeTag method is never called.

public class SampleJavaClassName implements DiagramListener
{
  ...
  Diagram diagram = new Diagram();
  diagram.loadFromXml(xmlDocFileName);
  DiagramItemList diagramItemList = diagram.getItems();
  for (DiagramItem item : diagramItemList) {
     // want to retrieve the item's tag data here
     ...
  }

  public void deserializeTag(SerializeTagEvent evt) {
     Element element = evt.getTagElement();
     evt.setHandled(true);
     ...
  }
}

Thanks.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3440
Joined: Oct 19th, 2005
Re: read tags from XML document
Reply #1 - Aug 4th, 2008 at 8:28am
Print Post  
Can you see the tags saved in the XML file, in your own format? If you don't set e.Handled = true from the .NET SerializeTag handler, Flowchart.NET might be saving the Tag as a string or a value from a primitive type. In that case JDiagram would load it as a primitive type too, without calling the deserializeTag method.
  
Back to top
 
IP Logged
 
tmtton
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 39
Joined: May 9th, 2008
Re: read tags from XML document
Reply #2 - Aug 5th, 2008 at 3:03am
Print Post  
In the XML document, I have something like this (sample only).
<Tag>
MyNetPackage.MyTagClass;<?xml version="1.0" encoding="utf-16"?><MyTagClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ID>1234</ID></MyTagClass>
</Tag>

The .NET program serializes the tag of MyTagClass object type into the XML document. Each diagram node in the document has an associated tag. I want to deserialize the tag from the XML document into MyTagClass object so I can extract the data (e.g. ID=1234). I have an equivalent MyTagClass on the Java side. Any suggestion?

Another question: I have the following code.
Diagram diagram = new Diagram();
diagram.addDiagramListener(new DiagramAdapter() {
public void deserializeTag(SerializeTagEvent event) {
Element element = event.getTagElement();
event.setHandled(true);
Log.info("tag=" + element.getTextContent());
}
});
diagram.loadFromXml(myXmlDocFileName);

I see the deserializeTag events raised for all the nodes in the diagram upon loading the XML document, and getTextContent returns the content between the <tag> </tag> above. But all these events are fired one after another without telling me which tag associates with which node. How do I tell which node a particular deserializeTag event was raised for? I need to do additional processing for each node based on the tag data.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3440
Joined: Oct 19th, 2005
Re: read tags from XML document
Reply #3 - Aug 5th, 2008 at 9:08am
Print Post  
So deserializeTag is called in fact? Reading the tag data in Java should be symmetrical to how you write it in .NET. For example, if when writing you add two elements with text in them to the tag element, you should read the two elements and the text in them, using the Java DOM API, when reading.

Call event.getItem() to get the node for which the event is raised. The result is not strongly typed because deserializeTag might be called for the diagram, for diagram items, for cells, and for anchor points. Use the "instanceof" operator to know whether the event is raised to load a DiagramNode's tag.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint