You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by "Costello, Roger L." <co...@mitre.org> on 2019/04/10 12:34:03 UTC

Which way of hiding a CSV header is better?

Hello DFDL community,

I have a comma-separated value (CSV) file that contains a header followed by rows:

[cid:image001.png@01D4EF78.2602F8F0]

I do not want the header in the XML; I want it hidden.

Below are two ways to hide the header. The one on the left uses a bunch of xs:sequence elements, each containing dfdl:initiator. The one on the right uses a bunch of xs:elements. Which way is better?

[cid:image002.png@01D4EF78.2602F8F0]

Re: Which way of hiding a CSV header is better?

Posted by "Beckerle, Mike" <mb...@tresys.com>.
I prefer to use this technique:

<xs:sequence dfdl:initiator="Year,Make,Model,Description,Price%NL;">
    .... the schema for rows ...
</xs:sequence>

This way, if someone tries to parse a CSV file and the header row has been modified from what you expect, it will fail to parse in a very obvious way.

In some sense this string "Year,Make,Model,Description,Price%NL;" becomes like a signature or magic number for files of the right kind to match your CSV-like schema.


________________________________
From: Costello, Roger L. <co...@mitre.org>
Sent: Wednesday, April 10, 2019 8:34 AM
To: users@daffodil.apache.org
Subject: Which way of hiding a CSV header is better?


Hello DFDL community,



I have a comma-separated value (CSV) file that contains a header followed by rows:



[cid:image001.png@01D4EF78.2602F8F0]



I do not want the header in the XML; I want it hidden.



Below are two ways to hide the header. The one on the left uses a bunch of xs:sequence elements, each containing dfdl:initiator. The one on the right uses a bunch of xs:elements. Which way is better?



[cid:image002.png@01D4EF78.2602F8F0]