DataONEorg / mnlite

Light weight read-only DataONE member node in Python Flask
Apache License 2.0
0 stars 0 forks source link

Written XML is not valid #25

Closed iannesbitt closed 1 year ago

iannesbitt commented 1 year ago

Written XML string must be changed according the following:

-<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ns2:person xmlns:ns2=\"http://ns.dataone.org/service/types/v1\"><subject>http://orcid.org/0000-0001-5828-6070</subject><givenName>Ian</givenName><familyName>Nesbitt</familyName><verified>false</verified></ns2:person>
+<?xml version="1.0" encoding="utf-8"?><ns2:person xmlns:ns2="http://ns.dataone.org/service/types/v1"><subject>http://orcid.org/0000-0001-5828-6070</subject><givenName>Ian</givenName><familyName>Nesbitt</familyName><verified>false</verified></ns2:person>
mbjones commented 1 year ago

@iannesbitt that escaping was probably because the XML was being sent via a shell script and curl. As you move the work over to Python, building the XML object from a string is not a very robust way of handling it. I think it would be better to use the core pyxb types that we have in our core d1_python library, such as the Subject class, which knows how to serialize and deserialize instances with proper escaping into XML. This will prevent problems down the line if the data you are putting in the subject fields contains characters that need to be escaped in the XML serialization.

iannesbitt commented 1 year ago

Changes have been made but will soon be obsoleted by #26