On Mon, 2008-12-01 at 11:28 +0100, Per Jessen wrote: > Peter Ford wrote: > > > Per Jessen wrote: > >> > >> That's cool, but XSL is still the more appropriate tool IMO. It does > >> exactly what you need - it parses and validates the XML document, > >> allows you to extract the bits you need and in virtually any format > >> you need - which could be a text document with SQL statements for > >> piping to mysql. > >> > >> > >> /Per Jessen, Zürich > >> > > > > I'm with you on this, Per. > > You could even use the XSL to construct a bunch of PHP which could be > > eval'd or just read in as an include. > > Or better yet, if you use the XSL classes, you can register PHP > > functions and then call them within your XSL directly. That could > > potentially handle the validation you required, and even do the > > database inserts. > > Yep, that occured to me too. I think XSL can even do quite a bit of the > validation too. > > > I'm looking into using something like that on a project I'm currently > > working on: maybe I can come up with some examples in a couple of > > days... > > Here's one easy example - > > we generate monthly reports for our customers based on the activities of > the most recent month. The template is an OpenOffice document (well, > several in different languages), which is merged with the activity data > to produce the report in OOo format. The data is extracted and > formatted as XML. > The process looks roughly like this: > > OOo:template + XML:data -> apply XSL -> OOo document. (We then turn the > final OOo document into a PDF which is emailed). > > Of course the same could be achieved using PHP, but instead of a neat > XSL stylesheet, I would have a pile of custom PHP code. > > IMO, when you have a need to parse XML or otherwise extract data from > XML, you need a really good reason to disregard XSL. The only really > good reason I've heard so far was lack of XSL skills, which could be a > real issue. The learning curve IS quite steep. > > > /Per Jessen, Zürich > > I still disagree, as using XSL is essentially converting the XML to another format, which is then being used by PHP. XSL is great for some tasks, but for this, I think having a good PHP XMLDoc (or similar type of) class is better. On a slightly aside note though, how would you apply the XSL to the XML using PHP? I know that you can have the stylesheet (XSL) called in from within the XML document itself, but without being able to change that XML document, how else can it be done? This could be quite useful to me in the future. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php