Archive for the 'XML' Category

Note: I've reorganized this site to use tags; the category archive remains to support old links. Only posts prior to April, 2006 are categorized. Tag Archive »

PList, improved

Behold, the power of XSLT: Cleaning up iTunes plist XML. This is another example of why data should be in XML (even a lousy XML format like Apple’s plist).

XML Blogging

As I mentioned previously, I use XML, XPath, XSLT, and W3C XML Schemas extensively at work. Recent activity on other blogs has put me to thinking about how XML can be used to run a blog. I’m working on getting Syncato working locally for experimentation, although I doubt I’ll be converting this blog- I don’t think it’s currently compatible with my hosting provider. Instead, I want to use it to experiment with XML blogging possibilities. I’ve created this new category, /WebDev/XML, to document ideas, progress, questions, etc.

XPath Rocks

I’ve been using XPath extensively for a couple of years now. The Excel templating engine I wrote for work accepts only XML as source data. XPath is used within the templates to select the elements to insert into the worksheet. The second version of the engine, which I wrote a year ago, uses even more XML – templates are now completely described in an XML schema designed for the purpose, and requests from the web server to the reporting servers for report creation are formatted in another XML schema. Inside the engine, most all manipulation of the various XML bits is done via XPath instead of DOM accessor methods like getElementByName().

Sam Ruby is currently working with a new weblog system known as Syncato, which stores entries in an XML DB (among other cool XML features). Sam has now enabled XPath searches of his archives, using the Atom and xhtml namespaces. Hover the example search links and checkout the search urls.

This is almost reason enough to switch to Syncato immediately. Add the fact that all presentation is done via XSLT (another XML technology I love), and the case is quite compelling.

Just because they don’t support it…

According to the Xalan-j homepage, Xalan-J 1 is no longer supported. Unfortunately, I’m still using it, at least for the time being. These two realities colided a couple days ago when I ran into a problem with the following (filenames have been changed to protect the innocent):

java org.apache.xalan.xslt.Process -IN /path/datafile.xml -XSL /path/template.xslt -OUT /path/output.xml -PARAM basecurrencyiso 'EUR'

Despite the deceptive simplicity of the above, the output indicated a problem with the parameter value. Adding a element to the key template proved the point:


$ISO=EUR, $basecurrencyiso=
$ISO=CHF, $basecurrencyiso=
$ISO=DKK, $basecurrencyiso=
$ISO=EUR, $basecurrencyiso=
(snip...)

My parameter value was not making it into the process. Making the ‘no longer supported’ issue even more fun is the fact that Xalan-j 2 no longer requires the single quotes around string values. I tried with single quotes, without; I googled and groups.googled; I kept coming up dry.

Of course, those of you in the audience whose Unix skills are better than mine have already seen the issue… the shell was handling the single-quotes. The answer was stunningly simple:

java org.apache.xalan.xslt.Process -IN /path/datafile.xml -XSL /path/template.xslt -OUT /path/output.xml -PARAM basecurrencyiso "'EUR'"

The funny thing is, I never saw any example that showed the extra double quotes. An hour wasted, but not a true waste… I’ll bet that in the future I’ll be more quote-savvy in when working in Unix. And now I’ve documented it, so at least for a brief moment, Xalan-j 1 is once again supported… just not by Apache.