XML-EasyOBJ-1.12/0040755000076400010400000000000007520561444011623 5ustar defaultXML-EasyOBJ-1.12/t/0040755000076400010400000000000007520561444012066 5ustar defaultXML-EasyOBJ-1.12/t/write.t0100644000076400010400000000236207520557424013410 0ustar default use strict; use Test; use XML::EasyOBJ; use FindBin qw/$Bin/; BEGIN { plan tests => 11 } ok( my $doc = XML::EasyOBJ->new( -type => 'new', -param => "root" ) ); $doc->level1_a->level2_a->setString("L1AL2A"); $doc->level1_a->level2_b->setString("L1AL2B"); $doc->level1_a->level2_c->setString("L1AL2C"); $doc->level1_b->level2_a->setString("L1BL2A"); $doc->level1_b->level2_b->setString("L1BL2B"); $doc->level1_c->level2_a->setString("L1CL2A"); $doc->level1_a->level2_b->setAttr("L1AL2B", 'test="1"'); $doc->level1_b->level2_b->setAttr("L1BL2B", 'test<>2'); $doc->level1_c->level2_a->setAttr("L1CL2A", 'test<>3'); $doc->getDomObj->printToFile("$Bin/write.xml"); ok( my $doc2 = XML::EasyOBJ->new( -type => 'file', -param => "$Bin/write.xml" ) ); ok( $doc2->level1_a->level2_a->getString, "L1AL2A" ); ok( $doc2->level1_a->level2_b->getString, "L1AL2B" ); ok( $doc2->level1_a->level2_c->getString, "L1AL2C" ); ok( $doc2->level1_b->level2_a->getString, "L1BL2A" ); ok( $doc2->level1_b->level2_b->getString, "L1BL2B" ); ok( $doc2->level1_c->level2_a->getString, "L1CL2A" ); ok( $doc2->level1_a->level2_b->getAttr("L1AL2B"), 'test="1"' ); ok( $doc2->level1_b->level2_b->getAttr("L1BL2B"), 'test<>2' ); ok( $doc2->level1_c->level2_a->getAttr("L1CL2A"), 'test<>3' ); XML-EasyOBJ-1.12/t/synop.t0100644000076400010400000000220407520557424013421 0ustar default use strict; use Test; use XML::EasyOBJ; use FindBin qw/$Bin/; BEGIN { plan tests => 9 } ok( my $doc = XML::EasyOBJ->new("$Bin/read.xml") ); ok( my $doc2 = XML::EasyOBJ->new(-type => 'file', -param => "$Bin/read.xml") ); ok( my $doc3 = XML::EasyOBJ->new(-type => 'new', -param => 'root_tag') ); # write to document $doc3->an_element->setString('some string'); $doc3->an_element->addString('some string'); ok( $doc3->an_element->getString, 'some stringsome string' ); $doc3->an_element->setAttr('attrname', 'val'); ok( $doc3->an_element->getAttr('attrname'), 'val' ); # access elements with non-name chars and the underlying DOM my $element = $doc3->getElement('foo-bar')->getElement('bar-none'); $element->setString('test1234'); ok( $doc3->getElement('foo-bar')->getElement('bar-none')->getString, 'test1234' ); # remove elements/attrs $doc3->remElement('foo-bar', 0); ok( ! $doc3->getElement('foo-bar')->getElement('bar-none')->getString ); $doc3->an_element->remAttr('attrname'); ok( $doc3->an_element->getAttr('attrname'), '' ); # remap builtin methods $doc3->remapMethod('getString', 's'); ok( $doc3->an_element->s, 'some stringsome string' ); XML-EasyOBJ-1.12/t/read.t0100644000076400010400000000115607520557424013171 0ustar default use strict; use Test; use XML::EasyOBJ; use FindBin qw/$Bin/; BEGIN { plan tests => 8 } ok( my $doc = XML::EasyOBJ->new( "$Bin/read.xml" ) ); ok( my @maps = $doc->MAP, 6 ); ok( $doc->MAP(2)->KINGDOM(0)->NAME->getString, 'The Church of the Anhk' ); ok( my @regions = $doc->MAP(2)->KINGDOM(0)->DIPLOMACY->REGION, 2 ); ok( $regions[0]->getString, 'EBRA' ); ok( $regions[1]->getString, 'ULM' ); my $counter = 0; foreach my $m ( $doc->MAP ) { foreach my $k ( $m->KINGDOM ) { $counter++; } } ok( $counter, 43 ); ok( $doc->MAP->KINGDOM(2)->DIPLOMACY->getString, qr/^\s*Vught \(ne\), Wijk \(ne\)\s*WIJK\s*VUGHT\s*$/s ); XML-EasyOBJ-1.12/t/string.t0100644000076400010400000007732507520557426013601 0ustar default use strict; use Test; use XML::EasyOBJ; use FindBin qw/$Bin/; BEGIN { plan tests => 8 } my $xml = join('', ); ok( my $doc = XML::EasyOBJ->new( -type => 'string', -param => $xml ) ); ok( my @maps = $doc->MAP, 6 ); ok( $doc->MAP(2)->KINGDOM(0)->NAME->getString, 'The Church of the Anhk' ); ok( my @regions = $doc->MAP(2)->KINGDOM(0)->DIPLOMACY->REGION, 2 ); ok( $regions[0]->getString, 'EBRA' ); ok( $regions[1]->getString, 'ULM' ); my $counter = 0; foreach my $m ( $doc->MAP ) { foreach my $k ( $m->KINGDOM ) { $counter++; } } ok( $counter, 43 ); ok( $doc->MAP->KINGDOM(2)->DIPLOMACY->getString, qr/^\s*Vught \(ne\), Wijk \(ne\)\s*WIJK\s*VUGHT\s*$/s ); __END__ John Doe john.doe@xyz The Anfo Nation HUMAN PAGAN King Leopold open nation John Doe john.doe@xyz The Grand Duchy of Gistel SEEKER Grand Duke Trantolus, Overlord of the West Zrjpe (f) ZRJPE A messenger arrived at the court of the Grand Duke. He had been sent by Doran, Cheif Elder of the Old Church. The message was simple, the Old Church would not stand by while its nations were attacked. The Duke decided to look towards the future of his nation. The messangers ran quickly between Doran and the Duke. The Cheif Elder made his postion clear "Withdraw or suffer a Holy War". The Duke demanded that the Old Church not interfere with his aquisition of the penninsula. After much debate the issue was finally setteled. Gistell forces withdrew from Velsen. The Island Defense Agreement was signed. Chu-Lon, Sonlar, Tearsh,Norta and Gistel signed the IDA. In other news Princes Moira travelled to the region of Zrjpe. She was taken by a young man who happend to be a nobleman of the region. The Grand Duke arrainged a marriage. The Bishop Toben was nearby. He gladly made time to officiate at the ceremony. John Doe john.doe@xyz The Socdom of Hechtel TARQ Soclord Magedo Vught (ne), Wijk (ne) WIJK VUGHT The Soclord left his government in the hands of his Heir Lucretia. He travelled to some of his lands but moved around to quickly to have any effect. While in Vught he received even worse news, Lucretia had taken ill and passed away. Maximus Thrax was snet to gather more slaves to improve the region of Hechtel. John Doe john.doe@xyz The Julich Tribes SEEKER King Replevin the Clan Lord Buir (a), Liers (f), BUIR LIERS Prince Welsen was put in charge of the government. He was worried about the financial state of the nation that he would one day lead. So, he built a bank in Hainos and a Merchant's Guild in Canay. The King spent his time enjoying his wife and newest son. The various clan leaders were sent to improve relations. John Doe john.doe@xyz Ancient Empire of the Dragon TARQ King Nokolai II, Dreadlord open nation John Doe john.doe@xyz The Mighty Empire of Vruda Ungeria OLD CHURCH King Wilbur, of the House of Unger, High Tribunal, Grand Executive, Holder of the Axe, Defender of the Faith, Great Chief of the Barbarian Swine Horde Soltsky (t) SOLTSKY King Wilbur grows ever more paranoid, as threats of war and the Elbar resonate in his royal ears. Accordingly, the KIng of Vruda directs the royal treasurer to divert funds towaards improving the Empies defenses. In particular, a fighter's guild is constructed amongst the barbarian backwoods in Mead Hall, Slotsky. The diplomat from Narva will be there, to make the necessary and proper opening ceremony speeches between draughts of corn ale and honey mead. Wilbur and son Edwin will meanwhile soberly attend to the running of the nation. The Wizard of Robur will ply his new skills, magicking the fields to build reservoirs and better drain the city sewerage. John Doe john.doe@xyz The Mighty Realm of Krosno ANKH King Grindall Dukla (rebels) King Elendil had many fine plans. He ordered that some new trails be built to help encourasge the farmers to bring their wares to market. In the process he eat some unclean fruit and took ill. As he passed away with no heir, the country went into turmoil. When it was all over Dukla had broken away from the kingdom, and Grindall had seized power. John Doe john.doe@xyz The Seadragon Rank of Lahti MESSENGER King Faz-Katu IV, First of the Rank, Crowned Despot of All Seadragons open nation John Doe john.doe@xyz The Kingdom of Torun OLD CHURCH King James Chipka (c), Lipno (c) CHIPKA LIPNO King James ordered that the slaves build irrigation ditches and move rocks, and plant wheat. He then looked at his map. "West of Torun are a couple of trade centers that I wish to control." So he launched the Merchant War. 5000 swordsmen,1000 well-trained cavalry, 1500 elite swordsmen, and 3000 horsebowman led into battle by King James. King Hawke's forces numbered 7500 swordsmen. The Merchant War Spring 226- The Toruneese Horsebowman kill 1000 Cesenian troops. Then the two sides charge. 4000 Cesenians die compared to only 2500 Toruneese. Summer 226- Arrows kill 500 more Cesenians. The Toruneese are in control of the field. The final charge is masterfully handeled. All 2000 remaining Cesenians die. With the loss of only 500 Toruneese. Aftermath- The Cesenians are now under the control of Torun. John Doe john.doe@xyz The Garden of Klodawa MESSENGER King Bailey, Prince of the Free Peoples none King Bailey increased his army and his royal family. The Princess Karma was sent to explore the outlying regions. In Stegna he found the Old Church. In Turku he discovered followers of the Blood Cult. In Kalisz he saw people seeking the True Path. John Doe john.doe@xyz The Dell of Decin MESSENGER King Alfred none News from the Dell of Decin. New lands liberated. Princess Destiny getting a fine eduaction.Prince Blada killed in a training exercise. King Alfred announces "The Dell is producing the finest apples and blueberries in the world, along with that new stuffed toy the royal inventors mage for Destiny. I think they call it a "Furrby". Why dont more nations wish to trade with us?" King Alfred gathers his army of 11,500 swordsmen and conquers Plzen. He then aadds 2500 archers and 500 lancers, and conquers Detva. John Doe john.doe@xyz The Cesenian League HUMAN PAGAN King Hawke none Destoyed in the Merchant War. John Doe john.doe@xyz The Church of the Anhk ANKH High Priest Dathinius Ebra (ab), Ulm (ab) EBRA ULM Selene begins by declaring Dathinius as heir to the leadership of the Church, the orders missionaires to Ulm to expand the vision of the Anhk family. Then she travelled to Ebra. She was completly taken by the beauty of the area. She finds a very lovely forest that captures her attention. In this place she takes her last breath. An abbey is built on the spot. Dathinius begins to search the surrounding areas. He sneaks into Narial only to discover pagans. Undauted he goes into Stormwer, but there he finds elves. John Doe john.doe@xyz The Regal Realm of Rostow SEEKER King Raash, Seeker of the Strange Aliev (c) ALIEV Prince Jarosh was starting to bet a liitle bored with his royal lifestyle. So he sneaked off to spend some time in more local areas of Delmop. While visiting The Drowned Rat, a local pub, Prince Jarosh was accidentily killed in the middle of a dispute regarding a young brunette. King Raash was not happy at all. " I will make these cities safer for my people." City walls were built for all three cities in the land, and troops were stationed in key areas. Then he diplomacized Aliev. John Doe john.doe@xyz The Naughty Neserea TARQ Unknown Ruler open nation John Doe john.doe@xyz The Peoples Republic of Yzer OLD CHURCH Unknown Ruler open nation John Doe john.doe@xyz The Golden Empire of Khatai ANKH King Chenchun Dumaria (fa) DUMARIA King Chenchun was watching the workers beautify Lauria City. When a young man told him there was exciting news down at the docks. Men had arrived with the head of King Jarimor. This was exciting news for King Chenchun, so he raced to the docks. There he was met by the men. They said they were envoys of Vruda. "We took our army to investigate hereitc rumblings to the north. There we observed what we thought to be rituals of Tarq. As the only good follower of Tarq is a dead follower, we killed them all. Then we rumaged through their belongings and found relics of Elbar. So we came here with the head of King Jarimor to claim the reward. King Jarimor is dead, long live the Old Church." KIng Chenchun was very happy. "Lets open some corn ale and toast this victory" The men looked at the king and said "show us the way to the ale." The King, knowing that all Vrudanesse sailors always carry plenty of corn ale in ther ships, and never drink from other peoples kegs. He killed them. " FIND ME KING JARIMOR!!!!!!!!" Duke Pelara looked in the region of Morwen. He found some shady characters, but the killed as a message to keep away from the local underworld, not because they were Tarq spies. His home region of Dumaria, scared by the underworld, distanced themselves from the king. Duke Mulwar found nothing in Mittfel. Duke Krellius was looking in the region of Encora when he found a rather odd item. A helm of strange design. He placed it on his head and was consumed by flame. A local peasent carefully transported the helm to King Chenchun. John Doe john.doe@xyz The Kingdom of Balto HUMAN PAGAN Unknown Ruler open nation John Doe john.doe@xyz The Gruzz TARQ King Gruzz the XI open nation John Doe john.doe@xyz The United Tribes of Diol OLD CHURCH King Hector, His Royal Highness, The Emerald King none The nation was not active. John Doe john.doe@xyz The Spirits of the Pristine Woods OLD CHURCH Doran, Chief Elder of the Old Church Sonlar (ca), Sasyk (mn), Lepel (mn), Vruda (ab) VRUDA LEPEL SASYK SONLAR Enraged by Gistel's invasion of Velsen, Doran set the wheels in motion to bring Velsen back its freedom, by any means necessary. Emissaries flew between the Chief Elder and the Grand Duke. As the deadline for peace approached, it became apparent that the Duke was willling to deal. Tensions throught the lands of Tarsha were high, when at the last moment, Doran announced that an agreement had been reached with the Duke. Gistel would withdraw from Velsen. The nations of Chu-Lon,Tearsh,Sonlar,Norta and Gistel would also sign a mutual defense compact known as the Island Defense Agreement or IDA. This settled, the Chief Elder had time to concentrate on other matters. He placed a HUGE bounty on the head of King Jarimor of Elbar. Any nation that discovers, reports the location of and aids in the destruction of the fugitive nation will benefit handsomely. John Doe john.doe@xyz The Terrible Twoja TARQ Unknown Ruler open nation John Doe john.doe@xyz The Serene Land of Kas OLD CHURCH King Samuel, the Serene One none As the workers began to look over the plans for a merchants guild, they realized there was something missing, a bank! So, they built a bank instead. The region of Yutu was explored and happily it was found to be Old Church. Much of King Samuel's time was spent with his royal family. The region of Kas was improved slightly, to compete with Ios. The really important news came from the university where they had learned much about Ironworking. Thus heralding the advance to tech level three. John Doe john.doe@xyz The Glorious Gollel TARQ Unknown Ruler open nation John Doe john.doe@xyz The Duchy of Aragon OLD CHURCH Duke Rostow II, Patron of the arts Duru (t), Kelo (t) DURU KELO A bank was built in Aragon. Prince Derek was sent on a diplomatic mission, as was Count Balck.The region of Bili was improved and Rostow II spent his money on investing in the future of his nation. John Doe john.doe@xyz The Sacrifice Gatherers of Tarq. (formerly Carnot) TARQ Blood Marshal Alstair Vyborg (ea) VYBORG The government of Carnot required the Blood Marshal's full attention. He sent Blynder, Prince of the seven hues of Red, along with Dumjon De'mon, Fang Searcher and Red-Robed Seeker to secure the region of Vyborg. The army was increased by the addition of the Red Wizards unit. John Doe john.doe@xyz The Confederacy of Mopti SEEKER Unknown Ruler open nation John Doe john.doe@xyz The Red Church TARQ Grand Shaman Holtech, The Prophet of Tarq, Keeper of the Sacred Scrolls none open nation John Doe john.doe@xyz The Kingdom of Faldo HUMAN PAGAN King Nick Faldo, Monarch of Faldo Senla (a) SENLA Deciding to learn the secrets of the long forgotten wisdom of the elders, King Nick sat at his desk to study. Leaving orders not to be disturbed unless the NCAA tourney was on the tele, Knig Nick studied diligintley day and night. Ian attempted to bring Senla into the fold by offering discounted memberships...assuming reciprocity would soon follow. Collin, dismayed by the lack of caddies had a thought. " Would it not be better if the Orcs were carying our clubs instead of trying to hit us with clubs?" So he went in search of orcs. He found some, and realized it was a bad idea. Clarke was intrigued by the books the King was reading, who grew annoyed at someone reading over his shoulder, so he gave him his own book. Neither one learned anything usefull. John Doe john.doe@xyz The Seekers of the True Path SEEKER Prime Seeker Norkell Temor (ab), Seldon (ab) SELDON TEMOR Studying maagic was all well and good, but at times it was amazxingly boring. Some activity would do the Prme Seeker good. his planned route took him to various places on the island. With joy he saw the seeker people emmbraace the Path. He was able to build religious sites on the island. Once in a while Bishop Toben woul;d send a message to the Prime Seeker about the activities on the Western Front. The people of Zrjpe and Gistel were looking forward to the marriage of the princess Moria. She was to be wed in the region of Zrjpe in the year 226 S.C. Toben was excited as this was one of the few chances he would have to proside over a royal function. He sought out the people of Gistel to assist them in the signing of the Island Defense Pact. Then he let his wonderings take him to the region of Dovai, where he found the Church of the Anhk. Some young priests were sent to Faldo in hopes that they would consider changing their pagan ways to Seek the True Path. John Doe john.doe@xyz The Glittering Chu-Lon OLD CHURCH Sir Zembar, Regent for his royal personage none Sir Zembar looked after the affairs of the state for his two young charges, the Princess Gwyneth and the Prince Valon. Knowing the pain of the people durinf the 10 year war, and with the loss of two kings, he made it his special purpose to thank the Chu-Lonoins for their support and promises that one day soon, we will be able to live peaceful rich lives. He also spent money to plant flowers at the various battle sites of the war. John Doe john.doe@xyz The Kingdom of Tearsh OLD CHURCH King Antipode none open nation John Doe john.doe@xyz The Northern Ice Kingdom of Kal SEEKER King Kal, the founder none Kal was claimed off waivers by John Smith. John Doe john.doe@xyz The Island People of Norta OLD CHURCH King Norton, the Great none King Norton built a mages guild around the shrine to the Old Church that he had built back in 223 S.C. The shrine itself was also expanded. It looks as if the shrine could engulf the abbey that exsists there. It is noted by many that the shrine generates a healthy feeling in all who spend time there. This could be true, or just a feeling-only the gods know for sure. King Norton prolcaimed "Long live the Old Church" John Doe john.doe@xyz The Majestic Sonlar OLD CHURCH King Mixilplyx Tronchi (nt), Troncha (c) TRONCHA TRONCHI King Mixilplyx continued to increase his holdings in the area. He also ordered that defensive fortifications be buiklt through-out his nation. prince Andrew came of age, and was given a nice party. John Doe john.doe@xyz The People who live in Tsin OLD CHURCH King Francis, the limp Pohai (f) Tilos (f) POHAI (F) TILOS King Francis was very worried. "No tax revenue, no tax revenue. How will I pay my military. I must get those tax collectors motivated. I know, I'll kill one of them. That will get the others in line. " Then he called in his favorite Captain. " The treasury lacks the money to pay the troops." "Well Sire, just make sure they are well fed, and maybe most will wait." "Oh, thats it, we will sell off the surplus grain, Yes,Yes, ohhhhhh Yes" And thus, a national disaster was avoided. Arthur "two sheds" Jackson was sent to Pohi to increase loyalty in the region. Tim "the enchanter" secured the loyalty of Tilos. In Ye a rather strange thing happened. The leader of the region went completly mad and had to be locked in his bedchambers in his castle for the rest of his life ... chewing on pillows and screaming about the "swine horde of the north". His eldest son Delores (he really wanted a girl) took over the day to day business of Ye for him. John Doe john.doe@xyz The Compact of Kudat ANKH King Boris , tamer of the wild boar open nation John Doe john.doe@xyz The Protectorate of Ios ANKH King Gonad, the Venerator Akti (t) AKTI Prince Ralph was given the responsibility of making sure the tax collectors were doing their jobs correctly. Meanwhile King Gonad ent out to continue gathering slaves. The slaves that would continue to make Ios the most beautiful region in Tarsha. At least to those people in Ios who aren't slaves. Bob, the ally from Ried, went to Akti to discuss matters of state. John Doe john.doe@xyz The Vale of Volsk ANKH King Moshushu Velsk (ne), Crkua (ne), Irbit (nt), Serry (fa) IRBIT SERRY VELSK CRKUA Rothgar, the brother of Moshushu, went out riding with Moshushu's son. They were asttacked by bandits. Rothgar died. Ventos took his place as the heir to the Vale. The ally from Buzau was sent to explore the land. In Athes he found Orcs, so the rest of his plans were cancelled. The ally from Serry was sent out to gather slaves. He was rather taken by the looks of one of the young women in Hulst. As it turned out she did not appreciate his interest. She killed him in his sleep. The region of Serry felt now was a good time to distance themselves from the Vale. John Doe john.doe@xyz The Shmmering Shores of Sasyk OLD CHURCH King Kalr, the scourge of the seas Lanchow (ne), Husi (fa), Odesa (nt), Uryu (fa) HUSI ODESA LANCHOW URYU After years of araiding King Kalr decides to take a break and expand the empire. With this in mind he sets sail for the island of Lanchow, while sending his uncle to Husi and the Tulaneese ally to Uryu and then Amoy to Explore. His trip to Uryu was succesfull, but in Amoy he found Orcs. Before his departure King Kalr orders public projects built in Clan Hold, Odesa, and Norda. He also informs his eldest son Kalr II that he is to become the heir after his great-uncle Kalna retires to become the governor of the City-state of Odesa. John Doe john.doe@xyz The Council at Melnik TARQ King Lomax open nation John Doe john.doe@xyz The Sirnan Council ANKH Unknown Ruler open nation John Doe john.doe@xyz The Wild Kingdom of Boul ANKH King Thorkell Ipin (a) IPIN The duties of the government occupied King Thorkell. Shir Kahn was sent out to gather slaves. Zhearer was sent to explore. We went into Schio only to find Orcs. Undaunted he went into Wuti, and to his great surprise, found more Orcs. XML-EasyOBJ-1.12/t/elements.t0100644000076400010400000000105607520557426014073 0ustar default use strict; use Test; use XML::EasyOBJ; use FindBin qw/$Bin/; BEGIN { plan tests => 7 } ok( my $doc = XML::EasyOBJ->new( "$Bin/read.xml" ) ); ok( my @maps = $doc->MAP, 6 ); ok( my @elements = $doc->MAP(0)->KINGDOM(0)->getElement(), 6 ); ok( $doc->MAP(0)->KINGDOM(0)->getElement()->getTagName, 'PLAYER' ); ok( $doc->MAP(0)->KINGDOM(0)->getElement('',2)->getTagName, 'RELIGION' ); my $list = ''; for ( @elements ) { $list .= $_->getTagName; } ok( $list, 'PLAYERNAMERELIGIONRULERDIPLOMACYNOTES' ); ok( ! $doc->MAP(0)->KINGDOM(0)->getElement('',6) ); XML-EasyOBJ-1.12/t/read.xml0100644000076400010400000007604607520557426013542 0ustar default John Doe john.doe@xyz The Anfo Nation HUMAN PAGAN King Leopold open nation John Doe john.doe@xyz The Grand Duchy of Gistel SEEKER Grand Duke Trantolus, Overlord of the West Zrjpe (f) ZRJPE A messenger arrived at the court of the Grand Duke. He had been sent by Doran, Cheif Elder of the Old Church. The message was simple, the Old Church would not stand by while its nations were attacked. The Duke decided to look towards the future of his nation. The messangers ran quickly between Doran and the Duke. The Cheif Elder made his postion clear "Withdraw or suffer a Holy War". The Duke demanded that the Old Church not interfere with his aquisition of the penninsula. After much debate the issue was finally setteled. Gistell forces withdrew from Velsen. The Island Defense Agreement was signed. Chu-Lon, Sonlar, Tearsh,Norta and Gistel signed the IDA. In other news Princes Moira travelled to the region of Zrjpe. She was taken by a young man who happend to be a nobleman of the region. The Grand Duke arrainged a marriage. The Bishop Toben was nearby. He gladly made time to officiate at the ceremony. John Doe john.doe@xyz The Socdom of Hechtel TARQ Soclord Magedo Vught (ne), Wijk (ne) WIJK VUGHT The Soclord left his government in the hands of his Heir Lucretia. He travelled to some of his lands but moved around to quickly to have any effect. While in Vught he received even worse news, Lucretia had taken ill and passed away. Maximus Thrax was snet to gather more slaves to improve the region of Hechtel. John Doe john.doe@xyz The Julich Tribes SEEKER King Replevin the Clan Lord Buir (a), Liers (f), BUIR LIERS Prince Welsen was put in charge of the government. He was worried about the financial state of the nation that he would one day lead. So, he built a bank in Hainos and a Merchant's Guild in Canay. The King spent his time enjoying his wife and newest son. The various clan leaders were sent to improve relations. John Doe john.doe@xyz Ancient Empire of the Dragon TARQ King Nokolai II, Dreadlord open nation John Doe john.doe@xyz The Mighty Empire of Vruda Ungeria OLD CHURCH King Wilbur, of the House of Unger, High Tribunal, Grand Executive, Holder of the Axe, Defender of the Faith, Great Chief of the Barbarian Swine Horde Soltsky (t) SOLTSKY King Wilbur grows ever more paranoid, as threats of war and the Elbar resonate in his royal ears. Accordingly, the KIng of Vruda directs the royal treasurer to divert funds towaards improving the Empies defenses. In particular, a fighter's guild is constructed amongst the barbarian backwoods in Mead Hall, Slotsky. The diplomat from Narva will be there, to make the necessary and proper opening ceremony speeches between draughts of corn ale and honey mead. Wilbur and son Edwin will meanwhile soberly attend to the running of the nation. The Wizard of Robur will ply his new skills, magicking the fields to build reservoirs and better drain the city sewerage. John Doe john.doe@xyz The Mighty Realm of Krosno ANKH King Grindall Dukla (rebels) King Elendil had many fine plans. He ordered that some new trails be built to help encourasge the farmers to bring their wares to market. In the process he eat some unclean fruit and took ill. As he passed away with no heir, the country went into turmoil. When it was all over Dukla had broken away from the kingdom, and Grindall had seized power. John Doe john.doe@xyz The Seadragon Rank of Lahti MESSENGER King Faz-Katu IV, First of the Rank, Crowned Despot of All Seadragons open nation John Doe john.doe@xyz The Kingdom of Torun OLD CHURCH King James Chipka (c), Lipno (c) CHIPKA LIPNO King James ordered that the slaves build irrigation ditches and move rocks, and plant wheat. He then looked at his map. "West of Torun are a couple of trade centers that I wish to control." So he launched the Merchant War. 5000 swordsmen,1000 well-trained cavalry, 1500 elite swordsmen, and 3000 horsebowman led into battle by King James. King Hawke's forces numbered 7500 swordsmen. The Merchant War Spring 226- The Toruneese Horsebowman kill 1000 Cesenian troops. Then the two sides charge. 4000 Cesenians die compared to only 2500 Toruneese. Summer 226- Arrows kill 500 more Cesenians. The Toruneese are in control of the field. The final charge is masterfully handeled. All 2000 remaining Cesenians die. With the loss of only 500 Toruneese. Aftermath- The Cesenians are now under the control of Torun. John Doe john.doe@xyz The Garden of Klodawa MESSENGER King Bailey, Prince of the Free Peoples none King Bailey increased his army and his royal family. The Princess Karma was sent to explore the outlying regions. In Stegna he found the Old Church. In Turku he discovered followers of the Blood Cult. In Kalisz he saw people seeking the True Path. John Doe john.doe@xyz The Dell of Decin MESSENGER King Alfred none News from the Dell of Decin. New lands liberated. Princess Destiny getting a fine eduaction.Prince Blada killed in a training exercise. King Alfred announces "The Dell is producing the finest apples and blueberries in the world, along with that new stuffed toy the royal inventors mage for Destiny. I think they call it a "Furrby". Why dont more nations wish to trade with us?" King Alfred gathers his army of 11,500 swordsmen and conquers Plzen. He then aadds 2500 archers and 500 lancers, and conquers Detva. John Doe john.doe@xyz The Cesenian League HUMAN PAGAN King Hawke none Destoyed in the Merchant War. John Doe john.doe@xyz The Church of the Anhk ANKH High Priest Dathinius Ebra (ab), Ulm (ab) EBRA ULM Selene begins by declaring Dathinius as heir to the leadership of the Church, the orders missionaires to Ulm to expand the vision of the Anhk family. Then she travelled to Ebra. She was completly taken by the beauty of the area. She finds a very lovely forest that captures her attention. In this place she takes her last breath. An abbey is built on the spot. Dathinius begins to search the surrounding areas. He sneaks into Narial only to discover pagans. Undauted he goes into Stormwer, but there he finds elves. John Doe john.doe@xyz The Regal Realm of Rostow SEEKER King Raash, Seeker of the Strange Aliev (c) ALIEV Prince Jarosh was starting to bet a liitle bored with his royal lifestyle. So he sneaked off to spend some time in more local areas of Delmop. While visiting The Drowned Rat, a local pub, Prince Jarosh was accidentily killed in the middle of a dispute regarding a young brunette. King Raash was not happy at all. " I will make these cities safer for my people." City walls were built for all three cities in the land, and troops were stationed in key areas. Then he diplomacized Aliev. John Doe john.doe@xyz The Naughty Neserea TARQ Unknown Ruler open nation John Doe john.doe@xyz The Peoples Republic of Yzer OLD CHURCH Unknown Ruler open nation John Doe john.doe@xyz The Golden Empire of Khatai ANKH King Chenchun Dumaria (fa) DUMARIA King Chenchun was watching the workers beautify Lauria City. When a young man told him there was exciting news down at the docks. Men had arrived with the head of King Jarimor. This was exciting news for King Chenchun, so he raced to the docks. There he was met by the men. They said they were envoys of Vruda. "We took our army to investigate hereitc rumblings to the north. There we observed what we thought to be rituals of Tarq. As the only good follower of Tarq is a dead follower, we killed them all. Then we rumaged through their belongings and found relics of Elbar. So we came here with the head of King Jarimor to claim the reward. King Jarimor is dead, long live the Old Church." KIng Chenchun was very happy. "Lets open some corn ale and toast this victory" The men looked at the king and said "show us the way to the ale." The King, knowing that all Vrudanesse sailors always carry plenty of corn ale in ther ships, and never drink from other peoples kegs. He killed them. " FIND ME KING JARIMOR!!!!!!!!" Duke Pelara looked in the region of Morwen. He found some shady characters, but the killed as a message to keep away from the local underworld, not because they were Tarq spies. His home region of Dumaria, scared by the underworld, distanced themselves from the king. Duke Mulwar found nothing in Mittfel. Duke Krellius was looking in the region of Encora when he found a rather odd item. A helm of strange design. He placed it on his head and was consumed by flame. A local peasent carefully transported the helm to King Chenchun. John Doe john.doe@xyz The Kingdom of Balto HUMAN PAGAN Unknown Ruler open nation John Doe john.doe@xyz The Gruzz TARQ King Gruzz the XI open nation John Doe john.doe@xyz The United Tribes of Diol OLD CHURCH King Hector, His Royal Highness, The Emerald King none The nation was not active. John Doe john.doe@xyz The Spirits of the Pristine Woods OLD CHURCH Doran, Chief Elder of the Old Church Sonlar (ca), Sasyk (mn), Lepel (mn), Vruda (ab) VRUDA LEPEL SASYK SONLAR Enraged by Gistel's invasion of Velsen, Doran set the wheels in motion to bring Velsen back its freedom, by any means necessary. Emissaries flew between the Chief Elder and the Grand Duke. As the deadline for peace approached, it became apparent that the Duke was willling to deal. Tensions throught the lands of Tarsha were high, when at the last moment, Doran announced that an agreement had been reached with the Duke. Gistel would withdraw from Velsen. The nations of Chu-Lon,Tearsh,Sonlar,Norta and Gistel would also sign a mutual defense compact known as the Island Defense Agreement or IDA. This settled, the Chief Elder had time to concentrate on other matters. He placed a HUGE bounty on the head of King Jarimor of Elbar. Any nation that discovers, reports the location of and aids in the destruction of the fugitive nation will benefit handsomely. John Doe john.doe@xyz The Terrible Twoja TARQ Unknown Ruler open nation John Doe john.doe@xyz The Serene Land of Kas OLD CHURCH King Samuel, the Serene One none As the workers began to look over the plans for a merchants guild, they realized there was something missing, a bank! So, they built a bank instead. The region of Yutu was explored and happily it was found to be Old Church. Much of King Samuel's time was spent with his royal family. The region of Kas was improved slightly, to compete with Ios. The really important news came from the university where they had learned much about Ironworking. Thus heralding the advance to tech level three. John Doe john.doe@xyz The Glorious Gollel TARQ Unknown Ruler open nation John Doe john.doe@xyz The Duchy of Aragon OLD CHURCH Duke Rostow II, Patron of the arts Duru (t), Kelo (t) DURU KELO A bank was built in Aragon. Prince Derek was sent on a diplomatic mission, as was Count Balck.The region of Bili was improved and Rostow II spent his money on investing in the future of his nation. John Doe john.doe@xyz The Sacrifice Gatherers of Tarq. (formerly Carnot) TARQ Blood Marshal Alstair Vyborg (ea) VYBORG The government of Carnot required the Blood Marshal's full attention. He sent Blynder, Prince of the seven hues of Red, along with Dumjon De'mon, Fang Searcher and Red-Robed Seeker to secure the region of Vyborg. The army was increased by the addition of the Red Wizards unit. John Doe john.doe@xyz The Confederacy of Mopti SEEKER Unknown Ruler open nation John Doe john.doe@xyz The Red Church TARQ Grand Shaman Holtech, The Prophet of Tarq, Keeper of the Sacred Scrolls none open nation John Doe john.doe@xyz The Kingdom of Faldo HUMAN PAGAN King Nick Faldo, Monarch of Faldo Senla (a) SENLA Deciding to learn the secrets of the long forgotten wisdom of the elders, King Nick sat at his desk to study. Leaving orders not to be disturbed unless the NCAA tourney was on the tele, Knig Nick studied diligintley day and night. Ian attempted to bring Senla into the fold by offering discounted memberships...assuming reciprocity would soon follow. Collin, dismayed by the lack of caddies had a thought. " Would it not be better if the Orcs were carying our clubs instead of trying to hit us with clubs?" So he went in search of orcs. He found some, and realized it was a bad idea. Clarke was intrigued by the books the King was reading, who grew annoyed at someone reading over his shoulder, so he gave him his own book. Neither one learned anything usefull. John Doe john.doe@xyz The Seekers of the True Path SEEKER Prime Seeker Norkell Temor (ab), Seldon (ab) SELDON TEMOR Studying maagic was all well and good, but at times it was amazxingly boring. Some activity would do the Prme Seeker good. his planned route took him to various places on the island. With joy he saw the seeker people emmbraace the Path. He was able to build religious sites on the island. Once in a while Bishop Toben woul;d send a message to the Prime Seeker about the activities on the Western Front. The people of Zrjpe and Gistel were looking forward to the marriage of the princess Moria. She was to be wed in the region of Zrjpe in the year 226 S.C. Toben was excited as this was one of the few chances he would have to proside over a royal function. He sought out the people of Gistel to assist them in the signing of the Island Defense Pact. Then he let his wonderings take him to the region of Dovai, where he found the Church of the Anhk. Some young priests were sent to Faldo in hopes that they would consider changing their pagan ways to Seek the True Path. John Doe john.doe@xyz The Glittering Chu-Lon OLD CHURCH Sir Zembar, Regent for his royal personage none Sir Zembar looked after the affairs of the state for his two young charges, the Princess Gwyneth and the Prince Valon. Knowing the pain of the people durinf the 10 year war, and with the loss of two kings, he made it his special purpose to thank the Chu-Lonoins for their support and promises that one day soon, we will be able to live peaceful rich lives. He also spent money to plant flowers at the various battle sites of the war. John Doe john.doe@xyz The Kingdom of Tearsh OLD CHURCH King Antipode none open nation John Doe john.doe@xyz The Northern Ice Kingdom of Kal SEEKER King Kal, the founder none Kal was claimed off waivers by John Smith. John Doe john.doe@xyz The Island People of Norta OLD CHURCH King Norton, the Great none King Norton built a mages guild around the shrine to the Old Church that he had built back in 223 S.C. The shrine itself was also expanded. It looks as if the shrine could engulf the abbey that exsists there. It is noted by many that the shrine generates a healthy feeling in all who spend time there. This could be true, or just a feeling-only the gods know for sure. King Norton prolcaimed "Long live the Old Church" John Doe john.doe@xyz The Majestic Sonlar OLD CHURCH King Mixilplyx Tronchi (nt), Troncha (c) TRONCHA TRONCHI King Mixilplyx continued to increase his holdings in the area. He also ordered that defensive fortifications be buiklt through-out his nation. prince Andrew came of age, and was given a nice party. John Doe john.doe@xyz The People who live in Tsin OLD CHURCH King Francis, the limp Pohai (f) Tilos (f) POHAI (F) TILOS King Francis was very worried. "No tax revenue, no tax revenue. How will I pay my military. I must get those tax collectors motivated. I know, I'll kill one of them. That will get the others in line. " Then he called in his favorite Captain. " The treasury lacks the money to pay the troops." "Well Sire, just make sure they are well fed, and maybe most will wait." "Oh, thats it, we will sell off the surplus grain, Yes,Yes, ohhhhhh Yes" And thus, a national disaster was avoided. Arthur "two sheds" Jackson was sent to Pohi to increase loyalty in the region. Tim "the enchanter" secured the loyalty of Tilos. In Ye a rather strange thing happened. The leader of the region went completly mad and had to be locked in his bedchambers in his castle for the rest of his life ... chewing on pillows and screaming about the "swine horde of the north". His eldest son Delores (he really wanted a girl) took over the day to day business of Ye for him. John Doe john.doe@xyz The Compact of Kudat ANKH King Boris , tamer of the wild boar open nation John Doe john.doe@xyz The Protectorate of Ios ANKH King Gonad, the Venerator Akti (t) AKTI Prince Ralph was given the responsibility of making sure the tax collectors were doing their jobs correctly. Meanwhile King Gonad ent out to continue gathering slaves. The slaves that would continue to make Ios the most beautiful region in Tarsha. At least to those people in Ios who aren't slaves. Bob, the ally from Ried, went to Akti to discuss matters of state. John Doe john.doe@xyz The Vale of Volsk ANKH King Moshushu Velsk (ne), Crkua (ne), Irbit (nt), Serry (fa) IRBIT SERRY VELSK CRKUA Rothgar, the brother of Moshushu, went out riding with Moshushu's son. They were asttacked by bandits. Rothgar died. Ventos took his place as the heir to the Vale. The ally from Buzau was sent to explore the land. In Athes he found Orcs, so the rest of his plans were cancelled. The ally from Serry was sent out to gather slaves. He was rather taken by the looks of one of the young women in Hulst. As it turned out she did not appreciate his interest. She killed him in his sleep. The region of Serry felt now was a good time to distance themselves from the Vale. John Doe john.doe@xyz The Shmmering Shores of Sasyk OLD CHURCH King Kalr, the scourge of the seas Lanchow (ne), Husi (fa), Odesa (nt), Uryu (fa) HUSI ODESA LANCHOW URYU After years of araiding King Kalr decides to take a break and expand the empire. With this in mind he sets sail for the island of Lanchow, while sending his uncle to Husi and the Tulaneese ally to Uryu and then Amoy to Explore. His trip to Uryu was succesfull, but in Amoy he found Orcs. Before his departure King Kalr orders public projects built in Clan Hold, Odesa, and Norda. He also informs his eldest son Kalr II that he is to become the heir after his great-uncle Kalna retires to become the governor of the City-state of Odesa. John Doe john.doe@xyz The Council at Melnik TARQ King Lomax open nation John Doe john.doe@xyz The Sirnan Council ANKH Unknown Ruler open nation John Doe john.doe@xyz The Wild Kingdom of Boul ANKH King Thorkell Ipin (a) IPIN The duties of the government occupied King Thorkell. Shir Kahn was sent out to gather slaves. Zhearer was sent to explore. We went into Schio only to find Orcs. Undaunted he went into Wuti, and to his great surprise, found more Orcs. XML-EasyOBJ-1.12/EasyOBJ.pm0100644000076400010400000005057107520557424013425 0ustar default =head1 NAME XML::EasyOBJ - Easy XML object navigation =head1 VERSION Version 1.12 =head1 SYNOPSIS # open exisiting file my $doc = new XML::EasyOBJ('my_xml_document.xml'); my $doc = new XML::EasyOBJ(-type => 'file', -param => 'my_xml_document.xml'); # create object from XML string my $doc = new XML::EasyOBJ(-type => 'string', -param => $xml_source); # create new file my $doc = new XML::EasyOBJ(-type => 'new', -param => 'root_tag'); # read from document my $text = $doc->some_element($index)->getString; my $attr = $doc->some_element($index)->getAttr('foo'); my $element = $doc->some_element($index); my @elements = $doc->some_element; # first "some_element" element my $elements = $doc->some_element; # list of "some_element" elements my @elements = $doc->some_element; # write to document $doc->an_element->setString('some string') $doc->an_element->addString('some string') $doc->an_element->setAttr('attrname', 'val') $doc->an_element->setAttr('attr1' => 'val', 'attr2' => 'val2') # access elements with non-name chars and the underlying DOM my $element = $doc->getElement('foo-bar')->getElement('bar-none'); my $dom = $doc->foobar->getDomObj; # get elements without specifying the element name my @elements = $doc->getElement(); my $sixth_element = $doc->getElement('', 5); # remove elements/attrs $doc->remElement('tagname', $index); $doc->tag_name->remAttr($attr); # remap builtin methods $doc->remapMethod('getString', 's'); my $text = $doc->some_element->s; =head1 DESCRIPTION I wrote XML::EasyOBJ a couple of years ago because it seemed to me that the DOM wasn't very "perlish" and the DOM is difficult for us mere mortals that don't use it on a regular basis. As I only need to process XML on an occasionally I wanted an easy way to do what I needed to do without having to refer back to DOM documentation each time. A quick fact list about XML::EasyOBJ: * Runs on top of XML::DOM * Allows access to the DOM as needed * Simple routines to reading and writing elements/attributes =head1 REQUIREMENTS XML::EasyOBJ uses XML::DOM. XML::DOM is available from CPAN (www.cpan.org). =head1 METHODS Below is a description of the methods avialable. =cut package XML::EasyOBJ; use strict; use XML::DOM; use vars qw/$VERSION/; $VERSION = '1.12'; =head2 new You can create a new object from an XML file, a string of XML, or a new document. The constructor takes a set of key value pairs as follows: =item -type The type is either "file", "string" or "new". "file" will create the object from a file source, "string" will create the object from a string of XML code, and "new" will create a new document object. =item -param This value depends on the -type that is passed to the constructor. If the -type is "file" this will be the filename to open and parse. If -type is "string", this is a string of XML code. If -type is "new", this is the name of the root element. Creating an object from an XML file: my $doc = new XML::EasyOBJ(-type => 'file', -param => 'my_xml_document.xml'); Creating an object from a string containing the XML source: my $doc = new XML::EasyOBJ(-type => 'string', -param => $xml_source); Creating a new XML document by passing the root tag name: my $doc = new XML::EasyOBJ(-type => 'new', -param => 'root_tag'); =item -expref Passing a value of 1 will force the expansion of references when grabbing string data from the XML file. The default value is 0, not to expand references. Obtionally you may also pass the filename to open as the first argument instead of passing the -type and -param parameters. This is backwards compatable with early version of XML::EasyOBJ which did not handle -type and -param parameters. my $doc = new XML::EasyOBJ('my_xml_document.xml'); =cut sub new { my $class = shift; # container for DOM object my $doc = ''; # expand references flag. true to expand. my $expref = 0; # if there are an odd number of parameters, take the first # argument as a filename. if ( scalar(@_) % 2 ) { my $file = shift; my $parser = new XML::DOM::Parser; $doc = $parser->parsefile( $file ) || return; } # if there are an even number of arguments, treat them as # hash name/value pairs. else { my %args = @_; # check for "expand references" flag, and set $expref $expref = 1 if ( exists $args{-expref} and $args{-expref} == 1 ); # create DOM from file, param is filename if ( $args{-type} eq 'file' ) { my $parser = new XML::DOM::Parser; $doc = $parser->parsefile( $args{-param} ) || return; } # create a new DOM object, param is root element name elsif ( $args{-type} eq 'new' ) { $doc = new XML::DOM::Document(); $doc->appendChild( $doc->createElement( $args{-param} ) ); } # create DOM from string elsif ( $args{-type} eq 'string' ) { my $parser = new XML::DOM::Parser; $doc = $parser->parse( $args{-param} ) || return; } else { return; } } # set method mappings, may be changed by remapMethod method my %map = ( getString => 'getString', setString => 'setString', addString => 'addString', getAttr => 'getAttr', setAttr => 'setAttr', remAttr => 'remAttr', remElement => 'remElement', getElement => 'getElement', getDomObj => 'getDomObj', remapMethod => 'remapMethod', getTagName => 'getTagName', ); return bless( { 'map' => \%map, 'doc' => $doc, 'ptr' => $doc->getDocumentElement(), 'expref' => $expref, }, 'XML::EasyOBJ::Object' ); } package XML::EasyOBJ::Object; use strict; use XML::DOM; use vars qw/%SUBLIST %INTSUBLIST $AUTOLOAD/; $AUTOLOAD = ''; %SUBLIST = (); %INTSUBLIST = (); sub DESTROY { local $^W = 0; my $self = $_[0]; $_[0] = ''; unless ( $_[0] ) { $_[0] = $self; $AUTOLOAD = 'DESTROY'; return AUTOLOAD( @_ ); } } sub AUTOLOAD { my $funcname = $AUTOLOAD || 'AUTOLOAD'; $funcname =~ s/^XML::EasyOBJ::Object:://; $AUTOLOAD = ''; if ( exists $_[0]->{map}->{$funcname} ) { return &{$SUBLIST{$_[0]->{map}->{$funcname}}}( @_ ); } my $self = shift; my $index = shift; my @nodes = (); die "Fatal error: lost pointer!" unless ( exists $self->{ptr} ); for my $kid ( $self->{ptr}->getChildNodes ) { if ( ( $kid->getNodeType == ELEMENT_NODE ) && ( $kid->getTagName eq $funcname ) ) { push @nodes, bless( { map => $self->{map}, doc => $self->{doc}, ptr => $kid, expref => $self->{expref}, }, 'XML::EasyOBJ::Object' ); } } if ( wantarray ) { return @nodes; } else { if ( defined $index ) { unless ( defined $nodes[$index] ) { for ( my $i = scalar(@nodes); $i <= $index; $i++ ) { $nodes[$i] = bless( { map => $self->{map}, doc => $self->{doc}, ptr => &{$INTSUBLIST{'makeNewNode'}}( $self, $funcname ), expref => $self->{expref}, }, 'XML::EasyOBJ::Object' ) } } return $nodes[$index]; } else { return bless( { map => $self->{map}, doc => $self->{doc}, ptr => &{$INTSUBLIST{'makeNewNode'}}( $self, $funcname ), expref => $self->{expref}, }, 'XML::EasyOBJ::Object' ) unless ( defined $nodes[0] ); return $nodes[0]; } } } =head2 makeNewNode( NEW_TAG ) Append a new element node to the current node. Takes the tag name as the parameter and returns the created node as a convienence. my $p_element = $doc->body->makeNewNode('p'); =cut $INTSUBLIST{'makeNewNode'} = sub { my $self = shift; my $element_name = shift; return $self->{ptr}->appendChild( $self->{doc}->createElement($element_name) ); }; =head2 remapMethod( CUR_METHOD, NEW_METHOD ) Allows you to change the name of any of the object methods. You might want to do this for convienience or to avoid a naming collision with an element in the document. Two parameters need to be passed; the current name of the method and the new name. Returns 1 on a successful mapping and undef on failure. A failure can result if you don't pass two parameters if if the "copy from" method name does not exist. $doc->remapMethod('getString', 's'); $doc->s(); After remapping you must use the new name if you with to remap the method again. You can call the remapMethod method from any place in the XML tree and it will always change the method globally. In the following example $val1 and $val2 are equal: $doc->some_element->another_element->('getString', 's'); my $val1 = $doc->s(); $doc->remapMethod('s', 'getString'); my $val2 = $doc->getString(); =cut $SUBLIST{remapMethod} = sub { my $self = shift; my ( $from, $to ) = @_; die "Fatal error: lost the pointer!" unless ( exists $self->{ptr} ); return unless ( ( $from ) && ( $to ) ); return unless ( exists $self->{map}->{$from} ); my $tmp = $self->{map}->{$from}; delete $self->{map}->{$from}; $self->{map}->{$to} = $tmp; return 1; }; =head2 getString( ) Recursively extracts text from the current node and all children element nodes. Returns the extracted text as a single scalar value. Expands entities based on if the -expref flag was supplied during object creation. =cut $SUBLIST{getString} = sub { my $self = shift; die "Fatal error: lost the pointer!" unless ( exists $self->{ptr} ); my $string = &{$INTSUBLIST{extractText}}( $self->{ptr} ); return ( $self->{expref} ) ? $self->{doc}->expandEntityRefs($string) : $string; }; =head2 extractText( ) Same as getString() but does not check the -expref flag. Included for compatability with inital version of interface. =cut $INTSUBLIST{extractText} = sub { my $n = shift; my $text; if ( $n->getNodeType == TEXT_NODE ) { $text = $n->toString; } elsif ( $n->getNodeType == ELEMENT_NODE ) { foreach my $c ( $n->getChildNodes ) { $text .= &{$INTSUBLIST{extractText}}( $c ); } } return $text; }; =head2 setString( STRING ) Sets the text value of the specified element. This is done by first removing all text node children of the current element and then appending the supplied text as a new child element. Take this XML fragment and code for example:

This elment has text and child elements

$doc->p->setString('This is the new text'); This will change the fragment to this:

textchildThis is the new text

Because the and tags are not text nodes they are left unchanged, and the new text is added at the end of the specified element. If you need more specific control on the change you should either use the getDomObj() method and use the DOM methods directly or remove all of the child nodes and rebuild the

element from scratch. Also see the addString() method. =cut $SUBLIST{setString} = sub { my $self = shift; my $text = shift; die "Fatal error: lost the pointer!" unless ( exists $self->{ptr} ); foreach my $n ( $self->{ptr}->getChildNodes ) { if ( $n->getNodeType == TEXT_NODE ) { $self->{ptr}->removeChild( $n ); } } $self->{ptr}->appendChild( $self->{doc}->createTextNode( $text ) ); return &{$INTSUBLIST{extractText}}( $self->{ptr} ); }; =head2 addString( STRING ) Adds to the the text value of the specified element. This is done by appending the supplied text as a new child element. Take this XML fragment and code for example:

This elment has text

$doc->p->addString(' and elements'); This will change the fragment to this:

This elment has text and elements

=cut $SUBLIST{addString} = sub { my $self = shift; my $text = shift; die "Fatal error: lost the pointer!" unless ( exists $self->{ptr} ); $self->{ptr}->appendChild( $self->{doc}->createTextNode( $text ) ); return &{$INTSUBLIST{extractText}}( $self->{ptr} ); }; =head2 getAttr( ATTR_NAME ) Returns the value of the named attribute. my $val = $doc->body->img->getAttr('src'); =cut $SUBLIST{getAttr} = sub { my $self = shift; my $attr = shift; die "Fatal error: lost the pointer!" unless( exists $self->{ptr} ); if ( $self->{ptr}->getNodeType == ELEMENT_NODE ) { return $self->{ptr}->getAttribute($attr); } return ''; }; =head2 getTagName( ) Returns the tag name of the specified element. This method is useful when you are enumerating child elements and do not know their element names. foreach my $element ( $doc->getElement() ) { print $element->getTagName(); } =cut $SUBLIST{getTagName} = sub { my $self = shift; die "Fatal error: lost the pointer!" unless( exists $self->{ptr} ); if ( $self->{ptr}->getNodeType == ELEMENT_NODE ) { return $self->{ptr}->getTagName; } return ''; }; =head2 setAttr( ATTR_NAME, ATTR_VALUE, [ATTR_NAME, ATTR_VALUE]... ) For each name/value pair passed the attribute name and value will be set for the specified element. =cut $SUBLIST{setAttr} = sub { my $self = shift; my %attr = @_; die "Fatal error: lost the pointer!" unless( exists $self->{ptr} ); if ( $self->{ptr}->getNodeType == ELEMENT_NODE ) { if ( scalar(keys %attr) == 1 ) { for ( keys %attr ) { return $self->{ptr}->setAttribute($_, $attr{$_}); } } else { for ( keys %attr ) { $self->{ptr}->setAttribute($_, $attr{$_}); } return 1; } } return ''; }; =head2 remAttr( ATTR_NAME ) Removes the specified attribute from the current element. =cut $SUBLIST{remAttr} = sub { my $self = shift; my $attr = shift; die "Fatal error: lost the pointer!" unless( exists $self->{ptr} ); if ( $self->{ptr}->getNodeType == ELEMENT_NODE ) { if ( $self->{ptr}->getAttributes->getNamedItem( $attr ) ) { $self->{ptr}->getAttributes->removeNamedItem( $attr ); return 1; } } return 0; }; =head2 remElement( TAG_NAME, INDEX ) Removes a child element of the current element. The name of the child element and the index must be supplied. An index of 0 will remove the first occurance of the named element, 1 the second, 2 the third, etc. =cut $SUBLIST{remElement} = sub { my $self = shift; my $name = shift; my $index = shift; my $node = ( $index ) ? $self->$name($index) : $self->$name(); $self->{ptr}->removeChild( $node->{ptr} ); }; =head2 getElement( TAG_NAME, INDEX ) Returns the node from the tag name and index. If no index is given the first child with that name is returned. Use this method when you have element names that include characters that are not legal as a perl method name. For example: test # "foo-bar" is not a legal method name print $doc->bar->getElement('foo-bar')->getString(); =cut $SUBLIST{getElement} = sub { my $self = shift; my $funcname = shift; my $index = shift; my @nodes = (); die "Fatal error: lost pointer!" unless ( exists $self->{ptr} ); foreach my $kid ( $self->{ptr}->getChildNodes ) { if ( $funcname ) { if ( ( $kid->getNodeType == ELEMENT_NODE ) && ( $kid->getTagName eq $funcname ) ) { push @nodes, bless( { map => $self->{map}, doc => $self->{doc}, ptr => $kid, expref => $self->{expref}, }, 'XML::EasyOBJ::Object' ); } } else { if ( $kid->getNodeType == ELEMENT_NODE ) { push @nodes, bless( { map => $self->{map}, doc => $self->{doc}, ptr => $kid, expref => $self->{expref}, }, 'XML::EasyOBJ::Object' ); } } } if ( wantarray ) { return @nodes; } else { $index = 0 unless ( defined $index ); if ( defined $nodes[$index] ) { return $nodes[$index]; } else { # fail if no tag name given return undef unless ( $funcname ); for ( my $i = scalar(@nodes); $i <= $index; $i++ ) { $nodes[$i] = bless( { map => $self->{map}, doc => $self->{doc}, ptr => &{$INTSUBLIST{'makeNewNode'}}( $self, $funcname ), expref => $self->{expref}, }, 'XML::EasyOBJ::Object' ) } return $nodes[$index]; } } }; =head1 getDomObj( ) Returns the DOM object associated with the current node. This is useful when you need fine access via the DOM to perform a specific function. =cut $SUBLIST{getDomObj} = sub { my $self = shift; return $self->{ptr}; }; 1; =head1 BEGINNER QUICK START GUIDE =head2 Introduction You too can write XML applications, just as long as you understand the basics of XML (elements and attributes). You can learn to write your first program that can read data from an XML file in a mere 10 minutes. =head2 Assumptions It is assumed that you are familiar with the structure of the document that you are reading. Next, you must know the basics of perl lists, loops, and how to call a function. You must also have an XML document to read. Simple eh? =head2 Loading the XML document use XML::EasyOBJ; my $doc = new XML::EasyOBJ('my_xml_document.xml') || die "Can't make object"; Replace the string "my_xml_document.xml" with the name of your XML document. If the document is in another directory you will need to specify the path to it as well. The variable $doc is an object, and represents our root XML element in the document. =head2 Reading text with getString Each element becomes an object. So lets assume that the XML page looks like this: field1a field2b field3c field1d field2e field3f
As mentioned in he last step, the $doc object is the root element of the XML page. In this case the root element is the "table" element. To read the text of any field is as easy as navigating the XML elements. For example, lets say that we want to retrieve the text "field2e". This text is in the "field2" element of the SECOND "rec2" element, which is in the FIRST "record" element. So the code to print that value it looks like this: print $doc->record(0)->rec2(1)->field2->getString; The "getString" method returns the text within an element. We can also break it down like this: # grab the FIRST "record" element (index starts at 0) my $record = $doc->record(0); # grab the SECOND "rec2" element within $record my $rec2 = $record->rec2(1); # grab the "field2" element from $rec2 # NOTE: If you don't specify an index, the first item # is returned and in this case there is only 1. my $field2 = $rec2->field2; # print the text print $field2->getString; =head2 Reading XML attributes with getAttr Looking at the example in the previous step, can you guess what this code will print? print $doc->record(0)->rec2(0)->getAttr('foo'); print $doc->record(0)->rec2(1)->getAttr('foo'); If you couldn't guess, they will print out the value of the "foo" attribute of the first and second rec2 elements. =head2 Looping through elements Lets take our example in the previous step where we printed the attribute values and rewrite it to use a loop. This will allow it to print all of the "foo" attributes no matter how many "rec2" elements we have. foreach my $rec2 ( $doc->record(0)->rec2 ) { print $rec2->getAttr('foo'); } When we call $doc->record(0)->rec2 this way (i.e. in list context), the module will return a list of "rec2" elements. =head2 That's it! You are now an XML programmer! *start rejoicing now* =head1 PROGRAMMING NOTES When creating a new instance of XML::EasyOBJ it will return an object reference on success, or undef on failure. Besides that, ALL methods will always return a value. This means that if you specify an element that does not exist, it will still return an object reference (and create that element automagically). This is just another way to lower the bar, and make this module easier to use. You will run into problems if you have XML tags which are named after perl's special subroutine names (i.e. "DESTROY", "AUTOLOAD"), or if they are named after subroutines used in the module ( "getString", "getAttr", etc ). You can get around this by using the getElement() method of using the remapMethod() method which can be used on every object method (except AUTOLOAD and DESTROY). =head1 AUTHOR/COPYRIGHT Copyright (C) 2000-2002 Robert Hanson This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO XML::DOM =cut XML-EasyOBJ-1.12/README0100644000076400010400000000261107520561440012474 0ustar defaultXML/EasyOBJ version 1.12 ======================== This module is designed to make accessing accessing an XML document rather trivial. You don't need to understand the DOM, you don't need to even know what SAX is, all you need to know is how an XML document is structured and how to program with objects (OOP). XML::EasyOBJ takes each tag in your XML file and magically converts it to a method name. So if you wanted to access the 3rd

tag inside the tag of an XHTML file you might use this: $obj->body->p(2) XML::EasyOBJ gives you several methods to extract data from elements: $obj->body->p(2)->getString; $obj->body->getAttr('bgcolor'); XML::EasyOBJ gives you several methods to set data in elements: $obj->body->p(2)->setString("Testing"); $obj->body->setAttr('bgcolor', 'red'); Obviously these "helper" methods provided won't work in every situatiuon, so you can also access the underlying DOM model if you really really need to: my $element = $obj->body->p(2)->getDomObj; INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: XML::DOM COPYRIGHT AND LICENCE Copyright (C) 2002 Robert Hanson This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. XML-EasyOBJ-1.12/MANIFEST0100644000076400010400000000015707520557424012757 0ustar defaultChanges EasyOBJ.pm Makefile.PL MANIFEST README t/read.t t/read.xml t/write.t t/synop.t t/elements.t t/string.t XML-EasyOBJ-1.12/Changes0100644000076400010400000000101707520560640013107 0ustar defaultRevision history for Perl extension XML::EasyOBJ. 1.12 Sat Jul 27 12:00:00 2002 - create from XML string - better documentation 1.11 Fri Apr 19 12:00:00 2002 - ability to retrieve child elements without naming them 1.10 Sat Mar 9 12:00:00 2002 - bug fix when adding elements to the tree. - ability to remap function names created. - ability to create new file from scratch - ability to save XML doc - ability to remove elements/attributes - added some tests 1.00 Sat Jul 29 12:00:00 2000 - original version XML-EasyOBJ-1.12/Makefile.PL0100644000076400010400000000077207520557424013603 0ustar defaultuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'XML::EasyOBJ', 'VERSION_FROM' => 'EasyOBJ.pm', # finds $VERSION 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'EasyOBJ.pm', # retrieve abstract from module AUTHOR => 'A. U. Thor ') : ()), );