I realise that it's not elegant or desired, but is it allowed (in well-formed XML) for an attribute value in an XML element to span multiple lines?
e.g.
<some-xml-element value="this value goes over.... multiple lines!" /> Yeah I realise there's better ways of writing that. I would personally write it like:
<some-xml-element> <value>this value goes over... multiple lines!</value> </some-xml-element> or:
<some-xml-element value="this value goes over.... " /> But we have our own XML parser and I'd like to know whether the first example is allowed in well-formed XML.
XML does not require a specific form of line break, so you can use whatever is convenient (carriage return, linefeed, or a combination) when creating an XML file. XML parsers will do the right thing largely because they're parsing on tags, not records - so whatever line break you're using is just whitespace to XML.
use <br/> ; or.
The default value of the xml:space attribute is the literal value "default" . For the value "default" , or if xml:space is not indicated at all, the behavior of significant white-space parsing is the default handling, as defined in the topic White-space processing in XAML.
Some special characters are not permitted in XML attribute values. Note that the ampersand (&) and less-than (<) characters are not permitted in XML attribute values.
http://www.w3.org/TR/REC-xml/#NT-AttValue
Seems to say everything except <, &, and your delimiter (' or ") are OK. So newline should be, too.
It is allowed, however according to W3C recommendation your XML parser should normalize the all whitespace characters to space (0x20) - so the output of your examples will differ (you should have new line on the output for " ", but only space in the first case).
http://www.w3.org/TR/1998/REC-xml-19980210#AVNormalize
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With