0

私はこの例外を受けています:

javax.xml.stream.XMLStreamException: Attribute not associated with any element
    at com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.writeAttribute(Unknown Source)
    at de.dhbw.horb.routePlanner.parser.GraphDataParser$2.run(GraphDataParser.java:136)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)*

以下の私のコードから。私はそれがどこから来ているのか理解していません。

public void writeEdgeXML() throws XMLStreamException {

    final long[] idCount = new long[1];

    XMLOutputFactory factory = XMLOutputFactory.newInstance();

    try {
        final XMLStreamWriter writer = factory
                .createXMLStreamWriter(new FileOutputStream(
                        GraphDataConstants.CONST_XML_EDGE), "UTF-8");

        writer.writeStartDocument("UTF-8", "1.0");

        while (graphSR.hasNext()) {
            if (graphSR.nextStartElement() && graphSR.isWay()) {

                final Way nextWay = getWay(null);

                Controller.executor.getExecutor().submit(new Runnable() {

                    @Override
                    public void run() {

                        while (nextWay != null && nextWay.hasEdge()) {

                            try {
                                idCount[0]++;
                                Edge e = nextWay.removeFirstEdge();
                                writer.writeStartElement(GraphDataConstants.CONST_EDGE);
                                writer.writeAttribute(
                                        GraphDataConstants.CONST_EDGE_ID,
                                        String.valueOf(idCount[0]));
                                writer.writeEmptyElement(GraphDataConstants.CONST_EDGE_NODE);
                                writer.writeAttribute(
                                        GraphDataConstants.CONST_EDGE_ID,
                                        String.valueOf(e.getStartNode()
                                                .getID()));
                                writer.writeAttribute(
                                        GraphDataConstants.CONST_EDGE_LATITUDE,
                                        String.valueOf(e.getStartNode()
                                                .getLatitude()));
                                writer.writeAttribute(
                                        GraphDataConstants.CONST_EDGE_LONGITUDE,
                                        String.valueOf(e.getStartNode()
                                                .getLongitude()));                                  

                                writer.writeEndElement();
                                writer.flush();

                            } catch  (XMLStreamException e) {
                                   e.printStackTrace();
                            }

                        }
                    }
                });
            }
        }
4

1 に答える 1