Adapt Saxon-CE event model to XSL-FO?

Inasmuch as the Print and Page Layout Community Group at the W3C is looking at how to get feedback from the XSL formatter and I’ve also been reading about how Saxon-CE handles user input, I’m now wondering whether the same sort of pattern could be adapted to handling feedback from the XSL formatter. Saxon-CE does it through template rules that match the element that receives the event and are in a mode that reflects the type of event, and similarly an XSL formatter could trigger on exceptional events such as overflow occurring or even on mundane events such as completion of a page sequence, and the templates in the corresponding modes could match on either FOs in the FO tree or areas in the area tree. Continue reading “Adapt Saxon-CE event model to XSL-FO?”

generate-id() in xsl:attribute-set

Inasmuch as xsl:attribute-set is most often thought of for adding constant sets of XSL-FO properties, it’s easy to forget that, as it says in the XSLT 2.0 spec:

Evaluating the same attribute set more than once can produce different results, because although an attribute set does not have parameters, it may contain expressions or instructions whose value depends on the evaluation context. Continue reading “generate-id() in xsl:attribute-set”

\Boot\BCD is missing required information

Inasmuch as a Windows partition that wouldn’t boot frustrated and inconvenienced me for nearly a week, and the solution, when I found it, took only a couple of minutes, I’m writing it up here.

The symptom when trying to boot into Windows was a black-and-white screen of death containing:

File: \Boot\BCD
Status: 0xc0000034
Info: The Windows Boot Configuration Data file is missing
  required information

The official Microsoft advice at http://support.microsoft.com/kb/927391/en-us didn’t help. What did work was the second option, “Manually Repairing the Windows Bootloader”, from http://neosmart.net/wiki/display/EBCD/Recovering+the+Windows+Bootloader+from+the+DVD:

attrib -h -s C:\boot\BCD

del C:\boot\BCD
bootrec.exe /rebuildbcd

Happily, I didn’t need to do the third, “Nuclear Holocaust” option from that page.

XML Summer School 2012

Inasmuch as last year’s sessions were both enjoyable and well received, I’m teaching two sessions at XML Summer School again in September this year.

One, in the XSLT and XQuery track, is an update of the Developing and Testing in XSLT talk, again alongside Jeni Tennison, that got us such a good review last year:

Unit tests, pro­fil­ing, debug­ging and, increas­ingly, test-driven devel­op­ment are part of the bread and but­ter of work­ing with other pro­gram­ming lan­guages but are not always so with XSLT or XQuery. In test-driven devel­op­ment, which is a fun­da­mental part of agile approaches to soft­ware devel­op­ment, the developers write tests that describe the desired beha­viour of their applic­a­tion, then write code that meets the tests. This style of devel­op­ment keeps code focused, avoids break­ing exist­ing code and facil­it­ates refactoring.

In this ses­sion, Jeni Ten­nison and Tony Gra­ham will describe both the state of the art in test­ing and debug­ging XSLT and XQuery and how test-driven devel­op­ment applies to XSLT and XQuery devel­op­ment. In par­tic­u­lar, they will focus on the use of the XSpec test­ing framework.

The other, in the Publishing track, is XML and Publishing Workflows:

Some formats are bet­ter or worse than oth­ers for cap­tur­ing and/or rep­res­ent­ing the inform­a­tion for pub­lish­ing pur­poses. Can you cre­ate and man­age life-cycle work­flows which ration­al­ise or reg­u­lar­ise mixes of formats using XSLT and other XML tool­sets? Should XML be the begin­ning of your pub­lish­ing work­flow, the hub format in the middle, the res­ult, or all three? How can XSLT and related tools be used to cover up the defi­cien­cies or excesses of the source XML? What are the argu­ments for mov­ing authors towards sub­mit­ting in XML (or not)? For mov­ing editors?

Incor­por­at­ing both live examples and war stor­ies, Tony Gra­ham will lead an exam­in­a­tion of XML in pub­lish­ing work­flows, the advant­ages and dis­ad­vant­ages of using XML at each stage, and some of the tools and tech­niques avail­able to you.

XML Sum­mer School 2012 is on Septem­ber 16–21 2012 at St Edmund Hall, Oxford Uni­ver­sity.

Robbery Under Arms

Inasmuch as I was in primary school in Australia when I first read it as a dead-tree book, it’s something of a turn for the books as well as a turn of the books that I’ve just finished reading Robbery Under Arms by Rolf Boldrewood as an EPUB while living and working in Ireland and, now, England. I think at the time I would have found the medium even more unlikely than the geography, but as the ready availability of EPUB readers has given new life and new audiences to many out-of-copyright books, when I was first stocking up on EPUBs I specifically looked for the EPUB of Robbery Under Arms since I was unlikely to find it the dead-tree version in either an Irish library or an Irish bookstore.

“My name is Dick Marston” as the opening words of Robbery Under Arms may not have the recognition nor the ring of “Call me Ishmael” (though for a great young-adult read, Don’t Call Me Ishmael), but it is one of the great Australian novels. If you want to read the EPUB, a search for ‘”Robbery Under Arms” EPUB’ will turn up several sources.

XML Calabash Ant task

Inasmuch as I’d been threatening since the XML Summer School last year to do it, I’ve made a custom Ant task for running XML Calabash, currently only in my fork at git@github.com:MenteaXML/xmlcalabash1.git.

You can use this task to process:

  • A single input file to produce a single output file
  • A set of input files, processed one at a time, to produce a set of output files
  • Multiple input files as the input to one XProc input port processed to produce a single output file
  • Any of the above with additional input ports to each of which are applied one or more input files whose file names may be either fixed or mapped from the name(s) of the current main input file(s)
  • Any of the above with additional output ports whose file names may be either fixed or mapped from the name(s) of the current main input file(s)
  • Any of the above with Ant defaulting to not running the pipeline when the outputs are already up-to-date compared to the inputs and the pipeline

You can also specify options and parameters to be used by the pipeline. Continue reading “XML Calabash Ant task”

use-when

Inasmuch as use-when is one of the standard attributes in XSLT 2.0 (and later) rather than being on a particular XSLT element, it seldom gets much of a mention; e.g., currently only 568 mentions on the XSL-List according to MarkMail (and some of those are false positives).

use-when (and xsl:use-when on non-XSLT elements) is for “conditional element inclusion” and is very useful for excluding elements that either aren’t currently useful or that will cause errors if acted upon. The use-when in the example below causes the xsl:value-of to be used only when saxon:line-number() is available, thereby avoiding the Saxon extension functions are not available under Saxon-HE message from more recent versions of Saxon HE where saxon:line-number() is no longer available but producing a useful result on older Saxon HE versions where the function is available.

<!-- Leftover intermediate elements. -->
<xsl:template match="t:*">
  <xsl:if test="$debug">
    <xsl:message>
      <xsl:value-of select="t:node-basename(.)" />
      <xsl:value-of
        use-when="function-available('saxon:line-number')"
        select="concat(':', saxon:line-number())"
        xmlns:saxon="http://saxon.sf.net/" />
      <xsl:text> :: </xsl:text>
      <xsl:copy-of select="." />
    </xsl:message>
  </xsl:if>
  <xsl:apply-templates />
</xsl:template>

The use-when expression is evaluated very early in the processing of the stylesheet, and you can’t use variable references in the expression. So don’t be tempted to try:

<xsl:message use-when="$debug">
...
</xsl:message>

“that error-handling be completely deterministic”

Inasmuch as, back in January, I was teaching another XML course, I reviewed the basis for draconian error handling in XML in light of the sea change in recent years towards HTML5-style completely-defined error recovery.

At the time of the draconian error handling decision, I was on the larger “W3C SGML Working Group” mailing list that provided input, clamour, and distraction to the core “W3C SGML Editorial Review Board” that did the work and made the decisions on the road to XML. I followed the discussions on the mailing list at the time (as much as humanly possible), and the message about this that stuck in my mind is the “ERB votes on error handling” message from Tim Bray on behalf of the ERB, particularly this section:

2. We have a strong political reality to deal with here in that for the first time, the big browser manufacturers have noticed XML and have together made a strong request: that error-handling be completely deterministic, and that browsers not compete on the basis of excellence in handling mangled documents. It was observed that if they wanted to do this, they could just do it; but then pointed out that this is exactly why standards exist – to codify the desired practices shared between competitors. In any case, if we want XML to succeed on the Web, it will be difficult to throw the first serious request from M & N back in their face.

Continue reading ““that error-handling be completely deterministic””