Slashdot Mirror


Perl & XML

dooling writes: "Perl & XML is a well-written book that accomplishes what it sets out to do. It states in the preface that it is written for Perl programmers who want to learn about XML and what is available in Perl for XML processing. It achieves this goal, but little else. When you are done reading this book you will have been given an overview of Perl and XML, know where to begin to attack an XML document, and know where to look to find more information." For dooling's more complete review, read on below. Perl & XML author Erik T. Ray & Jason McIntosh pages 202 publisher O'Reilly and Associates rating 6 reviewer dooling ISBN 059600205X summary Good introduction to XML for Perl programmers.

The book starts out with a brief explanation of why XML and Perl are well-suited for each other. It then provides a teaser of things to come: an explanation of how to use the XML::Simple module. The first chapter concludes with some warnings and gotchas that seem a little premature since they have not really explained XML. Fortunately, most of these gotchas are covered in context later in the book.

The second chapter provides a whirlwind overview of XML -- covering its structure, DTDs, schemas, and XSLT (transformation). The discussion of XML in general, its history, and parts of an XML document are well done. They give someone who is familiar with static HTML the needed background to understand the structure of an XML document and the vocabulary used to describe it. Unfortunately, the discussion of where XML begins to distinguish itself from HTML, namely with DTDs, the new replacement for DTDs called schemas, and the transformation language XSLT, is too brief. They gloss over these topics with little explanation and few examples. That said, there are other books that do provide more in-depth coverage of XML (this book only promises an introduction).

The next five chapters cover Perl modules designed to process XML, starting with simple parsers and writers. Only methods and syntax relating to XML processing are explained. Therefore, if you are considering reading this book, you should be fairly comfortable with Perl and object-oriented (OO) interfaces to CPAN modules (nearly all the modules discussed provide OO APIs). Again, there are other books and perldoc documentation that cover Perl and it's OO features; so read them first if you are not familiar with OO Perl. If you are familiar with OO Perl, these chapters provide a good overview of the different ways XML can be processed (stream- and tree-based approaches), the advantages and disadvantages of each, and the Perl modules best suited for each approach. These chapters are the biggest strength of this book. The modules discussed in these chapters are by no means an exhaustive list of XML-related modules available from CPAN nor do the explanations of each module cover everything the module does. These chapters do, however, provide the reader with enough information that she can begin to process XML documents intelligently and know where to turn when she needs more information.

The next chapter, Chapter 8, covers XML tree iterators, XPath, XSLT, and XML::Twig. All of these topics are covered in a span of 16 pages (with only slightly over two pages dedicated to XSLT). Indeed, after reading the chapter, you may get the feeling that it was only included so the authors could cram more trite colloquialisms into the book. The short shrift given to these topics creates the impression, which is strengthened in the chapters that follow, that this book was rushed a bit to press.

Chapter 9 discusses applications of XML, including RSS and SOAP, and Chapter 10 is mostly example code. These chapters are intended to give you a feeling for what is possible without really giving you enough information to make it happen. The main problem with these chapters are the examples: the examples are long and the explanations are short. Thus, they are more useful as templates or a quick reference than for learning these topics in detail. Of course, the authors never promised you would be programming SOAP applications when you were done reading this book. And again, there are other books out there which discuss these topics in more detail. So the authors stay true to their promise throughout the book: they will introduce you to XML and tell you how to interact with XML using Perl, no more.

Personally, I found this book did, in general, give me enough information to get started using XML and pointed me where I needed to go to get more information. I am an experienced Perl programmer who is new to XML and comfortable with on-line documentation. This book seems to be written for people who fit this profile and who want to learn by doing (finding the answers to the "hard" questions as they arise). It does introduce a wide variety of XML-related topics and the Perl modules used to interact with them, which is what the authors promised to do in the preface. While it is by no means an authoritative text on Perl and XML, there is something to be said for keeping promises ...

Index As with most first-edition books, the index was adequate but not complete. For example, XML::Twig, which has an entire section covering it, does not appear in the index at all.

Contents
Preface

  1. Perl and XML
    • Why Use Perl with XML?
    • XML Is Simple with XML::Simple
    • XML Processors
    • A Myriad of Modules
    • Keep in Mind ...
    • XML Gotchas
  2. An XML Recap
    • A Brief History of XML
    • Markup, Elements, and Structure
    • Namespaces
    • Spacing
    • Entities
    • Unicode, Character Sets, and Encodings
    • The XML Declaration
    • Processing Instructions and Other Markup
    • Free-Form XML and Well-Formed Documents
    • Declaring Elements and Attributes
    • Schemas
    • Transformations
  3. XML Basics: Reading and Writing
    • XML Parsers
    • XML::Parser
    • Stream-Based Versus Tree-Based Processing
    • Putting Parsers to Work
    • XML::LibXML
    • XML::XPath
    • Document Validation
    • XML::Writer
    • Character Sets and Encodings
  4. Event Streams
    • Working with Streams
    • Events and Handlers
    • The Parser as Commodity
    • Stream Applications
    • XML::PYX
    • XML::Parser
  5. SAX
    • SAX Event Handlers
    • DTD Handlers
    • External Entity Resolution
    • Drivers for Non-XML Sources
    • A Handler Base Class
    • XML::Handler::YAWriter as a Base Handler Class
    • XML::SAX: The Second Generation
  6. Tree Processing
    • XML Trees
    • XML::Simple
    • XML::Parser's Tree Mode
    • XML::SimpleObject
    • XML::TreeBuilder
    • XML::Grove
  7. DOM
    • DOM and Perl
    • DOM Class Interface Reference
    • XML::DOM
    • XML::LibXML
  8. Beyond Trees: XPath, XSLT, and More
    • Tree Climbers
    • XPath
    • XSLT
    • Optimized Tree Processing
  9. RSS, SOAP, and Other XML Applications
    • XML Modules
    • XML::RSS
    • XML Programming Tools
    • SOAP::Lite
  10. Coding Strategies
    • Perl and XML Namespaces
    • Subclassing
    • Converting XML to HTML with XSLT
    • A Comics Index
Index

You may also want to check out Erik T. Ray's home page, Jason McIntosh's home page, or O'Reilly's page for the book. You can purchase Perl &amp XML from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

12 of 125 comments (clear)

  1. Gene Kan, Gnutella creator, dead at 25 by Anonymous Coward · · Score: -1, Offtopic

    I just heard some sad news on talk radio -
    Gnutella creator Gene Kan was found dead in his California home this morning. There weren't any more details. I'm sure everyone in the Slashdot community will miss him - even if you didn't enjoy his work, there's no denying his contributions to popular culture. Truly an American icon.

    1. Re:Gene Kan, Gnutella creator, dead at 25 by Anonymous Coward · · Score: -1, Offtopic

      Too controversial since MS renewed their marketing plan with certain "provisions". Oh well, they have to make money somehow. I wonder what MS will do when they realize that these guys are serving up single pixle graphics" as "ads".

      micr5001en.gif - micr5017en.gif
      and
      micr6001en.gif - micr6003en.gif

      Guess when a company is desperate to pay the bills they will do anything to make a buck.
      R-W-S

  2. First XML app by Anonymous Coward · · Score: -1, Offtopic

    #! /usr/bin/perl

    print

    EOF

  3. Re:Gene Kan, Gnutella creator, dead at 25 [OT] by Anonymous Coward · · Score: -1, Offtopic
  4. First culinary post by Anonymous Coward · · Score: -1, Offtopic

    I like lobster.

  5. XML, whatever by Anonymous Coward · · Score: -1, Offtopic
    sex with donkeys: it's not just for breakfast any more.

    Speaking of fucking donkeys, I'd like to give Taco's mom a perl necklace.

  6. Open Source Development HOW-TO by poopbot by Anonymous Coward · · Score: -1, Offtopic

    Credits: onby

    1. Introduction

    As everyone knows, Open Source software is the wave of the future. With the market share of GNU/Linux and *BSD increasing every day, interest in Open Source Software is at an all time high.

    Developing software within the Open Source model benefits everyone. People can take your code, improve it and then release it back to the community. This cycle continues and leads to the creation of far more stable software than the 'Closed Source' shops can ever hope to create.

    So you're itching to create that Doom 3 killer but don't know where to start? Read on!

    2. First Steps
    The most important thing that any Open Source project needs is a Sourceforge page. There are tens of thousands of successful Open Source projects on Sourceforge; the support you receive here will be invaluable.

    OK, so you've registered your Sourceforge project and set the status to '0: Pre-Thinking About It', what's next?

    3. Don't Waste Time!

    Now you need to set up your SourceForge homepage. Keep it plain and simple - don't use too many HTML tags, just knock something up in VI. Website editors like FrontPage and DreamWeaver just create bloated eye-candy - you need to get your message to the masses!

    4. Ask For Help

    Since you probably can't program at all you'll need to try and find some people who think they can. If your project is a game you'll probably need an artist too. Ask for help on your new Sourceforge pages. Here is an example to get you started:

    "Hi there! Welcom to my SorceForge page! I am planing to create a Fisrt Person Shooter game for Linux that is going to kick Doom 3's ass! I have loads of awesome ideas, like giant robotic spiders! I need some help thouh as I cant program or draw. If you can program or draw the tekstures please get in touch! K thx bye!"

    Thousands of talented programmers and artists hang out at Sourceforge ready to devote their time to projects so you should get a team together in no time!

    5. The A-Team

    So now you have your team together you are ready to change your projects status to '1: Pre-Bickering'. You will need to discuss your ideas with your team mates and see what value they can add to the project. You could use an Instant Messaging program like MSN for this, but since you run Linux you'll have to stick to e-mail.

    Don't forget that YOU are in charge! If your team doesn't like the idea of giant robotic spiders just delete them from the project and move on. Someone else can fill their place and this is the beauty of Open Source development. The code might end up a bit messy and the graphics inconsistant - but it's still 'Free as in Speech'!

    6. Getting Down To It

    Now that you've found a team of right thinking people you're ready to start development. Be prepared for some delays though. Programming is a craft and can take years to learn. Your programmer may be a bit rusty but will probably be writing "hello world" programs after school in no time.

    Closed Source games like Doom 3 use the graphics card to do all the hard stuff anyhow, so your programmer will just have to get the NVidia 'API' and it will be plain sailing! Giant robot spiders, here we come!

    7. The Outcome

    So it's been a few years, you still have no files released or in CVS. Your programmer can't get enough time on the PC because his mother won't let him use it after 8pm. Your artist has run off with a Thai She-Male. Your project is still at '1: Pre-Bickering'...

    Congratulations! You now have a successful Open Source project on Sourceforge! Pat yourself on the back, think up another idea and do it all again! See how simple it is?

    - poopbot: for all your crapflooding needs

  7. My Biased Opinion... by FortKnox · · Score: 2, Offtopic

    I think that if you are making a large enough (enterprise?) website that requires a serious amount of XML development, you should ditch perl altogether and write it in Java. Java already handles XML efficiently, and is a better choice for large apps.

    If you are writing a smaller website that uses XML, sure, perl is a nice choice. But is the XML necessary?

    And I have used (and still use) both perl and Java. I just view Java as a better choice for large web apps, and perl for small web apps and scripting.

    Before I get hit with flames, please understand this is my opinion, not fact.

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
  8. Perl by prof187 · · Score: -1, Offtopic

    One thing about Perl that I think helps keep it in competition w/ PHP is it's ability to handle POP3 so much easier. I've wanted to write a POP3 web-gateway in PHP, but I've read that to write one in PHP, switch to Perl. Granted, PHP can handle IMAP, or at least I think it can, but nothing makes getting POP3 simple, from what I've looked at, that is.

    --

    My other sig is an import.
  9. Mod this up by whynot4 · · Score: -1, Offtopic

    he only speaks the truth.

    --
    So you don't think you need to pay for things? Good luck with that.
  10. CLAIMED by Anonymous Coward · · Score: -1, Offtopic

    For the sake of Perl.

  11. Aqua? by Anonymous Coward · · Score: -1, Offtopic

    Wait... is aqua the greenish blue, or the bluish green? Are we talking the Perl Cookbook or Perl for Website management?

    I also would like to know WTF mauve is. Thanks.