EdyWinarno.Com

|Computer|Blogging|Programming|Informatics|Network|Technology|

Modifikasi Dokumen XML dengan XUpdate pada Xindice

Comments Off
Posted by edy winarno on December 20, 2009 at 1:59 pm

xinxmlSeperti perintah pada basis data RDBMS (Relational Database Management System), maka modifikasi dokumen pada database XML Xindice juga terdiri dari INSERT, UPDATE dan DELETE.  Untuk setiap tahap perintah akan dipergunakan perintah konsolnya. Adapun karena perintah XUpdate ini bisa sangat panjang dan memerlukan modifikasi yang sering, maka pada utilitas konsol, perintah tersebut disimpan di dalam file teks tersendiri, untuk kemudian disertakan nama filenya pada setiap perintah modifikasi dokumen. Sedangkan untuk versi Java, baik perintah INSERT, UPDATE atau DELETE tidak mempunyai perbedaan kode, melainkan tentu saja sintaksis dari perintah XUpdate yang diinginkan. Berikut adalah kode progam Java yang diperlukan untuk menjalankan perintah XUpdate tersebut:
package test.xindiced;

import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;

public class XUpdate {

public static void main(String[] args) throws Exception {
Collection col = null;
try {
String driver = “org.apache.xindice.client.xmldb.DatabaseImpl”;
Class c = Class.forName(driver);

Database database = (Database) c.newInstance();
DatabaseManager.registerDatabase(database);
col = DatabaseManager.getCollection(“xmldb:xindice:///db/edy”);

String xpath = “//pasien[nomorinduk=1518989]/nama”;
String data = “Edy Winarno”;
String xupdate=”" +
“” + data + “” +
“”;

XUpdateQueryService service =
(XUpdateQueryService) col.getService(“XUpdateQueryService”, “1.0″);
service.update(xupdate);
} catch (XMLDBException e) {
System.err.println(“XML:DB Exception occured ” + e.errorCode + ” ” +
e.getMessage());
} finally {
if (col != null) {
col.close();
}
}
}
}
Perbedaan program ini dengan program Java yang menggunakan query dengan XPath, adalah service yang di-instansiasi. Jika yang menggunakan XPath service adalah bertipe XPathQueryService, maka disini service bertipe XUpdateQueryService, seperti ditunjukkan pada potongan program ini:

XUpdateQueryService service =
(XUpdateQueryService)
col.getService(“XUpdateQueryService”, “1.0″);
service.update(xupdate);

Adapun nilai dari variabel xupdate yang akan menentukan efek dari eksekusi servis tersebut, yang bisa bertipe INSERT, UPDATE ataupun DELETE.

1. Perintah INSERT.
Untuk menambah data pada dokumen XML, akan diperlihatkan data sebelum perintah INSERT ditambahkan, sebagaimana berikut ini:

D:\Program\xml-xindice-1.1\bin>xindice xpath -c /db/edy -q “//pasien”
trying to register database

<pasien src:col=”/db/edy” src:key=”pasien” xmlns:src=”http://xml.apache.org/xindice/Query”><nomorinduk>1518989</nomorinduk><nama>Edy Winarno</nama><nomoridentitas>KTP-229988221</nomoridentitas> <tempatlahir>Semarang</tempatlahir><jeniskelamin>Pria</jeniskelamin>  <golongandarah>A</golongandarah><tinggi>165</tinggi><berat>67</berat><telepon>024-588-xxx</telepon>    <pekerjaan>Dosen</pekerjaan><alergiobat>Amoxycillin</alergiobat><alamat>Semarang</alamat><riwayatpemeriksaan /></pasien>

Untuk menambahkan data baru, yaitu pasien dengan nomorinduk 1518989, maka dipergunakan perintah modifikasi XUpdate yang disimpan ke dalam file insert2.xml berikut ini:

<xupdate:modifications version=”1.0″ xmlns:xupdate=”http://www.xmldb.org/xupdate”>

<xupdate:append select=”/daftar_pasien”>

<xupdate:element name=”pasien”>

<nomorinduk>1518990</nomorinduk>

<nama>Yuni Astuti</nama>

<nomoridentitas>KTP-1109099922</nomoridentitas>

<tempatlahir>Semarang</tempatlahir>

<jeniskelamin>Wanita</jeniskelamin>

<golongandarah>O</golongandarah>

<tinggi>160</tinggi>

<berat>45</berat>

<telepon>024-566-xxx</telepon>

<pekerjaan>Swasta</pekerjaan>

<alergiobat>Amphicillyn</alergiobat>

<alamat>Semarang</alamat>

<riwayatpemeriksaan/>

</xupdate:element>

</xupdate:append>

</xupdate:modifications>

(Perintah modifikasi XUpdate untuk INSERT)

Untuk mengeksekusi perintah dalam file insert.xml tersebut, dilakukan perintah konsol berikut ini:
xin1

Gambar 1. Eksekusi Perintah dalam file insert.xml

Hasil dari proses tersebut adalah penambahan data pasien baru dengan nomorinduk 1518990 berikut ini :

xin2

Gambar 2.  Hasil Eksekusi Perintah XUpdate INSERT

Pada tampilan tersebut di atas, tampak bahwa data sudah bertambah dengan data baru yaitu pasien dengan nomor 1518990

(Bersambung…)

(winarnoedy@gmail.com)

Kembali ke halaman utama

Both comments and pings are currently closed.

40 Comments

  • On September 2, 2011 at 4:39 pm buy adobe creative suite 2 mac said

    Well I truly liked studying it. This article offered by you is very helpful for correct planning.

  • On September 6, 2011 at 3:42 pm Wholesaler Galvanni said

    Actually one of the many challenges which individuals beginning a new on-line firm face are obtaining website visitors to their net site.

  • On September 13, 2011 at 4:59 am link building service said

    Many thanks for this interesting post. I will probably be likely to tell others in regards to this site :) Excellent post. Cant wait to view the next text.

  • On September 13, 2011 at 7:14 pm Johnson Morgan & White said

    Hi! Your house is valueble for me. Thanks!

  • On September 14, 2011 at 4:44 pm Home Cleaners Southport said

    The acceptance of video submission sites akin to YouTube is rising at a steady pace. Films are considered to be efficient ways to place forth a concept, expertise entertainment, convey information, and even advertise and market products. Undeniably, you possibly can achieve video success with all the right information and quality work. An individual can boost YouTube views as part of your films and help your net presence regardless if up against rough competition.

  • On September 15, 2011 at 12:02 am monster truck games said

    Daniel, yea I noticed what we probably did there. I seriously favored that part, however hehe I am not that harsh like my dad with one of these things. He continuously informs me loopy stories again inside day and calls me a loser. I assume it’s the time I move out of my father and mother basement LOL. Aaanyways, have you considered you? simply what does your dad think xD Anyway, at my language, there will stop lots good supply similar to this.

  • On September 15, 2011 at 2:47 am custom koozies said

    I do believe this is certainly one of the most vital information in my opinion. And i’m glad reading your article. But should remark on few general things, The site style is ideal, the articles is absolutely excellent : D. Good job, cheers

  • On September 16, 2011 at 3:01 am motorbike games said

    huge written piece. I just discovered internet site and desired to inform you that I have certainly enjoyed browsing your blogs. Just the same I will be after the feed and i also hope you’re posting again soon.

  • On September 16, 2011 at 10:39 am Affordable Web Design said

    The contextual educating style featured inside the Jamorama will not make you training yourself in your room for too long periods at a time longing for a small improvement. The best way to gain knowledge music should be to have fun with other, better, musicians. Jamorama gives you which has a solution to study on among the better qualified person guitarists, including jam monitor recordings than enable you to play together with the pros. This extensive multimedia bundle carries a guitar-playing tuition book, ear schooling game, music browsing game, tuning software, a metronome, and video lessons.

  • On September 17, 2011 at 10:35 am California Web Design said

    Excellent post. I’d been checking constantly this site and Im impressed! Very useful info specifically the very last part :) I care for such information much. I became looking for this specific information for the quite a while. Appreciate it and all the best ..

  • On September 29, 2011 at 4:41 pm Windows 7 Home Premium key said

    I loved as much as you’ll receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get bought an shakiness over that you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this increase.

  • On September 30, 2011 at 12:12 pm Gale Wernli said

    I simply want to mention I am beginner to blogging and actually liked this web page. More than likely I’m going to bookmark your blog post . You actually come with tremendous stories. Thank you for revealing your web site.

  • On October 2, 2011 at 8:01 am online cash loans said

    I do think this is certainly just about the most vital information personally. And i’m glad reading your article. But should remark on few general things, The internet site style is perfect, the articles is basically excellent : D. Good job, cheers

  • On October 2, 2011 at 8:29 am jokeripokeri said

    Just right points?I’d note that as any person who in reality doesn’t write on blogs so much (in truth, this can be my first submit), I don’t think the time period ‘lurker’ may be very becoming to a non-posting reader. It’s not your fault in the slightest degree , but most likely the blogosphere may come up with a greater, non-creepy name for the ninety% people that experience studying the content material .

  • On October 2, 2011 at 3:18 pm Refugio Hartsoe said

    here is the guy who the giants need to hire as the next gm

  • On October 3, 2011 at 1:03 pm scrapebox list said

    some genuinely prize blogs during this web site , saved to bookmarks .

  • On October 3, 2011 at 11:40 pm cruises from baltimore said

    “The greatest happiness of life is the conviction that we are loved; loved for ourselves, or rather, loved in spite of ourselves.” ~ Victor Hugo

  • On October 4, 2011 at 3:03 am seo web directory said

    Give your website a boost on this free web directory

  • On October 4, 2011 at 5:49 pm Fredric Trank said

    who can resist a bent halloween with gus van sant??

  • On October 4, 2011 at 7:16 pm kore dizileri said

    My brother suggested I might like this website. He was entirely right. This post actually made my day. You cann’t imagine just how much time I had spent for this info! Thanks!

  • On October 5, 2011 at 1:45 am Luetta Hockenberry said

    So when you cross a street you dont look both ways because the cars will usually stop for you?Our higher intellect gives us the ability to think ahead and anticipate danger. Is there a problem with being prepared?

  • On October 5, 2011 at 11:03 am link building service said

    Read it, liked it, thanks for it

  • On October 5, 2011 at 7:35 pm House Training A Puppy said

    An fascinating communicating is couturier scuttlebutt. I cogitate that you should indite author on this subject, it mightiness not be a bias issue but generally grouping are not sufficiency to communicate on such topics. To the succeeding. Cheers like your Modifikasi Dokumen XML dengan XUpdate pada Xindice | EdyWinarno.Com.

  • On October 6, 2011 at 1:40 am work from home ideas said

    person finding identical rss challenge? Anybody who knows kindly respond. Thnkx

  • On October 6, 2011 at 7:00 am william hill casino said

    At this point, I dont care where Obama was born. We just need to make sure hes a one term president. We need to vote out all those who have voted for Obamas programs. Check each of your congresspeoples voting records. There are some good guys up there and we need to keep them. They, at least, have their heads on straight.

  • On October 6, 2011 at 7:21 am no deposit casino usa said

    Aye, youd need to be about 110, Icedog. Nee Sky HD in those days, either.

  • On October 6, 2011 at 1:56 pm wind turbine insurance said

    Your internet site is very slow because of open

  • On October 6, 2011 at 3:35 pm trivago said

    Heya, I needed to ask you some thing. Is this site a wordpress blog site? I will be wondering about shifting my blog site from Blogger to wordpress, do you think this can be probable? In addition did you create the following theme by yourself some how? Many thanks for the assistance!

  • On October 7, 2011 at 7:33 am Best Horror Movies said

    Full of propaganda and revisionist history. Niall F. must be on the Rothschild payroll.

  • On October 7, 2011 at 9:30 am Avengers Movie said

    Whats with the Bush/Greenspan bashing regarding money. Was everyone asleep when the Democrats were in control the last two years of Bushs administration. Its Barney Frank and his crowd whos to blame! This show is just another left-wing fraud.

  • On October 8, 2011 at 9:28 am chase.com said

    its not about liberals and conservatives.thats ridiculous. Its about just seeing beyond the divisive lies of right/left paradigms and getting the courage to stand up for the obvious truth that out shines the good guy/bad guy game. So grow up people and stop playing their trifling game!

  • On October 8, 2011 at 11:51 am www.chase.com said

    AT&T calls for speed. Erratic pitching, erratic hitting, you have to expect some of that with any team. Speed does not slump.

  • On October 8, 2011 at 9:24 pm quick cash loans said

    Thank you for making the sincere strive to provide an explanation for this. I think very sturdy approximately it and wish to be told more. If it’s OK, as you reach extra extensive wisdom, might you thoughts adding extra posts similar to this one with additional information? It could be extremely helpful and useful for me and my colleagues.

  • On October 8, 2011 at 10:03 pm no credit check payday loans said

    I picture this could be numerous upon the written content? then again I nonetheless consider that it may be suitable for nearly any type of subject material, as a result of it would often be pleasant to resolve a warm and delightful face or perhaps pay attention a voice when initial landing.

  • On October 9, 2011 at 3:48 pm fishing said

    WONDERFUL Post.thanks for share..more wait .. …

  • On October 9, 2011 at 3:52 pm medical answering service said

    I couldn’t get some of one’s links to work. Like your rss link just sent me back to your main page.

  • On October 9, 2011 at 8:23 pm windows games said

    It is a remarkably amazing powerful resource that you’re offering and you simply provide it away cost-free!! I comparable to discovering websites of which understand the particular importance of supplying you with beautiful learning resource for zero cost. We truly dearly loved examining this web site. Have fun here!

  • On October 10, 2011 at 2:28 am House Training A Puppy said

    An fascinating treatment is worth interpret. I conceive that you should correspond many on this issue, it might not be a inhibition message but generally group are not enough to speak on much topics. To the next. Cheers like your Modifikasi Dokumen XML dengan XUpdate pada Xindice | EdyWinarno.Com.

  • On October 10, 2011 at 4:24 am Laurence Osuch said

    I expressly believe that a large group of Men (men and women) will save the Constitution of the United States when it hangs by a thread. They will take the Constitution into the Tops of the Mountains and hold it up as an Ensign to ALL NATIONS.

  • On October 10, 2011 at 4:54 am Adolph Mcculla said

    The Nazis at Auschwitz-Birkenau, CheÅ‚mno, Bełżec, Majdanek, Sobibór, and Treblinka were all just following orders.

Pingbacks / Trackbacks

Welcome to EdyWinarno.Com
Edy Winarno-Blogger-Author sekaligus dosen di Program Studi Teknik Informatika Universitas Stikubank (UNISBANK) Semarang. Penulis adalah alumnus S2 Sistem Komputer & Informatika - Teknik Elektro UGM Yogyakarta. Saat ini sedang melanjutkan studi S3 dengan beasiswa BPPS di Program Studi Ilmu Komputer UGM. Penulis bisa dihubungi di edy_winarno[at]yahoo.co.id



Edy Winarno

Create Your Badge

Tulis Pesan Anda