asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
431 stars 106 forks source link

Generating a Diagram with umlet fails #364

Closed MennerM closed 2 years ago

MennerM commented 2 years ago

I have created a diagram with umlet and include this in my adoc file:

[umlet, "diagrams/overview", png] ....

include::diagrams/overview.uxf[]

....

the command asciidoctor -r asciidoctor-diagram overview.adoc don't works. I get the following error:

asciidoctor: ERROR: overview.adoc: line 22: Failed to generate image: /usr/lib/jvm/java-11-openjdk-amd64/bin/java failed: 0 | ERROR | com.baselet.diagram.io.DiagramFileHandler - "Cannot open the file: /tmp/java20210812-31713-1r5hoie.uxf" org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 6; The processing instruction target matching "[xX][mM][lL]" is not allowed. at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204) at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1471) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPIData(XMLScanner.java:745) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanPIData(XMLDocumentFragmentScannerImpl.java:1049) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(XMLScanner.java:713) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:891) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1216) at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635) at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:324) at java.xml/javax.xml.parsers.SAXParser.parse(SAXParser.java:197) at com.baselet.diagram.io.DiagramFileHandler.doOpen(DiagramFileHandler.java:251) at com.baselet.diagram.DiagramHandler.(DiagramHandler.java:74) at com.baselet.diagram.DiagramHandler.(DiagramHandler.java:58) at com.baselet.control.Main.doConvert(Main.java:273) at com.baselet.control.Main.main(Main.java:179) Width (0) and height (0) cannot be <= 0

To fix this I have to delete the first line (<?xml version="1.0" encoding="UTF-8" standalone="no"?> ) of the uxf-File.

Is there another way? I don't want to edit every uxf file.

pepijnve commented 2 years ago

The diagram extension isn't really involved in any of this. It invokes UMLet as follows: java -jar <umlet.jar> -action=convert -format=<output format> -filename=<input filename> -output=<output filename>. For some reason it doesn't like your XML preamble; no idea why.

Could you attach one of your problematic uxf files? That should allow me to reproduce this problem locally and then I might be able to tell you more.

MennerM commented 2 years ago

example.tar.gz

If I use asciidoc-kroki to get a preview in eclipse from my asciidoc, everything works fine.

pepijnve commented 2 years ago

I made a reproduction setup with the following asciidoc document and that works fine for me; must be some environmental difference. Is your system configured with a non-utf8 locale perhaps?

= Foo
:umlet: /Users/pepijn/Downloads/Umlet/umlet.sh

== Bar

umlet::test.uxf[]
MennerM commented 2 years ago

If I take your example it also works at my site. My system is configured with utf8.

The difference is that I don't use :umlet: /Users/pepijn/Downloads/Umlet/umlet.sh

I have attached my asciidoc file for comparison:

= Overview

tbd

== Test

test    

[umlet, "diagrams/test", png]
....

include::diagrams/test.uxf[]

....
pepijnve commented 2 years ago

Aha that explains it. Drop the leading empty line before include:: and it should work fine. The execution model to keep in mind is that the extension will read the block contents as


include::diagrams/test.uxf[]

Then it will apply macro substitution on that so you get something like


<?xml ... ?>
<diagram program="umlet" version="14.3.0">
...
</diagram>

That then gets written out as such to a temp file, including the leading empty line, and that temp file is passed on to umlet. Umlet will then try to parse an XML file with a leading empty line before the XML prolog and that's causing the parsing error.

MennerM commented 2 years ago

Tanks. It is so simple when you know it