OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

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

[ Lists Home | Date Index | Thread Index ]

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






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS