[xsd-users] RE: keeping annotations/comments in xml file

Inna Grois inna at hyperroll.com
Thu Aug 23 02:45:31 EDT 2007


Hi, Boris

Thank you for your answer.

I would like to get more details about the second possibility.
You wrote:

> Another, more elegant, way to do this would be to customize the 
> xml_schema::type type (a base type for all generated classes) with a 
> new DOMElement serialization operator that will copy the comments from

> the old DOM tree (that should be associated with the object model 
> using the keep_dom flag) to the new one.

I have a couple of questions:

If I use Keep_dom flag, then after parsing an xml node, the DOMElement
of this node contains the DOM info of this node?

Is it means that the DOMElement in xml_schema::type type contains all
the DOM info about current node including the comments of current node? 

If so, what exactly should I do to copy the comments from the DOMElement
to the output document?

if you can give me some simple example I will appreciate it very much.

Thanks a lot,
Inna

-----Original Message-----
From: xsd-users-bounces at codesynthesis.com
[mailto:xsd-users-bounces at codesynthesis.com] On Behalf Of
xsd-users-request at codesynthesis.com
Sent: Wednesday, August 22, 2007 7:00 PM
To: xsd-users at codesynthesis.com
Subject: xsd-users Digest, Vol 26, Issue 6

Send xsd-users mailing list submissions to
	xsd-users at codesynthesis.com

To subscribe or unsubscribe via the World Wide Web, visit
	http://codesynthesis.com/mailman/listinfo/xsd-users
or, via email, send a message with subject or body 'help' to
	xsd-users-request at codesynthesis.com

You can reach the person managing the list at
	xsd-users-owner at codesynthesis.com

When replying, please edit your Subject line so it is more specific
than "Re: Contents of xsd-users digest..."


Today's Topics:

   1. keeping annotations/comments in xml file (Inna Grois)
   2. Re: keeping annotations/comments in xml file (Boris Kolpackov)


----------------------------------------------------------------------

Message: 1
Date: Wed, 22 Aug 2007 11:53:42 +0300
From: "Inna Grois" <inna at hyperroll.com>
Subject: [xsd-users] keeping annotations/comments in xml file
To: <xsd-users at codesynthesis.com>
Message-ID:
	
<783879783B65E44995520FEF376C4538158F09 at ilexch1.int.hyperroll.com>
Content-Type: text/plain;	charset="us-ascii"

Hi,

 

I would like to update xml file while keeping the annotations if they
exist in xml.

Is it possible?

And if yes, how should I work in order to keep the annotations?

As I understand, If I will delete the node and create the new one with
the updates I will definitely lose the annotations.

But if I will check that the node already exists and if yes I will only
update it, will I keep the annotations in that way?

 

Thank you,

            Inna

 

 



------------------------------

Message: 2
Date: Wed, 22 Aug 2007 11:32:11 +0200
From: Boris Kolpackov <boris at codesynthesis.com>
Subject: Re: [xsd-users] keeping annotations/comments in xml file
To: Inna Grois <inna at hyperroll.com>
Cc: xsd-users at codesynthesis.com
Message-ID: <20070822093211.GA29954 at karelia>
Content-Type: text/plain; charset=us-ascii

Hi Inna,

Inna Grois <inna at hyperroll.com> writes:

> I would like to update xml file while keeping the annotations if they
> exist in xml.
>
> Is it possible?

There is no automatic way to preserve comments in the resulting
documents. The serialization operators remove any child nodes
(including comments) from DOM elements before creating new
content.

The straightforward way to achieve what you want would probably
be to traverse the old DOM document and copy any comments to
the correct places in the new one. The tricky part could be
figuring out when to copy a comment and when not to. Here
is a quick example to illustrate what I am talking about.
Let's say you start with the following document:

<person>
  <!-- Record for John -->
  <name>John Doe</name>
  <age>21</age>
</person>

Now you load it into the object model, modify the data and
write it out to the updated document (in DOM):

<person>
  <name>Jane Doe</name>
  <age>18</age>
</person

The problem is, how do you determine whether to copy the comment
from the old document or not.


Another, more elegant, way to do this would be to customize the
xml_schema::type type (a base type for all generated classes)
with a new DOMElement serialization operator that will copy
the comments from the old DOM tree (that should be associated
with the object model using the keep_dom flag) to the new one.


hth,
-boris



------------------------------

_______________________________________________
xsd-users mailing list
xsd-users at codesynthesis.com
http://codesynthesis.com/mailman/listinfo/xsd-users


End of xsd-users Digest, Vol 26, Issue 6
****************************************




More information about the xsd-users mailing list