#11 Add Single File Query


Kernow is a great tool for people that isn't used to the command line. I use it all the time in my XML class (that I teach at college). The only missing part is the XQuery equivalent of the "Single File Transform". Could you consider adding it? If you don't have time, I can write a patch (if I know that you plan to add it).

Regards, Hans Nordhaug

PS! I'm sure I have asked about this before, but I just can't find it Maybe in your blog?


  • Andrew Welch

    Andrew Welch - 2011-09-28


    Can you not use the Standalone tab along with queries that pull in their source xml using the doc() function?

    It doesn't really make sense to have the app supply the input for the XQuery as that doesn't happen in the real world... in an xmldb the query always get its input from an xpath or another query.


  • Hans Fr. Nordhaug

    Hm, maybe my need is very special since I use it in a teaching situation? I'm not sure. Considering that Kernow is a GUI for Saxon, I think you should support the -s option which provides an initial context document for XQuery. This is the same switch that you support for XSLT with "Single File Transform". And does people really use the "Single File Transform" in Kernow in real life? I would guess no - the XSL transform is part of some process/tool chain.

    Yes, I can use the the doc function
    and then use $x in all XPath/XQuery expressions. It's just much nicer, in particular when teaching, to avoid the extra $x in the beginning of all location paths ...

    declare variable $x := doc("file.xml");

  • Andrew Welch

    Andrew Welch - 2011-09-28


    In XSLT, the concept of a single input file being transformed into a single output file is the standard situation. A "standalone" transform that uses a named template as the entry point and pulls in its own input is less common, but it still happens especially for non-xml input like the csv-to-xml transform.

    XQuery is different - its only makes sense when its used with an xml database. For any other situation you should be using XSLT.

    My point is, while its straightfoward to add the feature to Kernow, its the wrong thing to do - I think your students would benefit learning to get their input from collection() and doc() as that's what they'll be doing outside of the classroom...

  • Hans Fr. Nordhaug

    I agree with everything you say about XSLT - no problem.

    > XQuery is different - its only makes sense when its used with an xml
    > database. For any other situation you should be using XSLT.

    Some people disagree, but that is a different discussion.

    And, yes, my students learn to use the doc function, but right now we are (ab)using XQuery to learn XPath. There are very few tools that lets you easily and robustly evaluate XPath expression - either they don't support namespace or XPath functions are missing or ... Saxon doesn't have those problems. Since the students don't like the command line, Kernow comes to the rescue. Whatever.

    I guess it boils down to this: AFAIK Kernow supports all features/options in Saxon, except the possibility to give the initial content document for XQuery. Could you please consider adding support for that option somewhere in Kernow? (A new tab "Single File Xquery" could be hidden by default.)

    Thx for the discussion. I hope I was able to convince you ...

    PS! I know this is open source so I could just create my own modified copy of Kernow and distribute that to my students.


Log in to post a comment.