dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #01961
Re: Version 0.6.0?
On Tue, Feb 14, 2006 at 07:31:29PM +0100, Johan Jansson wrote:
> On Mon, Feb 13, 2006 at 07:39:31PM -0600, Anders Logg wrote:
> ...
> > Maybe we can just move the writing of the header to the constructor
> > and the writing of the footer to the destructor of XMLFile?
>
> Hm, can we differentiate between reading and writing at that point?
No, I didn't think about that. How about two new (private) functions
in XMLFile: writeHeader() and writeFooter() and a bool
header_written and just implement as
void XMLFile::writeHeader()
{
if ( header_written )
return;
bla bla
header_written = true;
}
void XMLFile::writeFooter()
{
if ( !header_written )
return;
bla bla
}
All the output operators then just need to call writeHeader() and
writeFooter() is called by the destructor.
> >
> > > We can assume the incoming file is a valid DOLFIN XML file (by Schema
> > > validation). The schema doesn't exist yet, but it will eventually..
> >
> > I have never bothered to learn how to write a schema, but we do have
> >
> > <dolfin xmlns:dolfin="http://www.fenics.org/dolfin/">
> >
> > in the header and I suspect that is a reference to a schema? I don't
> > remember why I added this line but I vaguely remember I looked at the
> > XML format for an early version of Ko.
> >
> > /Anders
>
> The xmlns:dolfin="http://www.fenics.org/dolfin/" attribute is the
> namespace. A schema is defined with an attribute:
> xsi:schemaLocation="http://mydatatypes.edu/ex2.xsd". I'm still a bit
> unclear about XML namespaces though (and why they are usually URLs), I
> need to read up on it.
>
> A schema (ex2.xsd is the filename of the schema above) is just an XML
> file describing the data types in the file and their allowed semantics
> (allowed value ranges etc.).
>
> You define elements:
>
> <xs:element name="pointmass" type ="pointmassType"/>
> <xs:element name="radius" type="realType"/>
> <xs:element name="position" type="vectorType"/>
> <xs:element name="name" type="xs:string"/>
>
> and data types:
>
> <xs:complexType name="pointmassType">
> <xs:sequence>
> <xs:element ref="name" minOccurs="1" maxOccurs="1"/>
> <xs:element ref="position" minOccurs="0" maxOccurs="1"/>
> <xs:element ref="radius" minOccurs="0" maxOccurs="1"/>
> </xs:sequence>
> </xs:complexType>
>
> It's just a simple information description language. It would be nice
> to be able to generate source code from a schema (the data types will
> exist as source code as well, normally with the same semantics), but I
> don't think this is possible right now.
ok. Do you know if libxml2 has a function you can call to verify against a
schema before parsing (without first building the DOM tree which may
not fit in memory)?
/Anders
Follow ups
References
-
Re: Version 0.6.0?
From: Johan Jansson, 2006-02-13
-
Re: Version 0.6.0?
From: Garth N. Wells, 2006-02-13
-
Re: Version 0.6.0?
From: Anders Logg, 2006-02-13
-
Re: Version 0.6.0?
From: Garth N. Wells, 2006-02-13
-
Re: Version 0.6.0?
From: Anders Logg, 2006-02-13
-
Re: Version 0.6.0?
From: Garth N. Wells, 2006-02-13
-
Re: Version 0.6.0?
From: Anders Logg, 2006-02-13
-
Re: Version 0.6.0?
From: Johan Jansson, 2006-02-13
-
Re: Version 0.6.0?
From: Anders Logg, 2006-02-14
-
Re: Version 0.6.0?
From: Johan Jansson, 2006-02-14