Precice-config-visualizer

precice-config.xml (3.2 KB)
I try to analyze my configuration file with the tool

cat precice-config.xml | precice-config-visualizer | dot -Tpdf > config.pdf

But it gives some errors as follows:

  File "/home/michael/.local/bin/precice-config-visualizer", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/home/michael/config-visualizer/bin/precice-config-visualizer", line 237, in <module>
    main()
  File "/home/michael/config-visualizer/bin/precice-config-visualizer", line 230, in main
    xml = parseXML(args.infile.read())
  File "/home/michael/config-visualizer/bin/precice-config-visualizer", line 23, in parseXML
    return etree.fromstring(content, p)
  File "src/lxml/etree.pyx", line 3237, in lxml.etree.fromstring
  File "src/lxml/parser.pxi", line 1891, in lxml.etree._parseMemoryDocument
ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.

It works with the sample xml file. So I guess my installation is fine. What could be wrong with my xml file attached? I have deleted some comments and the header which should not cause the issues.

What version of the visualizer are you using? Did you freshly install it?

It just worked for me, but I have installed the config visualizer some time ago.

Alex,
Thank you for your testing! After your confirming, I found I made a silly mistake. I executed the command in a wrong directory which has no xml file. Now I get the same figure as you posted.

2 Likes

Great to hear that your problem is solved. I still find your error message interesting. If I call the config visualizer with a non-existing file I get a different error message:

$ cat filename-that-does-not-exist.xml | precice-config-visualizer
cat: filename-that-does-not-exist.xml: No such file or directory
Traceback (most recent call last):
  File "/home/jaustar/.local/bin/precice-config-visualizer", line 237, in <module>
    main()
  File "/home/jaustar/.local/bin/precice-config-visualizer", line 230, in main
    xml = parseXML(args.infile.read())
  File "/home/jaustar/.local/bin/precice-config-visualizer", line 23, in parseXML
    return etree.fromstring(content, p)
  File "src/lxml/etree.pyx", line 3235, in lxml.etree.fromstring
  File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseMemoryDocument
  File "src/lxml/parser.pxi", line 1757, in lxml.etree._parseDoc
  File "src/lxml/parser.pxi", line 1068, in lxml.etree._BaseParser._parseUnicodeDoc
  File "src/lxml/parser.pxi", line 601, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 711, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 640, in lxml.etree._raiseParseError
  File "<string>", line 1
lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1

I am a bit curious what happened in your case and whether we should open an issue in the GitHub repository of the visualizer.

You are right. If the file does not exist, cat will complain cat: precice-config1.xml: No such file or directory.

I am confused why I first got the error message and later I got it worked. Probably I did something which I was not aware of.

After some test, it seems everything is ok if there is no encoding="UTF-8 ? in my xml file.
<?xml version="1.0" encoding="UTF-8" ?>

Sorry for the confusion. I think the tool works well.

There is currently an open issue regarding this: Cannot process XML files formatted with our formatter · Issue #6 · precice/config-visualizer · GitHub

Thanks, @Makis. That explains the issue!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.