{"id":128,"date":"2015-02-18T09:22:44","date_gmt":"2015-02-18T09:22:44","guid":{"rendered":"http:\/\/www.w3.org\/community\/ppl\/?p=128"},"modified":"2015-02-18T09:22:44","modified_gmt":"2015-02-18T09:22:44","slug":"getting-an-area-tree-within-your-xslt-transform","status":"publish","type":"post","link":"https:\/\/www.w3.org\/community\/ppl\/2015\/02\/18\/getting-an-area-tree-within-your-xslt-transform\/","title":{"rendered":"Getting an area tree within your XSLT transform"},"content":{"rendered":"<p>The Print and Page Layout Community Group is developing a series of <a title=\"XSLT Extensions @ PPL CG wiki\" href=\"http:\/\/www.w3.org\/community\/ppl\/wiki\/XSLTExtensions\">open-source extensions for XSLT processors<\/a> so you can run any number of iterations of your XSL-FO processor from within your XSLT transformation, which allows you to make decisions based on formatted sizes of areas.<\/p>\n<p>The extensions are currently available for Java and DotNet and use either the Apache FOP XSL formatter or Antenna House AHF formatter to produce the area trees.\u00a0 Contributions supporting more XSLT\u2013XSL-FO combinations would, of course, be welcome.<\/p>\n<p>A single Java jar file covers four combinations of XSLT processor and XSL-FO formatter:<\/p>\n<ul>\n<li>Saxon 9.5 and FOP<\/li>\n<li>Saxon 9.5 and Antenna House<\/li>\n<li>Xalan and FOP<\/li>\n<li>Xalan and Antenna House<\/li>\n<\/ul>\n<p>The DotNet version supports:<\/p>\n<ul>\n<li>DotNet 4.0 and FOP<\/li>\n<li>DotNet 4.0 and Antenna House<\/li>\n<\/ul>\n<p>The graphic below is from a <a title=\"XSLT extensions poster for Balisage 2014\" href=\"http:\/\/www.w3.org\/community\/ppl\/files\/2014\/08\/balisage2014.pdf\">poster<\/a> done for the Balisage 2014 conference.\u00a0 It shows four ways that the XSLT extensions can be used.\u00a0 Can you see what they are?<\/p>\n<p><a href=\"http:\/\/www.w3.org\/community\/ppl\/files\/2014\/08\/balisage2014.pdf\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-140 size-full\" src=\"http:\/\/www.w3.org\/community\/ppl\/files\/2014\/08\/balisage-poster-top.png\" alt=\"balisage-poster-top\" width=\"621\" height=\"448\" srcset=\"https:\/\/www.w3.org\/community\/ppl\/files\/2014\/08\/balisage-poster-top.png 621w, https:\/\/www.w3.org\/community\/ppl\/files\/2014\/08\/balisage-poster-top-300x216.png 300w\" sizes=\"auto, (max-width: 621px) 100vw, 621px\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<h2>Size text to fill available width<\/h2>\n<p><a href=\"https:\/\/www.w3.org\/community\/ppl\/files\/2015\/02\/balisage-poster-fill-width.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-146\" src=\"https:\/\/www.w3.org\/community\/ppl\/files\/2015\/02\/balisage-poster-fill-width.png\" alt=\"Size text to fill available width\" width=\"294\" height=\"52\" style=\"float: right\" \/><\/a>The title text is formatted at a known size, then formatted \u201cfor real\u201d with the font-size multiplied by the ratio of the available width to the formatted width.<\/p>\n<h2>Size text to fill available height<\/h2>\n<p><a href=\"https:\/\/www.w3.org\/community\/ppl\/files\/2015\/02\/balisage-poster-fill-height.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-147\" src=\"https:\/\/www.w3.org\/community\/ppl\/files\/2015\/02\/balisage-poster-fill-height.png\" alt=\"Size text to fill available height\" width=\"294\" height=\"166\" style=\"float: right\" \/><\/a>The \u2018do-box\u2019 template recursively calls itself until one of these conditions is true:<\/p>\n<ul>\n<li>The formatted area fits within the box within a specified tolerance<\/li>\n<li>The change in font size between successive runs is less than the font size tolerance<\/li>\n<li>The maximum number of iterations is reached.<\/li>\n<\/ul>\n<h2>Adjust <code>fo:list-block<\/code> start-indent<\/h2>\n<p><a href=\"https:\/\/www.w3.org\/community\/ppl\/files\/2015\/02\/balisage-poster-start-indent.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-148\" src=\"https:\/\/www.w3.org\/community\/ppl\/files\/2015\/02\/balisage-poster-start-indent.png\" alt=\"Adjust fo:list-block start-indent\" width=\"294\" height=\"82\" style=\"float: right\" \/><\/a>Just the list item labels are formatted, then the longest length is found and the <code>provisional-distance-between-starts<\/code> is set on the <code>fo:list-block<\/code> is set to that length.<\/p>\n<h2>Make list item body avoid a long label<\/h2>\n<p><a href=\"https:\/\/www.w3.org\/community\/ppl\/files\/2015\/02\/balisage-poster-long-label.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-149\" src=\"https:\/\/www.w3.org\/community\/ppl\/files\/2015\/02\/balisage-poster-long-label.png\" alt=\"Make list item body avoid a long label\" width=\"292\" height=\"95\" style=\"float: right\" \/><\/a>Each <code>fo:list-item-body<\/code> formats its <code>fo:list-item-label<\/code> and, if the <code>fo:list-item-label<\/code> is too long, adds space above itself to get out of the way.<\/p>\n<h2>Where can I get it?<\/h2>\n<p>The main page for the XSLT extensions on on the PPL CG wiki at <a href=\"http:\/\/www.w3.org\/community\/ppl\/wiki\/XSLTExtensions\" title=\"XSLT extensions on PPL CG wiki\">http:\/\/www.w3.org\/community\/ppl\/wiki\/XSLTExtensions<\/a>.  The source code for the extensions and the examples are available from the Mercurial repository at <a href=\"https:\/\/dvcs.w3.org\/hg\/ppl\" title=\"PPL CG Mercurial repository\" target=\"_blank\" rel=\"nofollow\">https:\/\/dvcs.w3.org\/hg\/ppl<\/a> and are manually mirrored on GitHub at <a href=\"https:\/\/github.com\/pplcg\/XSLTExtensions\" title=\"PPL CG XSLT Extensions on GitHub\" target=\"_blank\" rel=\"nofollow\">https:\/\/github.com\/pplcg\/XSLTExtensions<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Print and Page Layout Community Group is developing a series of open-source extensions for XSLT processors so you can run any number of iterations of your XSL-FO processor from within your XSLT transformation, which allows you to make decisions &hellip; <a href=\"https:\/\/www.w3.org\/community\/ppl\/2015\/02\/18\/getting-an-area-tree-within-your-xslt-transform\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1252,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_s2mail":"yes","footnotes":""},"categories":[1],"tags":[],"class_list":["post-128","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.w3.org\/community\/ppl\/wp-json\/wp\/v2\/posts\/128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.w3.org\/community\/ppl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.w3.org\/community\/ppl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.w3.org\/community\/ppl\/wp-json\/wp\/v2\/users\/1252"}],"replies":[{"embeddable":true,"href":"https:\/\/www.w3.org\/community\/ppl\/wp-json\/wp\/v2\/comments?post=128"}],"version-history":[{"count":20,"href":"https:\/\/www.w3.org\/community\/ppl\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":156,"href":"https:\/\/www.w3.org\/community\/ppl\/wp-json\/wp\/v2\/posts\/128\/revisions\/156"}],"wp:attachment":[{"href":"https:\/\/www.w3.org\/community\/ppl\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.w3.org\/community\/ppl\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.w3.org\/community\/ppl\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}