I try to model a data definition language in XML. It can be seen as C
without any executable statements other than variable assignments. I
want to allow for:
(1) type declarations ("structs" in C), which can be nested, and where
each member can be (optionally) associated with
a) a comment (as a help to the user who will enter data) and
b) a unit such as kg, cm, etc.
(2)variable declarations of ordinary types such as float, int, string,
etc., as well as the types defined in (1), and
(3)assignments of values to variables.
Examples (in C-like syntax) would be:
(1)Type definitions:
struct Point {
float x, comment("X coordinate"), unit(m);
float y, comment("Y coordinate"), unit(m);
}
struct Z {
int a, comment("The amount of...");
float b, comment("The bla bla..."), unit(kg);
Point point, comment("The point ...");
}
(2)Variable declarations:
Point p;
Z z;
(3)Assignments
p.x = 1.1;
p.y = 2.2;
z.a = 1
z.b = 3.3
z.point.x = 4.4
z.point.y = 5.5
I want to keep these in separate files to have a clean separation of
these kinds/levels of data. (It must e.g. be possible to declare
several instances of the same struct.) There will also be arrays.
However, the problem is not to model this in XML syntax (that is
straightforward ), but my question is rather how to model the
interrelationsh ips between the files? At first sight, I thought it was
obvious that (1) should be defined as a schema for (3), but there are
some challenges that I cannot resolve:
* I want explicit variable declarations, mainly so that several
instances of the same type can be defined. This gives by hand the
inclusion of (2).
* I want to use the comment and unit in (1) for e.g. helping the user
in a GUI. Isn't a schema only a template for an XML file? Or can I put
things in the schema (1) that are needed there, but _shall not_ be
present in the XML file (3)?
* I want to resolve the names in (2), so that only declarations of
types defined in (1) (or basic types, float etc) are valid.
* I also want to make sure the assignments are made correctly, so that
e.g. "z.point.x = 4.4" is valid because z is of type Z which contains
a member point of type Point, which in its turn contain a float named
"x".
I realize that I can do these things programmaticall y (people have
been building compilers for some years now), but I first want to look
for solutions utilizing the power of XML. I cannot find anywhere on
the net someone who has attempted this – maybe I have used the wrong
search terms or it is just a stupid thing to attempt...
Any help in solving any or part of the problems is highly appreciated.
Regards,
Rikard Land 0 1277 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Oplec |
last post by:
Hi,
I'm learning C++ as a hobby using The C++ Programming Language : Special
Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that
deal with templates. Exercise 13.9 asks for me to turn a previously
made String class that deals with char's into a templated String class
that uses the template parameter C instead of char. I thought it would
be fairly simple to do this exercise, but I encoutered many errors for
my...
|
by: Steven T. Hatton |
last post by:
Now why didn't *_I_* think of that!
Declarations and Definitions in One Header
C++ object definitions can be quite complex. In principle, your source code
will need two kinds of things for each object that you use across more than
one source file. First, you need an interface specification, describing its
structure with type declarations and function prototypes. Second, you need
the implementation itself. It can be tedious to maintain...
|
by: Chris Gordon-Smith |
last post by:
I am currently in India and have treated myself to the Indian reprint
of O'Reilly's "C++ In A Nutshell". (Books in India come in at 1/3 to
1/2 of the price in Britain.)
I thought that I would have a look at what Chapter 12 on grammar says
about Declarations and Definitions. Now I'm more baffled than when I
started.
Here's the problem.
|
by: James A. Donald |
last post by:
I am contemplating getting into Python, which is used by engineers I
admire - google and Bram Cohen, but was horrified to read
"no variable or argument declarations are necessary."
Surely that means that if I misspell a variable name, my program will
mysteriously fail to work with no error message.
If you don't declare variables, you can inadvertently re-use an
variable used in an enclosing context when you don't intend to, or
|
by: Ron Guerin |
last post by:
The New York Linux User's Group invites you to a special presentation
by Alex Martelli of Google, on the Python Object Model. This
presentation will be held at P.J. Clarke's Sidecar, rather than our
usual location, and Google is picking up the tab for an hour and a half
of open bar and food. Additionally, if you're looking for a job as a
Python developer, bring your resume.
Please RSVP at http://rsvp.nylug.org to attend, as seating is...
| |
by: zouyongbin |
last post by:
Stanley B Lippman in his "C++ Primer" that a definition like this
should not appear in a header file:
int ix;
The inclusion of any of these definitions in two or more files of the
same program will result in a linker error complaining about multiple
definitions. So this kind of definition should be avoided as much as
possible. But as we know, the definition of a class is always in a
header file. And we can use "#ifndef" to eliminate...
|
by: Jess |
last post by:
Hello,
Sometimes declarations are all what we need when we define/declare
classes (or functions?), but sometimes we need definitions. I learned
that if we define a class (B) that has an object (a_obj) of a class
type (A), then we need to define A as well, but if B has a pointer to
A, then we only need to forward declare A. I was told this is because
the compiler needs to see the implemenation of A when allocating
memory for a_obj. ...
|
by: borophyll |
last post by:
I don't understand the difference between these two declarations
int foo(char a, char b)
{
...
}
int foo(a, b)
char a, b;
{
|
by: tonytech08 |
last post by:
What I like about the C++ object model: that the data portion of the
class
IS the object (dereferencing an object gets you the data of a POD
object).
What I don't like about the C++ object model: that most OO features
are not
available for class object design without loss of POD-ness.
So, I'm more than leaning toward "bad" because of the limitations and
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |