General notes and things I learned or remembered:
- You cannot put a comment within an XML tag!
- Google gives human-unreadable XML feeds, but tidy is extremely handy for cleaning it up.
- Remember to be careful to write out the greater and lesser than signs in code every time when you’re doing comparisons.
- In a similar line, use
disable-output-escapingwhere appropriate. - When you are doing XSLT, remember to import the appropriate namespaces into your XSL document using
xmlns:statements. - the
exclude-result-prefixesattribute of the root node keeps the namespaces from being printed in your output. Very handy. - When you are doing XSLT on an atom document, remember to use the atom namespace in a form like
xmlns:atom='http://www.w3.org/2005/Atom'rather than leaving it in the root. Nothing will work, otherwise. When you go to reference an atom item, useatom:itemname. For more, see the page that really solved my XSLT/atom problems. - XSL parameters are a very cool thing. I’m using them to do pagination, but they’re powerful in general.
- Once you get the hang of it, pagination is actually pretty easy.
But all things considered, now that I’ve written two XLST documents, I’m confident that I can generate new ones in a timely fashion. I’m finally getting the hang of it. I’m still not doing very complex things (mostly just parsing feeds from various sites), but the results are much more elegant than trying to build a custom php parser for each one.
Here are a couple useful links:
My current projects involve parsing feeds from google calendar and flickr. There is an API Document for Google Calendar’s feeds, which provided me the information necessary to sort and format the feed to my liking. I used this format string: full-noattendees?orderby=starttime&futureevents=true&singleevents=true&sortorder=a&max-results=25.
and my xsl file looks a bit like this (the blog messes up the formatting):
Post a Comment