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

If XML is too hard for a programmer, perhaps he'd be better off as a cro


chet murthy ibm
Tim's article just made me roll my eyes.  XML has made my life as a developer 
much easier, and i can't think of a developer whom I've mentored in using XML 
that doesn't have the same experience.  I suspect that Tim has completely 
misplaced the actual problem.

BTW, I find the idea of processing XML using simple regexen pretty hair 
raising.  Holy impedance mismatch!  Holy error prone!  That's supposed to be 
easier?  My mind boggles.

Bottom line, as I keep saying, the sky ain't falling on my head.  Ive never 
been more productive than since I've brought my career so much to focus on XML 
development.  Of course, my favorite language helped me a good deal of the way 
there.

> Tim is basically asking for pull-based XML parsers, implementations of
> which exist in .NET Framework and the Java world.

Python has pulldom, althugh I prefer DOM+Generators, myself.  I find them 
clearer and much easier.  It amused me to read:


> There isn't much
> difference between his mythical Holy Grail example
> 
> while (<STDIN>) {
>   next if (X<meta>X);
>   if    (X<h1>|<h2>|<h3>|<h4>X)
>   { $divert = 'head'; }
>   elsif (X<img src="/^(.*\.jpg)$/i>X)
>   { &proc_jpeg($1); }
>   # and so on...
> }
> 
> and its C# equivalent which has been available in the .NET Framework for
> over a year
> 
> 
> while (xmlreader.Read()){
> 
> 	if(reader.NodeType.Equals(XmlNodeType.Element) &&
> reader.Name.Equals("meta")){
> 		continue;
> 	}
> 
> 
>       if((reader.Name.Equals("h1") || reader.Name.Equals("h2")
> 	   || reader.Name.Equals("h3") || reader.Name.Equals("h4")) && 
>          reader.NodeType.Equals(XmlNodeType.Element)){
> 	 divert = "head";
>  
> 	}else if (reader.NodeType.Equals(XmlNodeType.Element) &&
> reader.Name.Equals("img")){
> 
> 		string jpegurl = reader.GetAttribute("src); 
> 
> 		if((jpegurl != null) && jpegurl.EndsWith(".jpg")){
> 				ProcessJpeg(jpegurl);
> 
> 		}
> 	}
> }

Hmm.  Both Tim's Perl and your C# seem more complex than the way I would code 
this in Python using DOM and generators.

I have copious examples of such here:

http://www.xml.com/pub/a/2003/01/08/py-xml.html

From seeing Don Box's talk at XML Web Services one, it seems .NET plans to 
implement a somewhat Pythonic form of iterators/generators.  Good.  Maybe .NET 
users won't be stuck with code like the above for too long.


-- 
Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Universal Business Language (UBL) - http://www-106.ibm.com/developerworks/xml/l
ibrary/x-think16.html
EXSLT by example - http://www-106.ibm.com/developerworks/library/x-exslt.html
The worry about program wizards - http://www.adtmag.com/article.asp?id=7238
Use rdf:about and rdf:ID effectively in RDF/XML - http://www-106.ibm.com/develo
perworks/xml/library/x-tiprdfai.html
Keep context straight in XSLT - http://www-106.ibm.com/developerworks/xml/libra
ry/x-tipcurrent.html
Python Generators + DOM - http://www.xml.com/pub/a/2003/01/08/py-xml.html
Using SAX for Proper XML Output - http://www.xml.com/pub/a/2003/03/12/py-xml.ht
ml
SAX filters for flexible processing - http://www-106.ibm.com/developerworks/xml
/library/x-tipsaxflex.html



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.