Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xml-dev] Schema, BNF and parsing

From: Andrew Jeavons <apj@-------------.--->
To: Bob Foster <bob@------.--->
Date: 3/6/2005 4:01:00 PM
At 02:02 PM 3/5/2005, Bob Foster wrote:
>Andrew Jeavons wrote:
>>> From your description I'd guess that every verb/attribute combination
>>>and interaction has been hardcoded.  If so, you might get the best
>>>bang for your buck by "acquiring" (training/hiring) someone who can
>>>help you re-write your existing XSLT.
>>Exactly. Which is totally brain dead. That's what set me on my search for 
>>the BNF tool. Even with my minimal XSLT knowledge seeing the SAME code
>>over and over again made me very worried.....
>>The XSLT was done by external contractors, soon to be ex-contractors now 
>>if I can help it. I know that I can make a parser out of Bison and Flex 
>>with a fifth or less code
>>which will do far more than the XSLT does and be readable (well to me 
>>anyway....)
>
>That's what you think you know, but it isn't correct in general. BNF can 
>only do a surface syntax scan; you'll have to escape to a programming 
>language to do any sort of semantic check. XSLT is far more powerful. 
>That's not saying that the contractors' stylesheet actually uses any of 
>this power, but it's there.

Reasonable point. Yes, BNF provides a validity checking mechanism but I 
still have to write C/C++ or whatever to do anything concrete with the 
elements I parse. And C et al
are not great languages for these kinds of job it is true.

>Plus, you seem to be missing this major point: Before you can teach your 
>BNF to parse your XML application language, you first have to teach it to 
>parse XML. This is a much bigger PITA than you imagine.

Yes and no. When I look at the XML language we have it is very (very) 
simple, which is why I was aghast it taking 2666 lines of *ANYTHING* (XSLT, 
C et al) to parse it. And also
looking at other systems I've written/worked on that use BNF parsers I'm 
pretty certain it isn't a huge job. 20+ years of hacking code around...:-) 
So while I accept your point
about XSLT being badly used in this case, I do know for an absolute fact I 
can write a shorter parser in Bison, but it does seem clear now that the 
problem isn't so much using
XSLT for the parsing as the way it has been done...

>  The virtue of using existing schema languages is that they already know 
> how to deal with the ins and outs of XML syntax, so you write grammars 
> and rules at a much higher level than BNF.

Very true. What wasn't clear to me was that systems like XSLT could write 
higher order grammars. This code was the first XSLT I had seriously looked 
at and it didn't give a good
impression !

>As a parser-aware person, you should find RELAX NG compact syntax easy to 
>understand and able to express what you need. If there is something you 
>can't say, you can add Schematron assertions to the same schema. I'd 
>strongly recommend you check it out.

Thanks, I'll check it out, I appreciate the comments/information.

andrew

>Bob Foster
>http://xmlbuddy.com/
>
>

Andrew Jeavons

www.andrewjeavons.com

+1 513 871 8278


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent