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

Re: Re: If XML is too hard for a programmer, perhaps he'dbe b


magic tags for xml
Sean McGrath wrote:
> [Bill de hÓra]
>  >And I don't understand this disdain for regular expressions over XML.
>  >Regexes are a perfectly useful tool for manipulating text.
> 
> Hi Bill,
> 
> I used regexp's myself - I'd say about 30% of the time when processing 
> XML. It makes me nervous
> though and I try not to do it in any mission critical context.
> 
> The trouble comes in having a degree of confidence in the correctness of 
> the regexps.

I think we're agreeing, but I'm looking at it backways- you'd want 
to know what you're looking for is regular and not say, context 
free, rather than hope the regex doesn't consume on false positives 
and negatives. If you know it's not regular or just don't care to 
know, that's willful engagement in incompetence.


> The standard answer I get when I harp on about this is something
> like "ah, but I know the XML I'm processing is machine generated and 
> consistent therefore...".

For regexing XML though I'm really talking about little 
admin/console jobs and sed scripts over the likes of config files 
rather than something sitting in front of a data stream (where Son 
of Regex, XPath, can do nicely).

One tempting exception might be for templating languages with what 
you might call 'magic tags' that get expanded. So instead of using

  $Revision

you end up with:

  <magic:Revision/>

This works so long as you produce and consume, with nothing in the 
middle (often the case with templating). Once another system is 
inserted and does this:

  <magic:Revision>
  </magic:Revision>

you're stuffed, or quickly refactoring to

  <magic:Revision value="$Revision"/>.

But if you hate attributes that's ok, there is an industrial 
strength, time-honoured option. If in the grand tradition we simply 
add,

  <!-- =============================================
         (DPH 2003-04-01) This Can't Happen:
  	<magic:Revision>
         </magic:Revision>
   =============================================  -->
  <magic:Revision/>

we're all set... ;)

Bill



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.