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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: Procedural vs Declarative XML transformation approaches

[ Lists Home | Date Index | Thread Index ]
  • From: Paul Tchistopolskii <paul@qub.com>
  • To: xml-dev@lists.xml.org
  • Date: Sat, 04 Nov 2000 12:55:27 -0800


----- Original Message ----- 
From: Matt Sergeant <matt@sergeant.org>

> > At 06:05 PM 04/11/00 +0000, Matt Sergeant wrote:
> > > Basically, procedural
> > >code is great for data oriented XML structures, but almost useless for XML
> > >mixed content. For mixed content you really need declarative code. 
> > 
> > Wow; a neat bifurcation of the universe.  I wish life were that
> > simple.  Suffice it to say that many will disagree with this
> > particular pair of broad brush strokes. -Tim
> 
> Go on then, disagree :-)
> 
> I make careful note that a stream based parser that says:
> 
>   if (element == 'foo') {
>     ...
>   }
>   elsif (element == 'bar') {
>     ...
>   }

apply-templates ( AKA push )
 
> is also declarative, as would be a DOM based parser that walks the DOM
> tree with some sort of iterator doing something similar. By procedural I
> mean something that says:
> 
> foreach foo element
> output "foo: "
> foreach bar element child of foo
> output " = "
> foreach text child of bar
> output the text

value-of ( AKA pull )
 
> Mapping that model to mixed content is, umm, difficult, to say the least.

This is why XSLT has both push and pull. ( because XML has mixed
content ).

I agree with Matt. The only purpose of push is to serve mixed content
and mixed content is not easy to process without push.

When data have a 'strict' schema, you're better not to use 'apply-templates'
at all, I think. 

I also think that XSLT has a focus on a usecase of processing 
" 'documents' / 'mixed content' with no DTD" so using  XSLT on 
some other cases is not an appropriate usage of XSLT ( even it 
is possible to use XSLT for everything, from solving chess puzzles
to schema validation ).

Rgds.Paul.

PS. I'm not sure this has something to do with declarative / procedural  
'distinction'. I think procedural / declarative is an issue of  usecases.






 

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

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