[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Whitespace

  • From: agreene@b... (Andrew Greene)
  • To: xml-dev@i...
  • Date: Thu, 28 Aug 1997 12:52:15 -0400

Re: Whitespace
But perl doesn't have to break $_ on newlines. Whenever I do SGML
"parsing" with perl, I start off with

    $/ = "<";

which says "the record-break character is '<', instead of newline."
Then, within my while (<>) loop, each $_ contains a single tag and
some content, (roughly) matching the regexp:

    ($etagP, $gi, $attlist, $content) =
       /(\/?)(\w+)\s*([^>]*)\>(.*)/;

[For purists only: Yes, GIs can contain a different set of characters
than \w+, and attributes can contain > if it's enclosed in quotations,
and this doesn't chop off the '<' at the end of all tags except the
last one, and so on and so forth.... For SGML, it assumes that the
first character of ETAGO is the same as STAGO; for XML, it doesn't
handle the /> syntax... but it's simplified to make a point.]

The point is that perl doesn't care whether you have whitespace or
not, and if your perl script is splitting on newlines then you're
probably not going to correctly handle tags that contain newlines,
such as

    <book
        id=TWENTYKDOWN
        authorid=VERNEJ
        pubid=PENGUIN
    ><title>20,000 Leagues Under the Sea</title
    ></book
    >

- Andrew Greene

        
        
        


xml-dev: A list for W3C XML Developers
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To unsubscribe, send to majordomo@i... the following message;
unsubscribe xml-dev
List coordinator, Henry Rzepa (rzepa@i...)


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.