xmlsquad / gsheet-to-xml

Given the url of a Google Sheet, this Symfony Console command fetches the Google Sheet and outputs it in the form of Xml.
Apache License 2.0
3 stars 1 forks source link

XML structure for empty elements #3

Closed zoka123 closed 6 years ago

zoka123 commented 6 years ago

XML sample is inconsistent when it comes to empty elements

<AdditionalKNumbers></AdditionalKNumbers> vs <PurposeOther />

Which syntax should be used for empty elements?

forikal-uk commented 6 years ago

Thanks for raising this.

I think it does not matter which method is used.

I believe that the <AdditionalKNumbers></AdditionalKNumbers> is the preferred method.

i.e "an empty open and close tag" and not using self-closing elements.

At some point we could refactor to encapsulate "the creation of empty elements" into a method. Then, if we need to change the strategy in an emergency we can do it in one place.

However, I agree the inconsistency can be confusing. So, I will update the XML to make this more consistent to avoid confusion in the future.

zoka123 commented 6 years ago

When XML is outputted there is param LIBXML_NOEMPTYTAG that does it, i.e. $dom->saveXML(null, LIBXML_NOEMPTYTAG);

If you want to change that behavior later simply omit the second param from the saveXML method

forikal-uk commented 6 years ago

Ok that is interesting. Thanks.