inserting and deleting valid xml nodes

I

indo3

Hello,
I program an xml editor with xerces for the university of
Braunschweig, the user
dont see any xml tags, it is represented in a JTree.
Now the user shall be able to insert nodes, which
conforms to the schema file (the user need not know what
that is, its transparent to him). I found two approaches for doing
that:

1. When xerces validates the source or the DOM tree (this is a new
xerces feature
and is faster since the tree structure is already there, by
normalizeDocument()),
it builds up for each node a vector holding all possible allowed
schema types, and
then just looks if that node's type is in that vector. I could
store that vector for my own purposes and let the user choose, what
node he wants to insert, according to the vector.
There are some difficulties in that: First, its hard to get that
vector,
there are not-public methods building it up and using it, its very
hard.
Second, DOMNormalizer only accepts the document root as input, and not
a child
node, but I dont want to run the DOMNormalizer after each little
modification on the
whole file, this would take to much time at a large file and a quick
user. Surely with some "hacking" (that means, with modification of
xerces source files) I could do it on child nodes somehow, but this is
even more complicated. Moreover, if I insert a node, I would have to
check
if the following sibling nodes are allowed at there new by-one-shifted
positions. This is needed especially at the deletion of a node in
backwards direction. Otherwise the node's type is not allowed to be
inserted or deleted.

2. I could use PSVI information. With PSVI information, I can see the
schema type definition of every node in the DOM tree. The good thing
is that I dont need to modify
internal xerces files. But what I dont know right now, since I not
programmed
it yet: If I can get an exact vector of all allowed schema node types
possible for one position in the DOM tree like with the first
approach. Moreover i am
cared about the thought that with this approach, I would virtually
program
a complete validator: the schema type of an element is defined by the
elements
name, which can be simply looked up in the schema file. So the
pseudocode

while GetNextElementName do
if !(ElementType isin VectorWithAllowedTypesAtCurrentPosition) then
DocumentIsNotValid();


looks to me like a validator!


So nice of you to read such much text, any suggestions what i should
do are welcome!


PS: it could be that i messed up some things, I am just tackling the
problems
again after months of delay.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top