Is it permissible to have XML attributes for newlines?

I know that in your XML attributes you can have new lines. But can you put each attribute on its own line?

 <maritalStatusCode code="M" displayName="Married" codeSystem="2.16.840.1.113883.5.2" codeSystemName="MaritalStatusCode"/> 

In Sublime, it appears as a non-closing tag . And when I try to parse it with something like jsdom, it breaks too. I tried this but have not yet found a definitive answer. If necessary, I can provide additional information about the document. I am not very good at all the intricacies of XML, so I may not have missed the relevant information.

+4
source share
2 answers

Yes, line breaks inside an XML element are absolutely beautiful.
Perhaps you are moving between Windows and Unix, and the difference in line breaks disables parsers?

+4
source

Looking at this BNF grammar for XML , it seems like newlines and carriage returns in a tag are fine. Tags can include a space ( S ), and the definition of a space includes 0xA and 0xD , which are respectively NL and CR.

XML generating tools can be more restrictive and still be correct in the sense that they generate valid XML, but XML accepting tools must accept line break tags.

+3
source

Source: https://habr.com/ru/post/1496416/


All Articles