Free Support Forum - aspose.com

Supporting input and output

I am interested in this product and after reading the documentation I have noticed it does not support input and output data from anything other than Visio.

What I would like to do is:

  • produce network diagrams from data that I have stored locally, so maybe provide an input using XML and have this package generate a Visio diagram and allow users to export as Visio.

  • allow users to create diagrams and be able to store the data as XML or extract the data somehow to store locally.

@sharif.uddin1,

You can create a Visio drawing from scratch and include data from external sources. Kindly send us an XML sample and expected Visio drawing. We will investigate and share our findings with you. Please also refer to this help topic: Working with SolutionXML Elements

Here is a sample of my xml which i would like to turn it into a visio diagram or turn a visio diagram into xml in this format. I am using host ip or a network. I woudl liek to know how to create a flow from the xml tag src and dst

    <?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/xslt/user_commsmatrix.xsl"?>
<response>
  <header>
    <api_status>1</api_status>
    <api_response>success</api_response>
    <http_status>200</http_status>
    <http_response>ok</http_response>
    <format>xml</format>
    <error>false</error>
    <quiet>false</quiet>
    <metadata>
      <routing_analysis>on</routing_analysis>
      <service_id>3</service_id>
      <service>* Ad-hoc Submission</service>
      <comms_matrix_id>24</comms_matrix_id>
      <filename>QA test v1.xls</filename>
      <visible_lines>6</visible_lines>
      <security_flows>6</security_flows>
      <error_flows>0</error_flows>
      <security_permit>2</security_permit>
      <security_deny>0</security_deny>
      <security_exemption>4</security_exemption>
      <security_prevention>0</security_prevention>
      <routing_permit>1</routing_permit>
      <routing_deny>4</routing_deny>
      <routing_exemption>0</routing_exemption>
      <routing_prevention>0</routing_prevention>
      <frozen>1</frozen>
      <download_1>approved</download_1>
      <download_2>requires_analysis</download_2>
      <download_3>all</download_3>
      <link></link>
    </metadata>
    <aggregate>true</aggregate>
    <techops>true</techops>
    <servicedesign>true</servicedesign>
    <ccpProjectUser>true</ccpProjectUser>
    <user>UddinS2</user>
    <title>QA test v1.xls</title>
    <description>Comms matrix analysis results</description>
    <nav>
    </nav>
    <version>13</version>
    <server>1</server>
    <timestamp>1509701960</timestamp>
  </header>
  <body>
    <recordset>
      <flow>
        <id>159</id>
        <status>
          <option>To implement</option>
          <url>159</url>
        </status>
        <cmline>9</cmline>
        <src>10.0.0.1</src>
        <src_desc>server1</src_desc>
        <src_net>10.0.0.1/24</src_net>        
        <dst>192.168.1.1</dst>
        <dst_net>192.168.1.1/32</dst_net>
        <protocol>TCP</protocol>
        <ports>636</ports>
        <remarks>none</remarks>
        <environment>TEST</environment>
        <spa>Exemption</spa>
        <spn>Exemption  - Approved by x until Forever</spn>
        <rpa>Requires Analysis</rpa>
        <rpn>Flow requires further analysis to verify</rpn>
        <fpa>Permit</fpa>
        <fpn>Flow is permitted using an acceptable port</fpn>
        <remedy_inc></remedy_inc>
      </flow>
      <flow>
        <id>160</id>
        <status>
          <option>To implement</option>
          <url>160</url>
        </status>
        <cmline>10</cmline>
        <src>10.1.0.1</src>
        <src_desc>server2</src_desc>
        <src_net>10.1.0.0/24</src_net>
        <dst>192.168.1.1</dst>
        <dst_net>192.168.1.1/32</dst_net>
        <protocol>TCP</protocol>
        <ports>389</ports>
        <remarks>none</remarks>
        <environment>PROD</environment>
        <spa>Exemption</spa>
        <spn>Exemption  - Approved by x until Forever </spn>
        <rpa>Requires Analysis</rpa>
        <rpn>Flow requires further analysis to verify</rpn>
        <fpa>Permit</fpa>
        <fpn>Flow is permitted using an acceptable port</fpn>
        <remedy_inc></remedy_inc>
      </flow>
      <flow>
        <id>161</id>
        <status>
          <option>To implement</option>
          <url>161</url>
        </status>
        <cmline>11</cmline>
        <src>10.3.0.1</src>
        <src_desc>server3</src_desc>
        <src_net>10.1.0.0/24</src_net>
        <dst>192.168.1.1</dst>
        <dst_net>192.168.1.1/32</dst_net>
        <protocol>TCP</protocol>
        <ports>636</ports>
        <remarks>none</remarks>
        <environment>PRODSUPP</environment>
        <spa>Exemption</spa>
        <spn>Exemption - Approved by x until Forever </spn>
        <rpa>Requires Analysis</rpa>
        <rpn>Flow requires further analysis to verify</rpn>
        <fpa>Permit</fpa>
        <fpn>Flow is permitted using an acceptable port</fpn>
        <remedy_inc></remedy_inc>
      </flow>
      <flow>
        <id>162</id>
        <status>
          <option>To implement</option>
          <url>162</url>
        </status>
        <cmline>12</cmline>
        <src>10.78.0.1</src>
        <src_desc>server4</src_desc>
        <src_net>10.1.0.0/24</src_net>
        <dst>192.168.1.1</dst>
        <dst_net>192.168.1.1/32</dst_net>
        <protocol>TCP</protocol>
        <ports>389</ports>
        <remarks>none</remarks>
        <environment>WORKER</environment>
        <spa>Exemption</spa>
        <spn>Exemption - Approved by x until Forever </spn>
        <rpa>Requires Analysis</rpa>
        <rpn>Flow requires further analysis to verify</rpn>
        <fpa>Permit</fpa>
        <fpn>Flow is permitted using an acceptable port</fpn>
        <remedy_inc></remedy_inc>
      </flow>
      <flow>
        <id>163</id>
        <status>
          <option>To implement</option>
          <url>163</url>
        </status>
        <cmline>13</cmline>
        <src>10.1.0.1</src>
        <src_desc>server2</src_desc>
        <src_net>10.1.0.0/24</src_net>
        <dst>10.3.0.1</dst>
        <dst_desc>server3</dst_desc>
        <dst_net>10.1.0.0/24</dst_net>
        <protocol>TCP</protocol>
        <ports>22</ports>
        <remarks>none</remarks>
        <environment>PROD</environment>
        <spa>Permit</spa>
        <spn>Flow is permitted within the same security zone</spn>
        <rpa>Permit</rpa>
        <rpn>Flow is permitted within the same routing domain</rpn>
        <fpa>Permit</fpa>
        <fpn>Flow is permitted using an acceptable port</fpn>
        <remedy_inc></remedy_inc>
      </flow>
      <flow>
        <id>164</id>
        <status>
          <option>To implement</option>
          <url>164</url>
        </status>
        <cmline>14</cmline>
        <src>10.1.0.1</src>
        <src_desc>server2</src_desc>
        <src_net>10.1.0.0/24</src_net>
        <dst>192.168.5.1</dst>
        <dst_desc>server5</dst_desc>
        <dst_net>192.168.5.0/25</dst_net>
        <protocol>TCP</protocol>
        <ports>9605</ports>
        <remarks>none</remarks>
        <environment>PROD</environment>
        <spa>Permit</spa>
        <spn>Flow is permitted by the security zoning policy</spn>
        <rpa>Routing Ok</rpa>
        <rpn> Updated by x on 05-OCT-86 03.47.46.698496 PM</rpn>
        <fpa>Permit</fpa>
        <fpn>Flow is permitted using an acceptable port</fpn>
        <remedy_inc></remedy_inc>
      </flow>
      <routing_flow_summary>
        <id>1</id>
        <cm_lines>9</cm_lines>
        <routing_analysis>
          <url>?src=10.0.0.1&amp;dst=192.168.1.1</url>
          <row>9</row>
        </routing_analysis>
        <src_net>10.0.0.1/24</src_net>
        <dst_net>192.168.1.1/32</dst_net>
        <rpa>Requires Analysis</rpa>
        <rpn>Flow requires further analysis </rpn>
      </routing_flow_summary>
      <routing_flow_summary>
        <id>2</id>
        <cm_lines>13</cm_lines>
        <routing_analysis>
          <url>?src=10.1.0.1&amp;dst=10.3.0.1</url>
          <row>13</row>
        </routing_analysis>
        <src_net>10.1.0.0/24</src_net>
        <dst_net>10.1.0.0/24</dst_net>
        <rpa>Permit</rpa>
        <rpn>Flow is permitted within </rpn>
        <status></status>
        <notes></notes>
        <updated_by></updated_by>
      </routing_flow_summary>
      <routing_flow_summary>
        <id>3</id>
        <cm_lines>10,11,12</cm_lines>
        <routing_analysis>
          <url>?src=10.1.0.1&amp;dst=192.168.1.1</url>
          <row>10</row>
        </routing_analysis>
        <routing_analysis>
          <url>?src=10.3.0.1&amp;dst=192.168.1.1</url>
          <row>11</row>
        </routing_analysis>
        <routing_analysis>
          <url>?src=10.78.0.1&amp;dst=192.168.1.1</url>
          <row>12</row>
        </routing_analysis>
        <src_net>10.1.0.0/24</src_net>
        <dst_net>192.168.1.1/32</dst_net>
        <rpa>Requires Analysis</rpa>
        <rpn>Flow requires further analysis </rpn>
      </routing_flow_summary>
      <routing_flow_summary>
        <id>4</id>
        <cm_lines>14</cm_lines>
        <routing_analysis>
          <url>?src=10.1.0.1&amp;dst=192.168.5.1</url>
          <row>14</row>
        </routing_analysis>
        <src_net>10.1.0.0/24</src_net>
        <dst_net>192.168.5.0/25</dst_net>
        <rpa>Routing Ok</rpa>
        <rpn> Updated by x </rpn>
        <status></status>
        <notes></notes>
        <updated_by></updated_by>
      </routing_flow_summary>
    </recordset>
  </body>
</response>

@sharif.uddin1,

You can use System.Xml DLL reference (.NET framework) to retrieve data from the XML file, and then you may store XML keys and values into the Visio drawing in the form of SolutionXML elements. Aspose.Diagram API does not work with XML data files. Please take help from the Microsoft MSDN website and this is a simple help topic: View and Extract XML Data

I dont think you understood my question. I am trying to create a diagram using data I have. I can loop through my data but I cannot seem to insert the required shapes and connectors. Below is my code which only draws a single connector on the page.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ccp;

import com.aspose.diagram.Connection;
import com.aspose.diagram.Diagram;
import com.aspose.diagram.Page;
import com.aspose.diagram.SaveFileFormat;
import com.aspose.diagram.Shape;
import com.aspose.diagram.Txt;
import com.aspose.diagram.TypeValue;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.DOMException;
import org.xml.sax.SAXException;

/**
 *
 * @author UddinS2
 */
public class ReadXMLFile {

    public static void main(String argv[]) throws Exception {

        try {
            String dataDir = "C:\\Users\\Uddins2\\Documents\\aspose\\";
            File fXmlFile = new File(dataDir + "comms_matrix.xml");
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(fXmlFile);

            //optional, but recommended
            //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
            doc.getDocumentElement().normalize();

            System.out.println("Root element :" + doc.getDocumentElement().getNodeName());

            NodeList nList = doc.getElementsByTagName("flow");

            System.out.println("----------------------------");

            Flow[] flows;
            flows = new Flow[nList.getLength()];
            
            // initialize a new drawing
            Diagram diagram = new Diagram();
            // get page by index
            Page page = new Page();//diagram.getPages().get(0);
            diagram.getPages().add(page);
           // add masters
            String connectorMaster = "Connector";
            String router = "Router";
            int pageNumber = 0;
            diagram.addMaster(dataDir + "stencil\\Network Connectivity.vss", router);
            diagram.addMaster(dataDir + "stencil\\Network Connectivity.vss", connectorMaster);
            double x = 4.5;
            double y = 7;

            for (int temp = 0; temp < nList.getLength(); temp++) {

                Node nNode = nList.item(temp);

                System.out.println("\nCurrent Element :" + nNode.getNodeName());

                if (nNode.getNodeType() == Node.ELEMENT_NODE) {

                    Element eElement = (Element) nNode;
                    Flow currentflow = new Flow(eElement.getElementsByTagName("src").item(0).getTextContent(), eElement.getElementsByTagName("dst").item(0).getTextContent());
                    //System.out.println(x.getSrc());
                    //System.out.println(x.getDst());
                    flows[temp] = currentflow;
                    //System.out.println("src : " + eElement.getElementsByTagName("src").item(0).getTextContent());
                    //System.out.println("dst : " + eElement.getElementsByTagName("dst").item(0).getTextContent());
                    //System.out.println("Last Name : " + eElement.getElementsByTagName("lastname").item(0).getTextContent());
                    //System.out.println("Nick Name : " + eElement.getElementsByTagName("nickname").item(0).getTextContent());
                    //System.out.println("Salary : " + eElement.getElementsByTagName("salary").item(0).getTextContent());
                    
                    
                    // add shapes                    
                    long shape1_ID = diagram.addShape(x, y, router, pageNumber);
                    long shape2_ID = diagram.addShape(x+2.5, y+4.5, router, pageNumber);
                    //long shape3_ID = diagram.addShape(4.5, 4.5, router, pageNumber);
                    //long shape4_ID = diagram.addShape(6.75, 4.5, router, pageNumber);
                    // get shapes by ID
                    Shape shape1 = page.getShapes().getShape(shape1_ID);
                    Shape shape2 = page.getShapes().getShape(shape2_ID);
                    //Shape shape3 = page.getShapes().getShape(shape3_ID);
                    //Shape shape4 = page.getShapes().getShape(shape4_ID);
                    // add two more connection points
                    Connection connection1 = new Connection();
                    connection1.getX().getUfe().setF("Width*0.33");
                    connection1.getY().getUfe().setF("Height*0");
                    Connection connection3 = new Connection();
                    connection3.getX().getUfe().setF("Width*0.66");
                    connection3.getY().getUfe().setF("Height*0");
                    shape1.getConnections().add(connection1);
                    shape1.getConnections().add(connection3);

                    // add connector shapes
                    Shape connector1 = new Shape();
                    Shape connector2 = new Shape();
                    Shape connector3 = new Shape();
                    long connecter1Id = diagram.addShape(connector1, connectorMaster, 0);
                    long connecter2Id = diagram.addShape(connector2, connectorMaster, 0);
                    long connecter3Id = diagram.addShape(connector3, connectorMaster, 0);
                    // connect shapes by index of conneecting points
                    //page.connectShapesViaConnectorIndex(shape1.getID(), 6, shape2.getID(), 3, connecter1Id);
                    //page.connectShapesViaConnectorIndex(shape1.getID(), 1, shape3.getID(), 3, connecter2Id);
                    //page.connectShapesViaConnectorIndex(shape1.getID(), 7, shape4.getID(), 3, connecter3Id);

                }
            } //end of for loop
            // save drawing
            diagram.save(dataDir + "Drawing1_out.vsdx", SaveFileFormat.VSDX);
            
            System.out.println(flows.length);
        } catch (IOException e) {
        } catch (ParserConfigurationException e) {
        } catch (DOMException e) {
        } catch (SAXException e) {
        }
        
        
        
        /*
        String dataDir = "C:\\Users\\Uddins2\\Documents\\aspose\\";
        // load diagram
        Diagram diagram = new Diagram(dataDir + "CreateDiagram_Out.vsdx");
        // it calculates max page id
        int max = 0;
        if (diagram.getPages().getCount() != 0) {
            max = diagram.getPages().get(0).getID();
        }

        for (int i = 1; i < diagram.getPages().getCount(); i++) {
            if (max < diagram.getPages().get(i).getID()) {
                max = diagram.getPages().get(i).getID();
            }
        }

        // Initialize a new page object
        Page newPage = new Page();
        // Set name
        newPage.setName("new page");
        Page page = newPage;
        // Set page ID
        newPage.setID(max + 1);
        // Add a new blank page
        diagram.getPages().add(newPage);

        // Save diagram 
        diagram.save(dataDir + "InsertBlankPageInVisio_Out.vsdx", SaveFileFormat.VSDX);
        
        String masterName = "Router";
// Add master with stencil file path and master name
        diagram.addMaster(dataDir + "stencil\\Network Connectivity.vss", masterName);

// page indexing starts from 0
        int PageIndex = 1;
        double width = 2, height = 2, pinX = 4.25, pinY = 4.5;
//Add a new rectangle shape
        long rectangleId = diagram.addShape(pinX, pinY, width, height, masterName, PageIndex);
        
        // add masters
        String connectorMaster = "Dynamic connector", router = "Router";
        int pageNumber = 0;
        //double width = 2, height = 2, pinX = 4.25, pinY = 9.5;
        diagram.addMaster(dataDir + "stencil\\Network Connectivity.vss", router);
        // add shapes
        long shape1_ID = diagram.addShape(4.5, 7, router, 0);

// set shape properties 

        Shape rectangle = page.getShapes().getShape(rectangleId);
        rectangle.getXForm().getPinX().setValue(5);
        rectangle.getXForm().getPinY().setValue(5);
        rectangle.setType(TypeValue.SHAPE);
        rectangle.getText().getValue().add(new Txt("Aspose Diagram"));
        rectangle.setTextStyle(diagram.getStyleSheets().get(3));
        rectangle.getLine().getLineColor().setValue("#ff0000");
        rectangle.getLine().getLineWeight().setValue(0.03);
        rectangle.getLine().getRounding().setValue(0.1);
        rectangle.getFill().getFillBkgnd().setValue("#ff00ff");
        rectangle.getFill().getFillForegnd().setValue("#ebf8df");

        diagram.save(dataDir + "AddShape_Out.vsdx", SaveFileFormat.VSDX);
        System.out.println("Shape has been added.");

*/

    }
}

the stencil i am using contains the shapes

Router
Switch
Firewall
Load Balancer
LAN
Cloud
Server
Connector

It doesn’t seem to be adding my custom shapes in the stencil.

I managed to get the shape to appear using a different method of adding the stencil shape. im not sure how to correctly connect the the flows xR1 to xR2 using the connector, if you can please help with this.

   /*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ccp;

import com.aspose.diagram.Connection;
import com.aspose.diagram.Diagram;
import com.aspose.diagram.Page;
import com.aspose.diagram.SaveFileFormat;
import com.aspose.diagram.Shape;
import com.aspose.diagram.Txt;
import com.aspose.diagram.TypeValue;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.DOMException;
import org.xml.sax.SAXException;

/**
 *
 * @author UddinS2
 */
public class ReadXMLFile {

    public static void main(String argv[]) throws Exception {

        try {
            String dataDir = "C:\\Users\\Uddins2\\Documents\\aspose\\";
            File fXmlFile = new File(dataDir + "comms_matrix.xml");
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(fXmlFile);

            //optional, but recommended
            //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
            doc.getDocumentElement().normalize();

            System.out.println("Root element :" + doc.getDocumentElement().getNodeName());

            NodeList nList = doc.getElementsByTagName("flow");

            System.out.println("----------------------------");

            Flow[] flows;
            flows = new Flow[nList.getLength()];
            
            // initialize a new drawing
            Diagram diagram = new Diagram();
            
            // Set stencil file path
            //String templateFileName = dataDir + "stencil\\Network Connectivity.vss";
            //FileInputStream stream = new FileInputStream(templateFileName);
            // get page by index
            Page page = diagram.getPages().get(0);
            //diagram.getPages().add(page);
           // add masters
            String connectorMaster = "Connector";
            String router = "Router";
            //int pageNumber = 0;
            //diagram.addMaster(templateFileName, router);
            //diagram.addMaster(templateFileName, connectorMaster);
            
            // adds master to diagram from source diagram
            Diagram src = new Diagram(dataDir + "Network Connectivity.vdx");
            diagram.addMaster(src, router);
            diagram.addMaster(src, connectorMaster);

            double xR1 = 1.5;
            double xR2 = 4.5;
            double y = 1;

            for (int temp = 0; temp < nList.getLength(); temp++) {

                Node nNode = nList.item(temp);

                System.out.println("\nCurrent Element :" + nNode.getNodeName());

                if (nNode.getNodeType() == Node.ELEMENT_NODE) {

                    Element eElement = (Element) nNode;
                    Flow currentflow = new Flow(eElement.getElementsByTagName("src").item(0).getTextContent(), eElement.getElementsByTagName("dst").item(0).getTextContent());
                    //System.out.println(x.getSrc());
                    //System.out.println(x.getDst());
                    flows[temp] = currentflow;
                    //System.out.println("src : " + eElement.getElementsByTagName("src").item(0).getTextContent());
                    //System.out.println("dst : " + eElement.getElementsByTagName("dst").item(0).getTextContent());
                    //System.out.println("Last Name : " + eElement.getElementsByTagName("lastname").item(0).getTextContent());
                    //System.out.println("Nick Name : " + eElement.getElementsByTagName("nickname").item(0).getTextContent());
                    //System.out.println("Salary : " + eElement.getElementsByTagName("salary").item(0).getTextContent());
                    
                    
                    // add shapes    
                    Shape router1 = new Shape();
                    long router1Id = diagram.addShape(xR1, y, router, 0);
                    long router2Id = diagram.addShape(xR2, y, router, 0);
                    //long shape1_ID = diagram.addShape(x, y, router, pageNumber);
                    //System.out.println(shape1_ID);
                    //long shape2_ID = diagram.addShape(x+2.5, y+4.5, router, pageNumber);
                    //long shape3_ID = diagram.addShape(4.5, 4.5, router, pageNumber);
                    //long shape4_ID = diagram.addShape(6.75, 4.5, router, pageNumber);
                    // get shapes by ID
                    Shape shape1 = page.getShapes().getShape(router1Id);
                    Shape shape2 = page.getShapes().getShape(router2Id);
                    //Shape shape2 = page.getShapes().getShape(shape2_ID);
                    //System.out.println(shape1);
                    //Shape shape3 = page.getShapes().getShape(shape3_ID);
                    //Shape shape4 = page.getShapes().getShape(shape4_ID);
                    // add two more connection points
                    Connection connection1 = new Connection();
                    connection1.getX().getUfe().setF("Width*0.33");
                    connection1.getY().getUfe().setF("Height*0");
                    Connection connection3 = new Connection();
                    connection3.getX().getUfe().setF("Width*0.66");
                    connection3.getY().getUfe().setF("Height*0");
                    shape1.getConnections().add(connection1);
                    shape1.getConnections().add(connection3);

                    // add connector shapes                    
                    Shape connector1 = new Shape();
                    //Shape connector2 = new Shape();
                    //Shape connector3 = new Shape();                    
                    long connecter1Id = diagram.addShape(connector1, connectorMaster, 0);
                    //long connecter2Id = diagram.addShape(connector2, connectorMaster, 0);
                    //long connecter3Id = diagram.addShape(connector3, connectorMaster, 0);
                    // connect shapes by index of conneecting points
                    page.connectShapesViaConnectorIndex(shape1.getID(), 6, shape2.getID(), 3, connecter1Id);
                    //page.connectShapesViaConnectorIndex(shape1.getID(), 1, shape3.getID(), 3, connecter2Id);
                    //page.connectShapesViaConnectorIndex(shape1.getID(), 7, shape4.getID(), 3, connecter3Id);
                    //xR1 += 2;
                    //xR2 += 2;
                    y++;y++;
                }
            } //end of for loop
            // save drawing
            diagram.save(dataDir + "Drawing1_out.vsdx", SaveFileFormat.VSDX);
            
            System.out.println(flows.length);
        } catch (IOException e) {
        } catch (ParserConfigurationException e) {
        } catch (DOMException e) {
        } catch (SAXException e) {
        }

    }
}

error i get is

cd C:\Users\Uddins2\Downloads\Aspose.Diagram-for-Java-master\Examples; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_131" cmd /c "\"\"C:\\Program Files\\NetBeans 8.2\\java\\maven\\bin\\mvn.bat\" -Dexec.args=\"-classpath %classpath ccp.ReadXMLFile\" -Dexec.executable=\"C:\\Program Files\\Java\\jdk1.8.0_131\\bin\\java.exe\" -Dexec.classpathScope=runtime -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.2\\java\\maven-nblib\\netbeans-eventspy.jar\" org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...
                                                                        
------------------------------------------------------------------------
Building diagram-java-examples 1.0-SNAPSHOT
------------------------------------------------------------------------

--- exec-maven-plugin:1.2.1:exec (default-cli) @ diagram-java-examples ---
Root element :response
----------------------------

Current Element :flow
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: com.aspose.diagram.Page.connectShapesViaConnectorIndex
	at ccp.ReadXMLFile.main(ReadXMLFile.java:136)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 2.241s
Finished at: Tue Nov 07 17:22:24 GMT 2017
Final Memory: 5M/121M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project diagram-java-examples: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

@sharif.uddin1,

The Flow class is unknown, kindly share the complete class or assembly. We will investigate further and let you know about our findings. Your response is awaited.

@imran.rafique here is Flow class

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ccp;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author UddinS2
 */
@XmlRootElement
public class Flow {
    String src, dst;

    Flow(String src, String dst) {
        this.src = src;
        this.dst = dst;
    }
    
    
    public String getSrc(){
        return src;
    }
    
    @XmlElement
    public void setSrc(String text) {
        this.src = text;
    }
    
    public String getDst(){
        return dst;
    }
    
    @XmlElement
    public void setDst(String text) {
        this.dst = text;
    }
}

@sharif.uddin1,

We are unable to parse your XML and facing an error as The processing instruction target matching “[xX][mM][lL]” is not allowed. Kindly send us a Zip of XML and VDX drawing which you are using in the code.

i have put my code on git hub you can get the xml here https://github.com/shorif2000/aspose/tree/master/src/main/resources/xml

comms_matrix.zip (1.6 KB)

this is what i am able to create without connectors. i need to add connectors but it does not work
Drawing1_out.zip (14.0 KB)

i get error when i try to follow this example

Current Element :flow
com.aspose.diagram.Page@6c3708b3
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: com.aspose.diagram.Page.connectShapesViaConnectorIndex
	at ccp.ReadXMLFile.main(ReadXMLFile.java:120)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 2.020s
Finished at: Thu Nov 09 10:20:27 GMT 2017
Final Memory: 5M/121M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project diagram-java-examples: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

my latest code

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ccp;

import com.aspose.diagram.Connection;
import com.aspose.diagram.Diagram;
import com.aspose.diagram.Page;
import com.aspose.diagram.SaveFileFormat;
import com.aspose.diagram.Shape;
import com.aspose.diagram.Txt;
import com.aspose.diagram.TypeValue;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.DOMException;
import org.xml.sax.SAXException;


/**
 *
 * @author UddinS2
 */
public class ReadXMLFile {

    public static void main(String argv[]) throws Exception {

        try {
            String dataDir = "C:\\Users\\Uddins2\\Documents\\aspose\\";
            File fXmlFile = new File(dataDir + "comms_matrix.xml");
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(fXmlFile);

            //optional, but recommended
            //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
            doc.getDocumentElement().normalize();

            System.out.println("Root element :" + doc.getDocumentElement().getNodeName());

            NodeList nList = doc.getElementsByTagName("flow");
            Flow[] flows;
            flows = new Flow[nList.getLength()];
            
            // initialize a new drawing
            Diagram diagram = new Diagram();
            
            // get page by index
            Page page = diagram.getPages().get(0);
            
           
            String connectorMaster = "Connector";
            String router = "Router";
            int pageNumber = 0;
            int xR1 = 1;
            int xR2 = 4;
            double y = 1;
           
            // Set stencil file path
            //String templateFileName = dataDir + "stencil\\Network Connectivity.vss";
            //FileInputStream stream = new FileInputStream(templateFileName);
            // adds master to diagram from source diagram
            Diagram src = new Diagram(dataDir + "Network Connectivity.vdx");
            diagram.addMaster(src, router);
            diagram.addMaster(src, connectorMaster);

            

            for (int temp = 0; temp < nList.getLength(); temp++) {

                Node nNode = nList.item(temp);

                System.out.println("\nCurrent Element :" + nNode.getNodeName());

                if (nNode.getNodeType() == Node.ELEMENT_NODE) {

                    Element eElement = (Element) nNode;
                    Flow currentflow = new Flow(eElement.getElementsByTagName("src").item(0).getTextContent(), eElement.getElementsByTagName("dst").item(0).getTextContent());
                    flows[temp] = currentflow;
                    //System.out.println("src : " + eElement.getElementsByTagName("src").item(0).getTextContent());
                    //System.out.println("dst : " + eElement.getElementsByTagName("dst").item(0).getTextContent());
                    
                    // add shapes
                    long shape1_ID = diagram.addShape(xR1, y, router, pageNumber);
                    long shape2_ID = diagram.addShape(xR2, y, router, pageNumber);
                    
                    // get shapes by ID
                    Shape shape1 = page.getShapes().getShape(shape1_ID);
                    Shape shape2 = page.getShapes().getShape(shape2_ID);
                    
                    // add two more connection points
                    Connection connection1 = new Connection();
                    connection1.getX().getUfe().setF("Width*0.33");
                    connection1.getY().getUfe().setF("Height*0");
                    Connection connection3 = new Connection();
                    connection3.getX().getUfe().setF("Width*0.66");
                    connection3.getY().getUfe().setF("Height*0");
                    shape1.getConnections().add(connection1);
                    shape1.getConnections().add(connection3);

                    // add connector shapes
                    Shape connector1 = new Shape();
                    //Shape connector2 = new Shape();
                    //Shape connector3 = new Shape();
                    long connecter1Id = diagram.addShape(connector1, connectorMaster, 0);
                    //long connecter2Id = diagram.addShape(connector2, connectorMaster, 0);
                    //long connecter3Id = diagram.addShape(connector3, connectorMaster, 0);
                    // connect shapes by index of conneecting points
                    System.out.println(page);
                    page.connectShapesViaConnectorIndex(shape1, xR1, shape2, xR2, connecter1Id);
                    //page.connectShapesViaConnectorIndex(shape1.getID(), 1, shape3.getID(), 3, connecter2Id);
                    //page.connectShapesViaConnectorIndex(shape1.getID(), 7, shape4.getID(), 3, connecter3Id);
                    
                    y++;y++;
                }
            } //end of for loop
            // save drawing
            diagram.save(dataDir + "Drawing1_out.vsdx", SaveFileFormat.VSDX);
            
            System.out.println(flows.length);
        } catch (IOException e) {
        } catch (ParserConfigurationException e) {
        } catch (DOMException e) {
        } catch (SAXException e) {
        }

    }
}

@sharif.uddin1,

In order to replicate your scenario in our environment, we require your source VDX drawing Network Connectivity.vdx which you are using in the code. Furthermore, we can see an evaluation watermark in your output VSDX drawing. Please note, the evaluation version can read only the first ten shapes of the first drawing page and also insert an evaluation watermark in the output documents.

You can get a 30 day temporary license from the purchase portal and its option is available in step 5. You will see a button with caption Get a Temp License in step 5 of the purchase portal. A temporary license is a time-restricted full license that lets you test every aspect of API before buying it. Please see how to apply license in the following help topic: Apply License to Aspose.Diagram for Java API

Network Connectivity.zip (141.6 KB)

So i have decreased the xml to have 2 rows so in theory there should only be 6 objects on the page. i still can’t figure out why this does not work page.connectShapesViaConnectorIndex(shape1, xR1, shape2, xR2, connecter1Id); even a copy paste from the example it throws error on that function.

@sharif.uddin1,

We managed to replicate the problem of not being able to connect shapes with connection point indexes. There is no connection point on the target shape and we have added a connection point, but it does not work. It has been logged under the ticket ID DIAGRAMJAVA-50566 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

@imran.rafique it is very important for us for this feature to be working - “be able to draw network diagrams”, if the custom shape does not work can you show me how to connect built in visio shapes with routers, switches, firewalls?

How soon can this bug be fixed, this product is very critical to our solution?

Can i as how would paid support work i have noticed your responses are out of office hours for us as we are based in UK?

Below is code using visio network shapes, i can’t seem to figure out why the connection does not connect together.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ccp;

import com.aspose.diagram.Connection;
import com.aspose.diagram.ConnectionPointPlace;
import com.aspose.diagram.Diagram;
import com.aspose.diagram.Page;
import com.aspose.diagram.SaveFileFormat;
import com.aspose.diagram.Shape;
import com.aspose.diagram.Txt;
import com.aspose.diagram.TypeValue;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.DOMException;
import org.xml.sax.SAXException;
import com.aspose.diagram.ConnectionPointPlace;
import com.aspose.diagram.Diagram;
import com.aspose.diagram.DiagramSaveOptions;
import com.aspose.diagram.Page;
import com.aspose.diagram.SaveFileFormat;
import com.aspose.diagram.Shape;
import com.aspose.diagram.examples.Utils;

/**
 *
 * @author UddinS2
 */
public class ReadXMLFile {

    public static void main(String argv[]) throws Exception {

        try {
            String dataDir = "C:\\Users\\Uddins2\\Documents\\aspose\\";
            File fXmlFile = new File(dataDir + "comms_matrix.xml");
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(fXmlFile);

            //optional, but recommended
            //read this - http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
            doc.getDocumentElement().normalize();

            System.out.println("Root element :" + doc.getDocumentElement().getNodeName());

            NodeList nList = doc.getElementsByTagName("flow");
            Flow[] flows;
            //flows = new Flow[nList.getLength()];
            
            // initialize a new drawing
            Diagram diagram = new Diagram();
            
            // get page by index
            Page page = diagram.getPages().get(0);
            
           
            String connectorMaster = "Dynamic connector";
            String router = "Router";
            String firewall = "Firewall";
            int pageNumber = 0;
            int xR1 = 1;
            int xR2 = 3;
            int xR3 = 5;
            double y = 1;
           
            // Set stencil file path
            //String templateFileName = dataDir + "stencil\\Network Connectivity.vss";
            //FileInputStream stream = new FileInputStream(templateFileName);
            // adds master to diagram from source diagram
            Diagram src = new Diagram(dataDir + "Example Diagram.vdx");
            diagram.addMaster(src, router);
            diagram.addMaster(src, firewall);
            diagram.addMaster(src, connectorMaster);

            

            String source;
            String destination;
            for (int temp = 0; temp < nList.getLength(); temp++) {

                Node nNode = nList.item(temp);

                System.out.println("\nCurrent Element :" + nNode.getNodeName());

                if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                    Element eElement = (Element) nNode;                    
                    source = eElement.getElementsByTagName("src").item(0).getTextContent();
                    destination = eElement.getElementsByTagName("dst").item(0).getTextContent();
                    
                    // add shapes
                    long shape1_ID = diagram.addShape(xR1, y, router, pageNumber);
                    long shape2_ID = diagram.addShape(xR2, y, firewall, pageNumber);
                    long shape3_ID = diagram.addShape(xR3, y, router, pageNumber);
                    
                    // get shapes by ID
                    Shape shape1 = page.getShapes().getShape(shape1_ID);
                    Shape shape2 = page.getShapes().getShape(shape2_ID);
                    Shape shape3 = page.getShapes().getShape(shape3_ID);                    
                    shape1.getText().getValue().add(new Txt(source));
                    shape3.getText().getValue().add(new Txt(destination));
                    
                    // add connector shapes
                    Shape connector1 = new Shape();
                    Shape connector2 = new Shape();
                    //Shape connector3 = new Shape();
                    long connecter1Id = diagram.addShape(connector1, connectorMaster, 0);
                    long connecter2Id = diagram.addShape(connector2, connectorMaster, 0);
                    //long connecter3Id = diagram.addShape(connector3, connectorMaster, 0);
                    // connect shapes by index of conneecting points
                    //System.out.println(page);
                    //System.out.println(shape1.getID());
                    //System.out.println(shape2.getID());
                    //System.out.println(connecter1Id);

                    page.connectShapesViaConnectorIndex(shape1_ID, ConnectionPointPlace.RIGHT, shape2_ID, ConnectionPointPlace.LEFT, connecter1Id);
                    page.connectShapesViaConnectorIndex(shape2_ID, ConnectionPointPlace.RIGHT, shape3_ID, ConnectionPointPlace.LEFT, connecter2Id);
                    //page.connectShapesViaConnectorIndex(shape1.getID(), xR1, shape2.getID(), xR2, connecter1Id);
                    //page.connectShapesViaConnectorIndex(shape1.getID(), 7, shape4.getID(), 3, connecter3Id);
                    //Connection connection1 = new Connection(); 
                    //shape1.Connections.Add(connection1); 
                    y++;y++;
                }
            } //end of for loop
            // save drawing
            DiagramSaveOptions options = new DiagramSaveOptions(SaveFileFormat.VSDX);
            options.setAutoFitPageToDrawingContent(false);
            diagram.save(dataDir + "Drawing2_out.vsdx", options);
            
            //System.out.println(flows.length);
        } catch (IOException e) {
        } catch (ParserConfigurationException e) {
        } catch (DOMException e) {
        } catch (SAXException e) {
        }

    }
}

out put in zip, you can see the connector just goes up and right even though up is not defined and the right does not connect.
Example Stencil.zip (264.1 KB)

@sharif.uddin1,

There is an error while parsing your XML data file. We have written a small code example to connect shapes and find that the connecting lines are invisible. When we open the output VSDX drawing in the Microsoft Visio application and slightly change the position of any shape, then the connecting lines are visible. This problem has been logged under the ticket ID DIAGRAMJAVA-50567 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

[Java]

 String dataDir = "C:\\Diagram\\test2296\\";
 String stencil = dataDir + "Example Stencil.vss";
 int pageNumber = 0;
 int xR1 = 1;
 int xR2 = 3;
 int xR3 = 5;
 double y = 1;
 String connectorMaster = "Dynamic connector";
 String router = "Router";
 String firewall = "Firewall";
         
 // adds master to diagram from source diagram
 Diagram diagram = new Diagram();
 diagram.addMaster(stencil, router);
 diagram.addMaster(stencil, firewall);
 diagram.addMaster(dataDir + "Basic Shapes.vss", connectorMaster);
        
 // add shapes
 long shape1_ID = diagram.addShape(xR1, y, router, pageNumber);
 long shape2_ID = diagram.addShape(xR2, y, firewall, pageNumber);
 long shape3_ID = diagram.addShape(xR3, y, router, pageNumber);
        
 // add connector shapes
 Shape connector1 = new Shape();
 Shape connector2 = new Shape();
 long connecter1Id = diagram.addShape(connector1, connectorMaster, 0);
 long connecter2Id = diagram.addShape(connector2, connectorMaster, 0);
        
 diagram.getPages().get(0).connectShapesViaConnector(shape1_ID, ConnectionPointPlace.CENTER, shape2_ID, ConnectionPointPlace.CENTER, connecter1Id);
 diagram.getPages().get(0).connectShapesViaConnector(shape2_ID, ConnectionPointPlace.CENTER, shape3_ID, ConnectionPointPlace.CENTER, connecter2Id);
        
        
 DiagramSaveOptions options = new DiagramSaveOptions(SaveFileFormat.VSDX);
 options.setAutoFitPageToDrawingContent(false);
 diagram.save(dataDir + "Output13.vsdx", options);

The linked ticket Ids have just been identified. Our product team will investigate as per their development schedules. We will let you know once a significant progress has been made in this regard. We recommend our clients to post each their critical issue in the paid support forum.

@sharif.uddin1,

The linked ticket ID DIAGRAMJAVA-50567 has been resolved. Please download and try the latest version 17.11 of Aspose.Diagram for Java API.

The linked ticket ID DIAGRAMJAVA-50566 has been resolved and will be included in the next version 17.12 of Aspose.Diagram for Java API. We will notify you once the next version is published.

@imran.rafique any update on the next release?

@sharif.uddin1,

The next version 17.12 of Aspose.Diagram for Java API will be published in the middle of next month. We will let you know once it is available for download.

@sharif.uddin1,

The linked ticket ID DIAGRAMJAVA-50566 has been fixed. Please download and try the latest Hotfix version: Aspose.Diagram for Java 17.11.1, and then let us know how that goes into your environment.