ModulesīaseX can be extended via modules too. This can be one or more opened session as long as they have watched the named event. db : event ( "my-event", "1 to 4" )Įach event can be passed an XQuery expression that will be evaluated and passed to any registered handlers on the client side. Then at some point you can fire an event and pass values to it. On the database side you need to have created an event called my-event for this to succeed CREATE EVENT my - event Here is a slightly more complex, real life authenti-genuine, example featuring list manipulation, dynamic XPath execution, external parameter passing and other typical XQuery stuff, declare variable $start external declare variable $limit external declare variable $reporting-org external let $filter := "$db//iati-activity" let $filter := concat ( $filter, switch ( $reporting-org ) case "" return "" default return ) let $db := db:open ( 'iati' ) let $bindings := map ) Everything is a sequence making it conceptually rather LISPy yet the syntax is much like ML. Its based on a SQL-like expression set called FLWOR (FOR, LET, WHERE, ORDER BY and RETURN) that when mixed with XPath you have a nice functional language. In fact XQuery is kind of an amazing language. XQuery is useful when you want to do more than just select nodes in a document. I did say contrived didn't I? So XPath is useful for selecting things but not manipulating or transforming anything. Take this rather contrived example, would return the release-date of all the beta releases of the project titled My Blog. In fact there are some features, such as selecting nodes based on conditions of their children, that CSS selectors could do with. A bit more verbose than CSS selector syntax but essentially the same idea. XPath is like the CSS selectors of the XML world. Both are mature, well documented, well understood query languages. XML has already got its own query language, well actually two, XPath and XQuery. Thanks to this "thoughtout-ed-ness" BaseX doesn't need to invent any new concepts to support querying. Yeah yeah there are aspects of the ecosystem that could be described as over thought but as a data format its not half bad. If there is one thing that can be said about XML - it's really well thought out. You feed a BaseX database a batch of XML files, it indexes the contents and allows you to query over the top of it as if it was a single root document. Now imagine you want to ask a question of this type of distributed XML data and you've discovered the sweet spot for BaseX. Like it or not there is a lot of data exactly like this. So the data itself is still locked up in static XML files spread across the globe. It does not extract the data from within the XML files. To top it all off the registry only provides a centralised lookup for datasources, pointers to XML files, via metadata. Not exactly big data but still a respectable volume of XML. Data is usually published as many XML files and according to the registry there are 241 organisations publishing 3,343 datasets (XML files). Many organisations and governments that spend money on foreign aid publish data via IATI. an XML standard for publishing data consistently, and,.an organisation that promotes transparency of foreign aid spend,.One example is IATI - the International Aid Transparency Initiative. There is a lot of publicly available data locked up in static XML documents. So what is BaseX useful for? Well one of the areas that it shines is Open Data. Well not quite 1 - the design goals are not the same. That makes it triply cool because it's schemaless. Not only that but it doesn't care about DTDs and XML schemas so, as long as they are well formed, it can store any XML document. It stores XML documents so it's doubly cool because it's a document store. That may sound like "the worst" but let me tell you why it is rather the opposite. BaseXīaseX is an XML database written in Java. One day you may need to interrogate XML and maybe BaseX will save your sanity as it did mine. So I wanted to write about BaseX because while it may not be shiny it makes up for it in pure practicality. Yes it's an XML database, yes XML is, like, totally lame and all but trust me, it exists and there are contexts it works. They make solving the problem so easy that I don't have to burn time getting them to work or try bending them to my needs.īaseX, an XML database, is one of those. There are technologies that I have used to solve problems that just make me happy while using them.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |