Changeset 2527

Show
Ignore:
Timestamp:
10/17/08 16:41:08 (3 months ago)
Author:
pataphil
Message:

NWB -> GraphML converter was not outputting any newlines in output XML.
Modified converter to output newlines appropriately to make XML more readable.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plugins/converter/edu.iu.nwb.converter.nwbgraphml/src/edu/iu/nwb/converter/nwbgraphml/NWBToGraphMLbyStax.java

    r2519 r2527  
    9898                        //write </graph></graphml> 
    9999                        try { 
    100                                 xtw.writeEndElement();   
    101                                 xtw.writeEndElement();           
     100                                xtw.writeEndElement(); 
     101                                xtw.writeCharacters("\r\n"); 
     102                                xtw.writeEndElement(); 
    102103                        } catch (Exception e) { 
    103104                                e.printStackTrace(); 
     
    127128        private void writeGraphMLHeader (XMLStreamWriter xtw) throws XMLStreamException{ 
    128129 
    129                 xtw.writeStartDocument("UTF-8","1.0");   
     130                xtw.writeStartDocument("UTF-8","1.0"); 
     131                xtw.writeCharacters("\r\n"); 
    130132                xtw.writeComment("This file is generated by XMLStreamWriter"); 
     133                xtw.writeCharacters("\r\n"); 
    131134                xtw.writeStartElement("graphml"); 
    132135                xtw.writeNamespace("", "http://graphml.graphdrawing.org/xmlns");  
     
    136139                                "schemaLocation",  
    137140                "http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"); 
     141                xtw.writeCharacters("\r\n"); 
    138142 
    139143        } 
     
    156160                        xtw.writeAttribute("attr.name", attr.getAttrName()); 
    157161                        xtw.writeAttribute("attr.type", getGraphmlType(attr)); 
    158                         xtw.writeEndElement();                 
     162                        xtw.writeEndElement(); 
     163                        xtw.writeCharacters("\r\n"); 
    159164                } 
    160165 
     
    175180                                xtw.writeAttribute("attr.name", attr.getAttrName()); 
    176181                                xtw.writeAttribute("attr.type", getGraphmlType(attr)); 
    177                                 xtw.writeEndElement();  
     182                                xtw.writeEndElement(); 
     183                                xtw.writeCharacters("\r\n"); 
    178184 
    179185                        } 
     
    198204                                xtw.writeAttribute("attr.type", attr.getDataType()); 
    199205                                xtw.writeEndElement(); 
     206                                xtw.writeCharacters("\r\n"); 
    200207                        } 
    201208                        xtw.writeStartElement("graph"); 
    202209                        xtw.writeAttribute("edgedefault", "undirected"); 
     210                        xtw.writeCharacters("\r\n"); 
    203211                } 
    204212                else if (validator.isDirectedGraph() && validator.isUndirectedGraph()){ 
     
    282290                                        xtw.writeStartElement("node"); 
    283291                                        xtw.writeAttribute("id", "n" + columns[0]); 
     292                                        xtw.writeCharacters("\r\n"); 
    284293 
    285294                                        for(int i = 1; i<nodeAttrList.size(); i++){ 
     
    300309                                                        xtw.writeStartElement("data"); 
    301310                                                        xtw.writeAttribute("key", attr.getAttrName().toLowerCase()); 
    302                                                         xtw.writeCharacters(value);  
    303                                                         xtw.writeEndElement();                                           
     311                                                        xtw.writeCharacters(value); 
     312                                                        xtw.writeEndElement();   
     313                                                        xtw.writeCharacters("\r\n"); 
    304314 
    305315                                                } else { 
     
    315325                                        //write </node> 
    316326                                        xtw.writeEndElement(); 
     327                                        xtw.writeCharacters("\r\n"); 
    317328 
    318329                                } 
     
    351362                                                        xtw.writeAttribute("source", "n" + columns[sourceColumnNumber]); 
    352363                                                        xtw.writeAttribute("target", "n" + columns[targetColumnNumber]); 
     364                                                        xtw.writeCharacters("\r\n"); 
    353365 
    354366                                                        for(int i = 0; i<edgeAttrList.size(); i++){ 
     
    373385                                                                                xtw.writeStartElement("data"); 
    374386                                                                                xtw.writeAttribute("key", attr.getAttrName().toLowerCase()); 
    375                                                                                 xtw.writeCharacters(value);  
     387                                                                                xtw.writeCharacters(value); 
    376388                                                                                xtw.writeEndElement(); 
     389                                                                                xtw.writeCharacters("\r\n"); 
    377390                                                                        } else { 
    378391                                                                                /* 
     
    386399                                                                } 
    387400                                                        } 
    388                                                         //write </edge>  
     401                                                        //write </edge> 
    389402                                                        xtw.writeEndElement(); 
     403                                                        xtw.writeCharacters("\r\n"); 
     404                                                         
    390405                                                }else{ 
    391406                                                        //out.println("<edge id=\""+edgeID+"\" source=\""+columns[sourceColumnNumber]+ 
     
    396411                                                        xtw.writeAttribute("target", "n" + columns[targetColumnNumber]); 
    397412                                                        xtw.writeEndElement(); 
     413                                                        xtw.writeCharacters("\r\n"); 
     414                                                         
    398415                                                } 
    399416                                        } 
     
    407424                                                        xtw.writeAttribute("source", "n" + columns[sourceColumnNumber]); 
    408425                                                        xtw.writeAttribute("target", "n" + columns[targetColumnNumber]); 
     426                                                        xtw.writeCharacters("\r\n"); 
    409427 
    410428                                                        for(int i = 0; i<edgeAttrList.size(); i++){ 
     
    421439                                                                                xtw.writeStartElement("data"); 
    422440                                                                                xtw.writeAttribute("key", attr.getAttrName().toLowerCase()); 
    423                                                                                 xtw.writeCharacters(columns[i]);  
     441                                                                                xtw.writeCharacters(columns[i]); 
    424442                                                                                xtw.writeEndElement(); 
     443                                                                                xtw.writeCharacters("\r\n"); 
     444                                                                                 
    425445                                                                        } else { 
    426446                                                                                /* 
     
    436456                                                        //out.println("</edge>");   
    437457                                                        xtw.writeEndElement(); 
     458                                                         
    438459                                                } 
    439460                                                else{ 
     
    446467                                                        xtw.writeAttribute("target", "n" + columns[targetColumnNumber]); 
    447468                                                        xtw.writeEndElement(); 
     469                                                        xtw.writeCharacters("\r\n"); 
     470                                                         
    448471                                                } 
    449472                                        }