|
From: Jimmy Z. <cra...@co...> - 2007-04-09 03:15:43
|
The step outlined will work as the most general purpose solution,
0. Create an XMLModifier
1. add an element
2. serialize all 100 megs
3. reparse the new output
One possible alternative involves the use of the overWrite feature...
and it is possible to disable/enable instead of remove/add elements to XML..
consider the following example,
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Still got the blues</TITLE>
<ARTIST>Gary More</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Virgin redords</COMPANY>
<PRICE>10.20</PRICE>
<YEAR>1990</YEAR>
</CD>
</CATALOG>
If it is serialized as
<CATALOG>
<CD enable = '1'>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD enable = '1'>
<TITLE>Still got the blues</TITLE>
<ARTIST>Gary More</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>Virgin redords</COMPANY>
<PRICE>10.20</PRICE>
<YEAR>1990</YEAR>
</CD>
</CATALOG>
We can simply disable it by setting "enable " to 0 to disable
an element
To enable an elements, we can *pre-serialize* some dummy
XML elements into the document whose initial value for
enable is set to zero. We also need to make sure that those
fields (e.g. title/artist/country/company) has long enough enough to
insert new content (this is similar to define the width of a column
of a relational table), so an XML doc with dummy elements may
look like:
<CATALOG>
<CD enable = '0'>
<TITLE> </TITLE>
<ARTIST> </ARTIST>
<COUNTRY> </COUNTRY>
<COMPANY> </COMPANY>
<PRICE> </PRICE>
<YEAR> </YEAR>
</CD>
<CD enable = '0'>
<TITLE> </TITLE>
<ARTIST> </ARTIST>
<COUNTRY> </COUNTRY>
<COMPANY> </COMPANY>
<PRICE> </PRICE>
<YEAR> </YEAR>
</CD>
</CATALOG>
When parsing the document above, you have created VTD that will
not be changed even after inserting new byte content into the white
spaces...
also notice that adding "enable" attribute to an element is just one way of
disabling/enabling an element
A quick summary: to tack extra content on to the end, just pre-serialize
a few dummy elemnts that can be modified without reparse...
----- Original Message -----
From: "Mark Swanson" <ma...@Sc...>
To: <vtd...@li...>
Sent: Saturday, April 07, 2007 10:54 PM
Subject: [Vtd-xml-users] XMLModifier isn't quite what I need
> Hello,
>
> I would like to use XML for more than just an intermediary format. I'd
> like to use VTD to query/update/remove elements and attributes at will
> without having to resort to moving the XML into objects.
>
> Currently, if I have a hundred megs of data I have to do this to tack a
> new element on to the end of the document:
>
> 0. Create an XMLModifier
> 1. add an element
> 2. serialize all 100 megs
> 3. reparse the new output
>
> I wonder... 100% of my use cases currently would pass if I could just
> tack elements on to the end of the document. Would it be possible for
> this specific case to work easily? And by work, I mean basically add a
> VTDGen.parseAndAddToEndOfDocument(byte[] d); I'm hoping the index
> generation and data structure manipulation would be minimal for this
> special case.
>
> Thoughts?
>
>
> --
> http://www.ScheduleWorld.com/
> Free Google Calendar synchronization with Outlook, Evolution,
> cell phones, BlackBerry, PalmOS, Exchange, Mozilla, Thunderbird,
> Pocket PC/Windows Mobile. Also sync tasks, notes and contacts!
> WebDAV, vfreebusy, RSS, LDAP, iCalendar, iTIP, iMIP support.
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Vtd-xml-users mailing list
> Vtd...@li...
> https://lists.sourceforge.net/lists/listinfo/vtd-xml-users
>
|