Skip to content

Commit

Permalink
editor: improve author xml detection
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalEgn authored and drjova committed Aug 28, 2024
1 parent 166a262 commit 20b4325
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<collaborationauthorlist xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:cal="http://inspirehep.net/info/HepNames/tools/authors_xml/">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE collaborationauthorlist SYSTEM "authors.dtd">
<collaborationauthorlist xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:cal="http://inspirehep.net/info/HepNames/tools/authors_xml/">
<cal:creationDate>2022-01-25</cal:creationDate>

<cal:publicationReference>Fermilab-PUB-2022-01-25</cal:publicationReference>
Expand Down Expand Up @@ -34,4 +36,4 @@
</cal:authorIDs>
</foaf:Person>
</cal:authors>
</collaborationauthorlist>
</collaborationauthorlist>
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ export class AuthorExtractActionsComponent {
if (isUrl) {
return 'url';
}

const isXml = this.source.startsWith('<collaborationauthorlist');
if (isXml) {
return 'xml';
}
return 'text';
const parser = new DOMParser();
const doc = parser.parseFromString(this.source, 'application/xml');
const errorNode = doc.querySelector('parsererror');
return !errorNode &&
doc.documentElement.nodeName === 'collaborationauthorlist'
? 'xml'
: 'text';
}
}

0 comments on commit 20b4325

Please sign in to comment.