Archive for the 'xml' Category
Friday, January 25th, 2008
I’ve taken this opportunity to ditch CVS on all my existing Sourceforge projects (pyxmlwiki, xfv) while setting up my newest project. Here’s the browable subversion source. Have at it.
Where should you start with this code? Step zero, if you haven’t already, is to look through my XML 2007 slides on my site. First thing is to grab a copy of PLY, which is a dependency. Then with all these files in your current directory, run python with no parameters. At the interpreter prompt type import demo then demo.demo1(), demo.demo2(), and so on. This will give you a feel for how the system works. Look at the source of demo.py to see how it works at the high level.
To actually get into the code, I suggest opening webpath.py and scrolling down to the end, where a large series of unit tests begins. Tracing through these will be (I hope!) instructive on how the various details of the engine are put together.
There are many missing pieces (a few intentionally so). So have a look around the code and start thinking about what you could do with it. One thing I would love to have happen soon is getting rid of minidom, replacing it with something more robust.
If you want developer access on Sourceforge, drop me a note with your sf username. -m
Permalink
Filed under announcement, xml, xpath
Thursday, January 24th, 2008

WebPath, my experimental XPath 2.0 engine in Python is now an open source project with a liberal BSD license. I originally developed this during a Yahoo! Hack Day, and now I get to announce it during another Hack Day. Seems appropriate.
The focus of WebPath was rapid development and providing an experimental platform. There remains tons of potential work left to do on it…watch this space for continued discussion. I’d like to call out special thanks to the Yahoo! management for supporting me on this, and to Douglas Crockford for turning me on to Top Down Operator Precedence parsers. Have a look at the code. You might be pleasantly surprised at how small and simple a basic XPath 2 engine can be. So, who’s up for some XPath hacking?
Code download. (Coming to SourceForge with CVS, etc., in however many days it takes them to approve a new project) I hope this inspires more developers to work on similar projects, or better yet, on this one! -m
Permalink
Filed under announcement, intentional web, python, xml, xpath, yahoo
Monday, December 31st, 2007
This blog page at the W3C discusses the TAG finding that a data format specification SHOULD provide for version information, specifically reconsidering that suggestion. As a few data points, XML 1.1 (with explicit version identifiers) is something of a non-starter, while Atom (without explicit version identifiers) is doing OK so far–though a significant revision to the core hasn’t happened and perhaps never will.
In a chat with Dave Orchard at XML 2007, I suggested that the evolution of browser User-Agent strings might be a useful model, since it developed in response to the actual kinds of problems that versioning needs to solve.
Indeed, the idea seemed familiar in my mind. In fact, I posted it here, in Feb 2004. The remainder of this posting republishes it with minor edits for clarity:
‘Standard practice’ of x.y.z versioning, where x is major, y is minor, and z is sub-minor (often build number) is not best practice. If you look at how systems actually evolve over time, a more ‘organic’ approach is needed.
For example, look at how browser user agent strings have evolved. Take this, for example:
Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows 98) Opera 7.02 [en]
Wow, if detection code is looking for a substring of “Mozilla” or “Mozilla/4″ or “Mozilla/4.0″, or “MSIE” or “MSIE 6″ or “MSIE 6.0″ or “Opera” or “Opera 7″ or “Opera 7.0″ or “Opera 7.0.2″ it will hit. If you look at the kind of code to determine what version of Windows is running, or the exact make and model of processor, you will see a similar pattern.
Since this is the way of nature, don’t fight it with artificial, fixed-length major.minor versioning. Embrace organically growing versions.
The first version of anything should be “1.” including the dot. (letters will work in practice too) All sample code, etc. that checks versions must stop at the first dot character; anything beyond that is on a ‘needs-to-know’ basis. A check-this-version API would be extremely useful, though a basic string compare SHOULD work.
Then, whenever revisions come out, the designers need to decide if the revision is compatible or not. A completely incompatible release would then be “2.”. However, a compatible release would be “1.1.”. All version checking code would continue to look only up to the first dot, unless it has a specific reason to need more details. Then it can go up to the 2nd dot, no more.
Now, even code that is expecting version “1.1.” will work fine with “1.1.1.” or 1.1.86.” or “1.1.2.1.42.1.536.”.
Every new release needs to decide (and explicitly encode in the version string) how compatible it is with the entire tree of earlier versions.
Now, as long as compatible revisions keep coming out, the version string gets longer and longer. This is the key benefit, and why fixed-field version numbers are so inflexible. (and why you get silly things like Samba reporting itself as “Windows 4.9″).
One possible enhancement, purely to make version numbers look more like what folks are used to, is to allow a superfluous zero at the end. This the first version is 1.0, followed by 1.1.0, 1.1.1.0, (this next one made an incompatible change) 1.2.0, and so on.
So if a document needs to self-version at all, perhaps a scheme like this should be used? -m
Permalink
Filed under annoyance, patternalia, standards, xml
Monday, December 31st, 2007
Thanks to all the folks who showed interest in this little XPath puzzler published here a few weeks ago. Some asked to see the dataset, but I’m not able to release it at this time (but ask me again in 3 months).
Turns out it was a combination of two bugs, one mine, one somebody else’s. Careful observers noted that I wasn’t using any namespace prefixes in the XPath, and since I did specify that it was XPath 1.0, that technically rules out XHTML as the source language. Like nearly all XML I work with these days, the first thing I do is strip off the namespaces to make it easier to work with. Bug #1 was that in a few cases, the namespaces didn’t get stripped.
Bug #2 was in the XPath engine itself. Which one? Uh, whatever one ships with the “XPath” plugin for JEdit. It’s hard to tell directly, but I think it might be an older version of Xalan-J. In the case of the expression //meta, it properly located only those elements part of no namespace. But in the case of //meta/@property, it was including all the nodes that would have been selected by //*[local-name(.)='meta']/@property. Hence, a larger number of returned nodes.
Confusing? You bet! -m
P.S. WebPath would not have this problem, since in the default mode it matches local-names only to begin with.
Permalink
Filed under annoyance, xml, xpath, yahoo
Friday, December 21st, 2007
One whole evening of the program was devoted to XForms, focused around the new 1.1 Candidate Recommendation. I admit that some of the early 1.1 drafts gave me pause, but these guys did a good job cleaning up some of the dim corners and adding the right features in the right places. This is worth a careful look. -m
Permalink
Filed under XForms, browsers, software, standards, trends, xml
Friday, December 21st, 2007
OK, the majority of the buzz came from my talk, where I strongly encouraged folks to take a look at Hadoop. This article seems to be saying much the same things. If you’re curious about the future of distributed computation and storage, it’s worth a look. -m
Permalink
Filed under search, xml, yahoo
Sunday, December 16th, 2007
Here’s the slides from my presentation at XML 2007, dealing with an implementation of XPath 2.0 in Python. I hope to have even more news in this area soon.
WebPath (html)
WebPath (OpenDocument, 4.7 megs)
Did you notice the OpenOffice has nice slide export, that generates both graphically-accurate slides and highly indexable and accessible text versons? -m
Permalink
Filed under announcement, intentional web, python, software, xml, xpath
Saturday, December 15th, 2007
While I’ve got your attention, here’s an XPath (1.0) puzzler. I have an RDFa dataset compiled from various and sundry sources. It’s all wrapped up in a single XML file. I run this XPath to see how many meta elements are present: //meta and it returns a node-set of size 762. Now, I want to see how many property elements are present, so I run the query: //meta/@property and it returns a node-set of size 764. How is it that the second node-set can be bigger than the first? -m
Permalink
Filed under everythingismiscellaneous, standards, xml, xpath
Saturday, December 15th, 2007
Surely somebody has implemented this in at least one tool.
In a text editor, I come across a misspelled close tag like </xsl:stylsheet>. My editor highlights the line as an error, which is is, not matching the start tag and all. Why can’t it go the extra step and give me the same kind of interface as I get for misspelled words, which an easy option to repair the spelling? This seems like a much simpler problem than all the hairy cases around human-language spell check…
So, what tools already do this today? -m
Permalink
Filed under AI, annoyance, xml
Thursday, November 29th, 2007
Well, my plans for a series of postings about details of implementing XPath 2.0 fell rather short, so let’s skip straight to the good stuff.
An article by Mike Kay giving the details of the Saxon architecture. On the surface it’s about performance, but it also has an excellent section in internals. Worth a look. This has been quite influential for me, and maybe you too. -m
Permalink
Filed under software, xml, xpath
Saturday, November 10th, 2007
What is the difference between placing instanceof=”prefix:val” vs. rel=”prefix:val” on something? How do I decide between the two?
In the example of hEvent data, why is it better/more accurate to use instanceof=”cal:Vevent” instead of a blank node via rel=”cal:Vevent”?
-m
Permalink
Filed under everythingismiscellaneous, languages, standards, xml
Monday, November 5th, 2007
“Compact Clark Notation“. (Inspired by reading this) -m
Permalink
Filed under annoyance, software, xml
Monday, October 22nd, 2007
The more I look at RDFa, the more I like it. But still it doesn’t help with the pain-point of namespaces, specifically of unmemorable URLs all over the place and qnames (or CURIEs) in content.
Does GRDDL offer a way out? Could, for instance, the namespace name for Dublin Core metadata be assigned to the prefix “dc:” in an external file, linked via transformation to the document in question? Then it would be simpler, from a producer or consumer viewpoint, to simply use names like “dc:title” with no problems or ambiguity.
This could be especially useful not that discussions are reopening around XML in HTML.
As usual, comments welcome. -m
Permalink
Filed under annoyance, intentional web, languages, microformats, standards, stuff, xml
Saturday, October 20th, 2007
In researching for an XPath 2.0 implementation, I ran across this curious document from the W3C. Despite being labeled a Working Draft (as opposed to a Note), it appears to be a one-shot document with no future hope for updates or enhancements.
In short, it outlines several options for the first stage or two of an XPath 2.0 or XQuery implementation. (Despite the title, it talks about more than just a tokenizer; additionally a parser and a possible intermediate stage). Tokenizing and parsing XPath are significantly more difficult than other languages, because things like this are perfectly legitimate (if useless):
if(if) then then else else- +-++-**-* instance
of element(*)* * * **---++div- div -div
The document tries to standardize on some terminology for various approaches toward dealing with XPath. The remaining bulk of the document sketches out some lexical states that would be useful for one particular implementation approach. I guess the vibrant, thriving throngs of XPath 2.0 developers didn’t see the need for this kind of assistance.
In short, I didn’t find it terribly useful. Maybe some readers have, though. Feel free to comment below. Subsequent articles here will describe how I approached the problem. Stay sharp! -m
Permalink
Filed under software, writing, xml, xpath
Monday, October 15th, 2007
Depending on who’s asking and who’s answering, W3C technologies take 5 to 10 years to get a strong foothold. Well, we’re now in the home stretch for the 5th anniversary of XForms Essentials, which was published in 2003. In past conferences, XForms coverage has been maybe a low-key tutorial, a few day sessions, and hallway conversation. I’m pleased to see it reach new heights this year.
XForms evening is on Monday December 3 at the XML 2007 conference, and runs from 7:30 until 9:00 plus however ERH takes on his keynote. :) The scheduled talks are shorter and punchier, and feature a lot of familiar faces, and a few new ones (at least to me). I’m looking forward to it–see you there! -m
Permalink
Filed under XForms, browsers, intentional web, software, trends, xml, xpath
Monday, October 8th, 2007
As widely reported by now, the final schedule for XML 2007 this December in Boston is up. All I have to add is the suggestion of careful attention to the Tuesday program at 4:00. :) If you can’t wait, some technical details are forthcoming in this space. That is all. -m
Permalink
Filed under announcement, software, standards, xml, xpath, yahoo
Wednesday, October 3rd, 2007
Let’s see how many downstream pieces of software trip over this post…
Do greater-than and less-than signs need to be escaped in XML? Conventional wisdom has it that less-than signs always do, since that character starts a fresh “tag”, but greater-than signs are safe.
Wrong.
There is a particular sequence, namely ]]> , not allowed to occur unescaped in XML “for compatibility“–a particular phrase the spec uses to indicate rules that only an SGML-head could love (but still strict requirements nonetheless). Does your software prevent this condition from causing an error? -m
Permalink
Filed under annoyance, xml
Monday, October 1st, 2007
It’s a common need to parse space-separated attribute values from XPath/XSLT 1.0, usually @class or @rel. One common (but incorrect) technique is simple equality test, as in {@class=”vcard”}. This is wrong, since the value can still match and still have other literal values, like “foo vcard” or “vcard foo” or ” foo vcard bar “.
The proper way is to look at individual tokens in the attribute value. On first glance, this might require a call to EXSLT or some complex tokenization routine, but there’s a simpler way. I first discovered this on the microformats wiki, and only cleaned up the technique a tiny bit.
The solution involves three XPath 1.0 functions, contains(), concat() to join together string fragments, and normalize-space() to strip off leading and trailing spaces and convert any other sequences of whitespace into a single space.
In english, you
- normalize the class attribute value, then
- concatenate spaces front and back, then
- test whether the resulting string contains your searched-for value with spaces concatenated front and back (e.g. ” vcard “
Or {contains(concat(’ ‘,normalize-space(@class),’ ‘),’ vcard ‘)} A moment’s thought shows that this works well on all the different examples shown above, and is perhaps even less involved than resorting to extension functions that return nodes that require further processing/looping. It would be interesting to compare performance as well…
So next time you need to match class or rel values, give it a shot. Let me know how it works for you, or if you have any further improvements. -m
Permalink
Filed under XForms, browsers, languages, software, web20, xml, xpath
Friday, September 21st, 2007
Watch this space for details. I’ll be speaking about something related to Python and XPath 2.0. Watch this blog for tidbits on the subject. :) -m
Permalink
Filed under announcement, python, software, standards, stuff, xml
Saturday, September 8th, 2007
Video from XTech, worth a look. -m
Permalink
Filed under XForms, browsers, intentional web, mobile, software, standards, xml
Wednesday, August 8th, 2007
Go check it out. It even has a Tidy option to clean up the markup. But they missed an important feature: it should include an option to run Tidy on the markup first then validate. This is becoming the defacto bar for web page validity anyway… -m
Permalink
Filed under browsers, intentional web, languages, software, standards, trends, xml
Wednesday, April 11th, 2007
James Clark is blogging. A few zillion people have already mentioned this.
A slightly tangent observation: I had trouble reading through an entire article in web form, but had no problems returning later to the atom feed. At first I chalked it up to early morning grogginess, but it seems to be a repeatable phenomenon at all hours, at least for me.
So a double thanks to James for publishing a full feed.
How about you: do you have an easier time reading long form articles in a feed reader vs. a browser? Do you prefer feed reader vs. browser for this blog? Comment below. -m
Permalink
Filed under browsers, intentional web, trends, xml
Thursday, March 15th, 2007
Big surprise, huh? More evidence that the XML namspaces spec is out of touch with the reality of developers ‘on the street’, a.k.a. it has cracks in the foundation.
I disagree that aggregator developers are “bozonic”, as the title of the first cited article indicates. Why should any developer need to keep all that extra complexity bouncing around in their head? Optimize for people first, machines second. -m
Permalink
Filed under browsers, xml
Thursday, February 1st, 2007
Some random thoughts and responses to lots of blog discussion sparked by the XML2 article, where I asked “Is HTML on the Web a special case?”
By which, I mean, if you go through all the effort of writing down all the syntax rules used by the union of browsers that you care about, then go through the pain of getting consensus within a standards body, will the resulting document be useful beyond HTML on the Web, much like how XML is useful beyond being a vehicle for XHTML?
I don’t know if Tim Bray had that same version of the question in mind, but he answers “obviously ‘yes’”.
But I don’t think so. Once you have that set of rules, wouldn’t it be useful in other areas, say, notoriously RSS on the web? SVG? MathML? In fact, I’d go as far as saying that any hand-authored markup would be a candidate for XML2 syntax.
What about mobile? Anne van Kesteren responds:
in that article Micah Dubinko mentions mobile browsers living up to their premise and all that. What he says however, isn’t really true. Mobile browsers and XHTML is tag soup parsing all the way.
He links to this page, which does a rather poor job of making a point the author seems to have decided upon before starting the experiment. If you look at the specific test cases, one tests completely bizarro markup that no author or tool I can imagine would ever produce. Another test checks the handling of content-type, not markup. On the other axis, the choices there seem a bit jumbled: lists of user-agent strings, one for stock Mozilla, and a footnote indicating confusion about what browser is really in use. If anything, this page shows that the browsers tested here, with the exception of Opera Mini, are crap. If you spend more than a few minutes in mobile, you’ll discover this widespread trend. (And I’m working on a solution…watch this space).
Look at this from a pragmatic viewpoint. Check the doctype used on Yahoo! front page vs mobile front page. Despite the poor browsers, XHTML adoption is still farther ahead on the mobile web then the desktop web.
The last thing nagging at me (for now) is whether XML2 will have an infoset. Will it be possible to use XPath, XQuery, and XML tools on XML2 content? How well will these map to each other? In the strict sense, no, XML2 won’t have a conforming infoset because it will never include namespaces. But might it support a subset of the infoset? (Would that be a infosubset?) That’s a huge open question at this point. -m
Permalink
Filed under browsers, intentional web, mobile, standards, xml
Tuesday, January 23rd, 2007
So, about a year ago, I wanted to use XPath 2.0 on a project. Turns out no non-toy, non-alpha versions existed except in Java land (where Saxon is quite good). Has the situation changed at all? Anything on the horizon? Libxml2? Anybody?? -m
Permalink
Filed under software, standards, xml
Friday, January 12th, 2007
In case you didn’t notice, a new XML Annoyances is out. From the first comment there:
markup typo
2007-01-11 18:58:33 Michael Dyck [Reply]
In the link following “same unofficial naming scheme as”, the attribute is missing its closing quote-mark, which (in my browser at least) causes a lot of the subsequent text (up to the next quote-mark) to be slurped in as the attribute value, effectively hiding it.
(Indeed, “well-formedness on the Web is dead”.)
This might be fixed by the time you read this, but indeed an interesting typo.
Update: I checked my original submitted article, and indeed there error isn’t there–it found its way in during the production process. But the interesting fact remains that it could happen in the first place 1) without causing any major problems, and 2) causing varied minor problems depending on the browser. -m
Permalink
Filed under mobile, xml
Wednesday, November 8th, 2006
but there has never been a successful Java implementation of a commercial-grade web browser. (right?)
There exist lots of huge applications including IDEs, and editors of all sorts, but nobody’s been able to nail the whole XHTML+CSS+JavaScript thing in Java. (right?)
Take it a step further–no need to pick on Java–nobody has done this in any VM-based language (right)?
Coincidence or sign of greater forces in the universe? Feel free to post counter-examples in the comments.-m
Permalink
Filed under browsers, languages, standards, xml
Monday, October 30th, 2006
Watch xml.com this week: the XML Annoyances column is returning, and not a moment too soon it seems. -m
Permalink
Filed under announcement, xml
Tuesday, June 20th, 2006
The Rise and Fall of CORBA, seen at the ACM.
To create quality software, the ability to say “no” is usually far more important than the ability to say “yes.”
Sound familiar? -m
Permalink
Filed under intentional web, xml
Friday, June 16th, 2006
when building REST XML protocols. Kimbro Staken. Good stuff. -m
Permalink
Filed under URLs, WS-Whatever, xml