Category: XML

  • O’Reilly Media book: XPath and XPointer

    Update 2011-03-05:
    Happily acquired the PDF e-book.
    Lots of nice XPath examples … – now: practice, practice, practice!Update 2011-03-09:
    This book is also available online and for free here, on the O’Reilly Commons wiki.
     
    Update 2016-02-19:
    I really like exercising the examples (for the URL see above!) using xmlstartlet. Instead of writing a script in Perl or Python or even some code in Java, nowadays (and for quite a while) you can process XML in a shell script using xmlstartlet, and this books shows you the way.
    I am rewriting an “old” shell script that dealt with XML using fgrep and sed; of course with using proper XPath through xmlstartlet is so much more appropriate. Quite possibly the next step may be to replace “shell + XPath” with “Python + XPath”.
    My shell script actually enquires Jenkins (CI), and Jenkins also offers a JSON interface, and nowadays you would deal with that using JQ, which is a little like XPath for JSON.
  • The SAXON XSLT and XQuery Processor

    The SAXON XSLT and XQuery Processor

    Downloaded Saxon-HE from the above URL on my Linux box, decided to go for the Java variant, installed saxonhe.jar and “the resources” into /usr/local/saxon-resources9-3.

    I wasn’t able to browse the documentation below saxon-resources9-3/doc with Chrome-10, so I use Firefox-3.6 for that.
    But I also read the documentation here.

    This is from “Getting started with Saxon on the Java platform”, adapted for my Unix-like platform:

    $ java -cp /usr/local/saxon-resources9-3/saxon9he.jar net.sf.saxon.Query -t ‘-qs:current-date()’

    Well, no error messages. I like that. Looks like I got all preconditions fulfilled.
    More command lines tries from there:


    $ cd /usr/local/saxon-resources9-3

    $ java -cp /usr/local/saxon-resources9-3/saxon9he.jar net.sf.saxon.Transform -t -s:samples/data/books.xml -xsl:samples/styles/books.xsl -o:$HOME/temp.html

    $ java -cp /usr/local/saxon-resources9-3/saxon9he.jar net.sf.saxon.Query -t -s:samples/data/books.xml -q:samples/query/books-to-html.xq > $HOME/temp.html

    (to be continued)

  • mind mapping using Free Mind and emacs and its nXML-mode

    I got my quick introduction to Free Mind by son#1 (13yrs) today. Of course I am a stressful student. Of course he is not an advanced user. But we are doing well together.

    We didn’t manage to get a cloud removed other then by undo. And of course you don’t want to make use of undo, if the doing happing an eternity ago.

    As expected Free Mind’s file format is XML in its very own dialect.

    So removing the cloud within the XML was an obvious option. Trang helped me to derive a RELAX-NG grammar from the example. The  compact version of that grammar for use with nXML-mode is not perfect, but improving it doesn’t look difficult.

    The first thing to do in emacs was obviously tidying the indentation. It was then, that the grammar showed, how imperfect it is. But easy to fix. And it was trival to remove the cloud.

  • editing XML documents in emacs using nxml-mode

    One good reason for not not authoring in XML is not having a suitable editor or IDE. I personally use and recommend emacs and James Clark‘s nxml-mode. I create and modify all sorts of XML documents this way. If you supply nxml-mode with the right schema for your document, nxml-mode can even help you with tag completion and document validation. nxml-mode makes use of schemas in RELAX-NG, co-created by James Clark. RELAX-NG schemas are rather easily created, if not yet just available, as for DocBook, DocBook Website, DocBook Slides, and many, many other XMLs.

    Trang” is your tool for creating a RELAX-NG schema:

    • if you want to convert a DTD into a RELAX-NG schema,
    • if you want to derive a RELAX-NG schema from a couple of XML files of a specific kind,

    I have done that a dozen times, it does work.

    Here you find nxml-mode’s manual page.

    Your mileage may vary …
  • DocBook Website – where to get the Relax-NG schema from?

    I found it at SourceForge.
    I really love editing XML in Emacs’s nxml-mode. I did mention that at my DocBook Wiki home page already.

  • bulk upload of events in XML at XING

    At this link XING tells us, that they accept XML files in a certain format for uploading events to their site. They supply us with some nice but rather informal documentation in PDF, but there is no schema. Now that made me a little curious today, I downloaded their template file, created a few variants of the sample entry, and running trang I created a RELAX-NG schema file (anybody interested?). trang seems to not recognise date-time values of tags, so that always needs a little manual post-processing.
    O, yes, I proudly uploaded one such event that way. (Actually on the first attempt I got the year wrong, that was quite embarrassing.)

  • my CV or Resume in XML

    Until not too long ago I had kept my CV in DocBook, then I converted it to XMLRésumé (but the project really looks dead nowadays), now I am converting it to HR-XML/Resume. Yes, I know, its project admin just recently declared this SourceForge project as inactive. But then, what alternatives are there?
    Of course, I want to edit HR-XML files in emacs using a RELAX-G grammar, but I didn’t find any on the web. Well, that’s not really a huge problem. Take a few nice sample files (of any XML), stuff them into trang, and trang creates a RELAX-NG grammar from them. Of course, that kind of grammar is far from perfect, but it’s better than nothing, and you can always improve it manually, that’s not that hard. That way I created a RELAX-NG “compact grammar” for HR-XML/Resume last night.
    The grammar created actually has problems with  InternetWebAddress and Competency, but I was able to fix that for my personal use.
    HR-XSL comes with a nice “XMLRésumé -> HR-XML/Resume” converter, that way my old XMLRésumé CV got converted into a good initial version for HR-XML/Resume. HR-XSL uses DocBook for creating HTML and PDF, but there is also a “DocBook -> RTF” converter, that I want to make use of.