Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Output is broken #23

Closed
ArsMasiuk opened this issue Jun 16, 2020 · 3 comments
Closed

XML Output is broken #23

ArsMasiuk opened this issue Jun 16, 2020 · 3 comments

Comments

@ArsMasiuk
Copy link
Contributor

ArsMasiuk commented Jun 16, 2020

There are no xml heading tags written into output.xml.
I'm suggesting the following change in Duplo.cpp in order to fix the issue:

@@ -350,6 +350,14 @@
     }
 
     std::cout << "Loading and hashing files ... " << std::flush;
+
+    if (options.GetOutputXml()) {
+        outfile
+            << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+            << std::endl
+            << "<duplo>"
+            << std::endl;
+    }
 
     auto lines = LoadFileList(options.GetListFilename());
     auto [sourceFiles, matrix, files, locsTotal] =

P.S. Thank you for the great software :)

@dlidstrom
Copy link
Owner

I am not sure the xml can be considered broken. Do you have an actual issue where the xml can’t be used as-is? Can you provide a screenshot perhaps?
I believe the xml is well-formed, see w3.org specification. Also, I don’t think I can specify utf-8, as there is no specific handling of text encoding. I could perhaps add the xml version though, if this helps resolve your issue.
Thanks for using Duplo and providing feedback!

@ArsMasiuk
Copy link
Contributor Author

Well, I mean the following issue: the xml output currently looks like:

  ...
   <set LineCount="21">
        <block SourceFile="..." StartLineNumber="267"/>
        <block SourceFile="..." StartLineNumber="222"/>
        <lines xml:space="preserve">
            <line Text="..."/>
               ...
            <line Text="..."/>
        </lines>
    </set>
   ...
</duplo>

So there is closing tag </duplo> at the very end, but there is no corresponding opening tag <duplo> at the beginning of the document. Therefore this xml cannot be read by some xml parsers.
The tag <?xml ... ?> would be also nice-to-have as it could be important for some of them.

@dlidstrom
Copy link
Owner

You are right! As you already have the fix, can you provide a PR? Without the encoding part:

<?xml version="1.0"?>
<duplo>

dlidstrom added a commit that referenced this issue Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants