MJLMills / rhorix

Python 3.3 Blender Add-On for Importing QCT Data
Other
1 stars 1 forks source link

Add .dtd for XML .top file #10

Closed MJLMills closed 7 years ago

MJLMills commented 9 years ago

The script does not currently check for a malformed input file. This can be achieved since .top is an XML format by defining a .dtd file and adding code to the add-on to check the input file against it.

MJLMills commented 8 years ago

_A .dtd file is outdated technology and a schema should be defined instead. See notes below. _ XML is a markup language used to represent data so that it can be easily shared among different kinds of applications that run on different operating systems.

It allows the definition of a hierarchy of objects, defining the parent-child relationships between them.

For the present case, this allows us to convert the abstractions described above into a generic filetype for quantum chemical topologies.

The data in the XML file is parsed to create the corresponding python objects.

A document type definition (.dtd) tells an application which markup tags a document uses and defines the structure of those tags. It gives the names and parent-child relationships of all tags, but does not tell the program what types of data to expect inside each tag. The DTD can however provide default values and a list of accepted values for a given tag.

<!ELEMENT # states that a declaration follows element_name # name of declared element (list of elements~ || #PCDATA) # is it a group of elements or parsed char data?

end the declaration

replace ~ with * for 0 to many, ? for 0 or 1, + for 1 to many, blank for exactly 1.

topology.dtd:

<?xml version=“1.0”?> #specify the XML version used <!ELEMENT topology (criticalpoint, atomic_interactionline)>

<!ELEMENT critical_point (vector, rank, signature)>
    <!ATTLIST critical_point label (CDATA) #REQUIRED>
    <!ELEMENT rank (#PCDATA)>
    <!ELEMENT signature (#PCDATA)>
    <!ELEMENT vector (x,y,z)>
    <!ELEMENT x (#PCDATA)>
    <!ELEMENT y (#PCDATA)>
    <!ELEMENT z (#PCDATA)>

<!ELEMENT gradient_path (vector+, A, B)>
<!ELEMENT interatomic_surface (gradient_path+,label)>
<!ELEMENT gradient_vector_field (gradient_path+)>

A minimal conforming file for H_2 is:

3 3 0.0 0.0 0.0 3 3 1.0 0.0 0.0 3 -1 0.5 0.0 0.0 H1<\A> H2<\B> 0.0 0.0 0.0<\vector> 0.2 0.0 0.0<\vector> 0.4 0.0 0.0<\vector> 0.6 0.0 0.0<\vector> 0.8 0.0 0.0<\vector> 1.0 0.0 0.0<\vector> 0.5 0.1 0.1 ... <\topology> The DTD can go at the top of a document or in a separate file. Use the latter and print comments -