obdurodon / dh_course

Digital Humanities course site
GNU General Public License v3.0
20 stars 6 forks source link

Namespaces question #285

Closed AncientGreekGeek closed 4 years ago

AncientGreekGeek commented 5 years ago

I am still a little bit confused with the concept of namespaces. So, in the homework we only need to put the namespace element for the Schematron namespace, but not for any other namespace? Does the namespace just define which types of elements is used in the Schematron? E.g. TEI elements, xml elements, Schematron elements?

MJB288 commented 5 years ago

From what I understand of namespaces, they define the elements being used. In fact, from the little we've been presented, they're a bit like C++ namespaces in my opinion. Based on this, I could explain this a little. For an analogy, suppose there are two candy companies. Both sell generic chocolate bars, but both are made differently. Now suppose these companies both name their chocolate bars "chocolate", no unique name. Just saying chocolate does not identify which bar you want, you would have to specify X's chocolate, or Y's chocolate.

Namespaces do the same thing, it helps identify what kind of elements it should be looking for. They also prevent any ambiguity issues for the schematron. The XML equivalent of the above example is if there were two different namespaces that both have a <chocolate> element. If we allowed all namespaces at once, with no way of specifying them, the compiler would not know which to pick, and we would have to prevent this by a limit of one per name. Namespaces prevent this issue, by allowing different programmers who do not know each other to create elements of the same exact name with no conflicts. At least, that's how I understand it. Did I explain it well enough? I'd like to be cross-referenced by an instructor.

djbpitt commented 5 years ago

@Guifindor Yes, that’s exactly it!