[gmx-developers] libxml2

David van der Spoel spoel at xray.bmc.uu.se
Fri Nov 22 14:34:06 CET 2013


On 2013-11-22 06:04, Teemu Murtola wrote:
> One additional comment that I forgot yesterday:
>
>
> On Thu, Nov 21, 2013 at 10:08 PM, Teemu Murtola <teemu.murtola at gmail.com
> <mailto:teemu.murtola at gmail.com>> wrote:
>
>     On Mon, Nov 18, 2013 at 5:23 PM, Mark Abraham
>     <mark.j.abraham at gmail.com <mailto:mark.j.abraham at gmail.com>> wrote:
>
>         Looks like a good start! Thanks.
>
>         I'm not sure whether <gromacs
>         xmlns:gmx="http://www.gromacs.__org/schemas
>         <http://www.gromacs.org/schemas>"> should name a schema file, or
>         a place to look up a schema file. Does anyone know?
>
>
>     As Erik said, it's just a string with no direct semantics. And there
>     is no strict correspondence between schemas and namespaces, either.
>     I'm not an expert on this, but at least it is possible to have
>     multiple schemas that all declare parts of the same namespace, and
>     composite schemas created from these. A single schema can also
>     reference multiple namespaces (but must in such a case import
>     schemas for the other namespaces). And the location of the schema is
>     often declared using a separate attribute (xsi:schemaLocation, with
>     suitably defined xsi:), separately from the namespace. Don't know
>     exactly what kind of look-up rules different parsers use for the
>     schema locations.
>
>     If we want to publish the schemas on the web page, we also need to
>     consider versioning. What is going to happen if, say, Gromacs 6.0
>     needs to change these schemas somehow? If we just replace them on
>     the web page, earlier files are going to break. It's unrealistic to
>     assume that we can design something that is going to remain static
>     forever, in particular if we start from a corner like this instead
>     from a central concept like the topology representation.
>
>     For the units, I don't have a strong opinion, but do we really want
>     to implement a mini-language that we then must parse and validate to
>     be able to specify arbitrary units and arbitrary unit conversions,
>     and force the users to type them everywhere? One simple alternative
>     would be to just encode the expected unit in the name of the element.
>
>
> Is it a good idea to have a root-level <gromacs> element instead of
> starting directly with <sfactors>? The root element being in a
> Gromacs-specific namespace should be enough indication that this is a
> Gromacs file, and that <gromacs> element makes it difficult to use this
> file as part of a larger entity through inclusion, which at least Erik
> was suggesting. Also, if all files would have the same root element, it
> is somewhat difficult (but probably not impossible) to compose a schema
> for that element from parts that could be used independently. Similarly,
> extra code is needed to check that the file actually contains the
> expected subelement and/or extract the relevant element; we may need
> that code in the future anyways, though, if we want to allow composite
> XML files.
>
>         In the past I have seem XML files with namespace-specific
>         content like
>
>            <gmx:sfactors type="Fourier" force_field="any"
>         displaced_solvent="true" reference="">
>              <gmx:sfactor residue="ALA" atom="MW" type="1">
>
>         which I'm sure we'd like to avoid. Does David's suggestion
>         achieve that?
>
>
>     It doesn't. It declares that anything prefixed with gmx: is in the
>     given namespace, but doesn't actually use that prefix for anything.
>     If you want to declare that unqualified elements go into a specific
>     namespace, you need to use xmlns="…".
>
>
> Regards,
> Teemu
>
>

Draft schema below for you commenting pleasure. It seems it should be 
possible to make defined vector of N elements and reuse that but haven't 
found any info yet.

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="gromacs">
     <xs:complexType>
       <xs:attribute name="unit" type="xs:string">

       <xs:element name="scatteringFactors">
         <xs:complexType>
           <xs:sequence>
             <xs:attribute name="source"           type="xs:string"/>
             <xs:attribute name="type"             type="xs:string"/>
             <xs:attribute name="forceField"       type="xs:string"/>
             <xs:attribute name="displacedSolvent" type="xs:string"/>
             <xs:attribute name="reference"        type="xs:string"/>

             <xs:element name="scatteringFactor">
               <xs:complexType>
                 <xs:sequence>
                   <xs:attribute name="residue"    type="xs:string"/>
                   <xs:attribute name="atom"       type="xs:string"/>
                   <xs:attribute name="identifier" type="xs:string"/>
                   <xs:element name="a">
                     <xs:complexType>
                       <xs:sequence>
                         <xs:element type="xs:double" minOccurs="6" 
maxOccurs="6"/>
                       </xs:sequence>
                     </xs:complexType>
                   </xs:element>

                   <xs:element name="b">
                     <xs:complexType>
                       <xs:sequence>
                         <xs:element type="xs:double" minOccurs="5" 
maxOccurs="5"/>
                       </xs:sequence>
                     </xs:complexType>
                   </xs:element>

                   <xs:element name="p">
                     <xs:complexType>
                       <xs:sequence>
                         <xs:element type="xs:double" minOccurs="3" 
maxOccurs="3"/>
                       </xs:sequence>
                     </xs:complexType>
                   </xs:element>

                   <xs:element name="q">
                     <xs:complexType>
                       <xs:sequence>
                         <xs:element type="xs:double" minOccurs="2" 
maxOccurs="2"/>
                       </xs:sequence>
                     </xs:complexType>
                   </xs:element>

                 </xs:sequence>
               </xs:complexType>
             </xs:element>

           </xs:sequence>
         </xs:complexType>
       </xs:element>

     </xs:complexType>
   </xs:element>
</xs:schema>



-- 
David van der Spoel, Ph.D., Professor of Biology
Dept. of Cell & Molec. Biol., Uppsala University.
Box 596, 75124 Uppsala, Sweden. Phone:	+46184714205.
spoel at xray.bmc.uu.se    http://folding.bmc.uu.se


More information about the gromacs.org_gmx-developers mailing list