By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

inserting and deleting valid xml nodes

P: n/a
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

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
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
there are not-public methods building it up and using it, its very
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
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
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
a complete validator: the schema type of an element is defined by the
name, which can be simply looked up in the schema file. So the

while GetNextElementName do
if !(ElementType isin VectorWithAllowedTypesAtCurrentPosition) then
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
again after months of delay.
Jul 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.