Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Export to Visio results in "An error occurred while parsing EntityName" (Read 8842 times)
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Export to Visio results in "An error occurred while parsing EntityName"
Aug 29th, 2012 at 3:02pm
Print Post  
Hi,

I am getting the above error when I attempt to export a diagram to Visio. I am able to do the same for other diagrams, so I suspect it might be data related.
However, this same diagram renders fine on the screen, plus I can also export it to PDF without any problems.

I have attached a zip file containing an XML export as well as a PDF export.

The complete error message:

"An error occurred while parsing EntityName. Line 1, position 746."

The relevant code is:

diagram = DiagramView1.Diagram;
MindFusion.Diagramming.Export.VisioExporter visio = new MindFusion.Diagramming.Export.VisioExporter();
visio.TemplatePath = Server.MapPath(@"~\Bin\visioExport.vxt");
visio.ExportLanes = ExportLanes.Horizontal;
visio.LaneGridTitle = Session["P_CFFD_CurrentActivityName"].ToString();

String filename = CleanFileName(Session["P_CFFD_CurrentActivityName"].ToString()) + " - " + DateTime.Now.ToString("ddMMMyyyy-HHmm-ss") + ".vdx";
visio.Export(diagram, Server.MapPath(@"~\ExternalDocs\") + filename);

Any ideas? This is a rather high priority issue for my customer.

Thanks in advance.

Jim
  

Export_To_Visio_Error.zip (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export to Visio results in "An error occurred while parsing EntityName"
Reply #1 - Aug 29th, 2012 at 5:21pm
Print Post  
Apparently the XmlElement.InsertAfter method used while exporting lane headers doesn't like the & symbols in some titles. For the time being you can work around that by temporarily replacing them with "&" before exporting. Ampersands in nodes' text work fine, it seems they use a different XML API method that escapes the & symbols internally.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Export to Visio results in "An error occurred while parsing EntityName"
Reply #2 - Aug 29th, 2012 at 6:02pm
Print Post  
Hi Stoyan,

Thanks for the prompt reply, but I've attached another PDF and XML export for a different diagram without any ampersands in the title that also fails when exporting to Visio.

Jim

  

Visio_Export_Issue_-_Sample2.zip (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export to Visio results in "An error occurred while parsing EntityName"
Reply #3 - Aug 29th, 2012 at 6:22pm
Print Post  
It still shows ampersands in the headers of the second and third lanes.
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Export to Visio results in "An error occurred while parsing EntityName"
Reply #4 - Aug 29th, 2012 at 8:20pm
Print Post  
Stoyan,

My mistake.  I was looking for ampersands in the title of the diagram (at the top); not in the lanes.
You are correct, removing them causes the export to work fine.
I'll attempt to replace them with & as you suggested.

Thanks once again.

Jim
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Export to Visio results in "An error occurred while parsing EntityName"
Reply #5 - Sep 10th, 2012 at 9:44pm
Print Post  
Hi Stoyan,

I am trying to replace the ampersands as you suggested.

Here's a bit of the relevant code:

roleName = roleName.Replace("&", "&");
grid.RowHeaders.Add(new Header(roleName));
Header swim1Header = grid.FindRow(roleName);
...

The only problem is that the lane headers now include the text & rather than just the &.

I have specified diagram.EnableStyledText = true;

Is there something else I have to do?

Thanks

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export to Visio results in "An error occurred while parsing EntityName"
Reply #6 - Sep 11th, 2012 at 7:05am
Print Post  
Hi Jim,

Create a copy of the actual diagram and replace the header ampersands there, then pass the copy to VisioExporter. You could use the serialization method to clone a diagram:

Code
Select All
Diagram Clone(Diagram d)
{
    Diagram c = new Diagram();
    c.LoadFromString(d.SaveToString());
    return c;
} 



I hope that helps,
Stoyan
« Last Edit: Sep 11th, 2012 at 10:17am by Stoyo »  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Export to Visio results in "An error occurred while parsing EntityName"
Reply #7 - Sep 11th, 2012 at 2:31pm
Print Post  
Hi Stoyan,

Forgive me, but I'm not quite getting this.

I tried the following without success:

protected Diagram fixAmpersands(Diagram oldDiag)
    {
        String s = oldDiag.SaveToString();
        s.Replace("&", "&");
        Diagram newDiag = new Diagram();
        newDiag.LoadFromString(s);
        return newDiag;
    }

How do I explicitly modify only the ampersands in the headers?

Thanks for you patience and assistance.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Export to Visio results in "An error occurred while parsing EntityName"
Reply #8 - Sep 11th, 2012 at 4:33pm
Print Post  
I meant you should replace the header titles in the cloned diagram:

Code
Select All
Diagram copy = Clone(oldDiag);
foreach (Header header in copy.LaneGrid.RowHeaders)
	header.Title = header.Title.Replace("&", "&");
foreach (Header header in copy.LaneGrid.ColumnHeaders)
	header.Title = header.Title.Replace("&", "&");
new VisioExporter().Export(copy, "..."); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jlj30
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 183
Joined: Sep 4th, 2011
Re: Export to Visio results in "An error occurred while parsing EntityName"
Reply #9 - Sep 11th, 2012 at 5:38pm
Print Post  
Stoyan,

Awesome and yet so simple - at least for you Smiley

Many thanks.  This is working fine now.

Jim
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint