320 likes | 339 Views
Understand the use of XML and XSL to create and customize print files, without altering the raw data. Access a client application for XSL creation, simplifying the process. Learn the benefits of XML's data representation and the flexibility of XSL's syntax for HTML conversion.
E N D
New Print Concept • Full data is delivered in XML format. • XSL is used for format and layout. • XML data + XSL language creates an HTML print file. • As an aid in the customization process, you can view the HTML file in a browser, and print from there. ALEPH XSL Templates
New Print Concept • Customization (translation, formatting and layout) can be an iterative process, without having to re-create the raw data. After XSL is changed, XML data can be re-printed, using new XSL definitions. • We have our own tool (a client application) for creating XSL. ALEPH XSL Templates
Old System Print Product ALEPH XSL Templates
New System Print Product ALEPH XSL Templates
Why XML / XSL ? • Built-in support for UTF-8 (= any language can be printed). • Fast growing standard – help and support readily available. • Regular text file – regular editor (vi, notepad) used for maintenance. ALEPH XSL Templates
Why XML / XSL ? • XML file contains all the data from the relevant Z record(s), independent of what will be printed; therefore, adding data to print form does not require programming. Data fields are easily added. • XSL is a language which supports include files – common blocks can be encapsulated in common functions. ALEPH XSL Templates
XML Background • XML – A standard for representing Data and its meaning. • Like HTML – every data element is surrounded by tags. • Unlike HTML – the tags are not standard, they are defined by the author of the XML document. • Unlike HTML – the tags have semantic meaning, no visual meaning, i.e. they say nothing about how the data should be presented. ALEPH XSL Templates
XML Example <?xml version="1.0"?> <?xml-stylesheet href="pres.xsl" type="text/xsl" encoding="utf-8" ?> <emp> <employee> <first-name>John</first-name> <last-name>Smith</last-name> <birth-date>15/4/1975</birth-date> </employee> <employee> <first-name>George</first-name> <last-name>Dupont</last-name> <birth-date>17/6/1985</birth-date> </employee> </emp> ALEPH XSL Templates
XSL Background • We use another standard / language – XSL – to convert the XML data to HTML presentation. • XSL syntax is based on XML – tags everywhere. • Here is a small XSL program for converting our XML example to HTML: ALEPH XSL Templates
XSL Example <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:for-each select="//employee"> <b>First Name:</b> <xsl:value-of select="./first-name"/><br/> <b>Last Name:</b> <xsl:value-of select="./last-name"/><br/> <b>Birth Date:</b> <xsl:value-of select="./birth-date"/><br/> </xsl:for-each> </xsl:template> </xsl:stylesheet> ALEPH XSL Templates
XML + XSL = HTML ALEPH XSL Templates
A closer look • Let’s look at the following: • <xsl:for-eachselect=“//employee"> • <b>First Name:</b> <xsl:value-of select="./first-name"/><br/> • We tell XSL to go through all the “employee” records, and for each of them display: • Literally ‘<b>First Name:</b>’ • The actual value of the current <first-name> • Literally ‘<br/> • That is: we combine: • literal values, including HTML elements, • Values to be taken from the contents of the XML file. ALEPH XSL Templates
A Broader View • So, if we can add HTML elements to the rendering, we can do anything HTML we want, such as presenting data in grids, deciding on fonts and sizes etc. • More than that, XSL also contains functions. So it is possible to encapsulate report sections that appear more than once (e.g. Sublibrary address, patron address, bib-info etc.) in functions and to invoke them whenever they are needed. ALEPH XSL Templates
XSL in ALEPH • The data for reports in ALEPH (starting 15) are contained in XML files. • For each report, an XSL file is defined (=Template). This template determines: • What fields of the XML are included in the formatted report. • How they should be formatted. ALEPH XSL Templates
XSL in ALEPH – cont • In addition, there are several XSL files which are common to all reports, and they are referred to by all the specific XSL templates. • They contain definitions for the rendering of common report blocks such as the standard salutations, signatures, sublibrary address, patron address etc. ALEPH XSL Templates
XSL in ALEPH – cont. • In principle the system librarian can maintain (=translate, add/remove fields etc.) without actually knowing XSL, • and rely on the patterns found in ALEPH default XSLs. ALEPH XSL Templates
Report Generation DB tables translation START Query client server XML XML XSL Parser XML XSL + HTML ALEPH XSL Templates
A Report ALEPH XSL Templates
Its XML ALEPH XSL Templates
Its XSL (Part 1) <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:include href="funcs.xsl"/> <xsl:template match="/"> <xsl:call-template name="header"/> <!--section-01 (FREE)--> <xsl:for-each select="//section-01"> <xsl:call-template name="section-01"/> </xsl:for-each> </xsl:template> ALEPH XSL Templates
<!-- START DATA --> <xsl:template name="header"> <xsl:call-template name="header-gen"> <xsl:with-param name="title" select="'Arrival Slip'"/> </xsl:call-template> </xsl:template> <!--SECTION-01 (FREE)--> <xsl:template name="section-01"> <xsl:call-template name="sublib-address"/> <xsl:call-template name="bib-info-hdr"> <xsl:with-param name="line" select="./bib-info"/> </xsl:call-template> <xsl:call-template name="table-open"/> <xsl:call-template name="display-gen"> <xsl:with-param name="label" select="'Doc Number:'"/> <xsl:with-param name="value" select="./z68-doc-number"/> </xsl:call-template> <xsl:call-template name="display-gen"> <xsl:with-param name="label" select="'Sequence:'"/> <xsl:with-param name="value" select="./z68-sequence"/> </xsl:call-template> <xsl:call-template name="display-gen"> <xsl:with-param name="label" select="'Order Type:'"/> <xsl:with-param name="value" select="./z68-order-type"/> </xsl:call-template> <xsl:call-template name="display-gen"> <xsl:with-param name="label" select="'Order Number:'"/> <xsl:with-param name="value" select="./z68-order-number"/> </xsl:call-template> <xsl:call-template name="table-close"/> </xsl:template> </xsl:stylesheet> Its XSL (cont.) ALEPH XSL Templates
Comments • ‘header-gen’, ‘sublib-address’, ‘display-gen’ are XSL functions that handle the actual display • All of them are implemented in funcs.xsl or one of the XSL files included in it • All specific templates contain the line ‘<xsl:include href="funcs.xsl"/>’ so they all can invoke the common functions. ALEPH XSL Templates
Now to Customization … ALEPH XSL Templates
Customization • There are 2 basic customizations: • Changing (or translating) labels • Adding or removing data (=Z table columns etc.) • In addition, there is advanced customization - layout change – which will be explained later. ALEPH XSL Templates
Changing Labels • Since the XSL file is a regular ASCII file you just edit it and make the changes you want. ALEPH XSL Templates
Removing Fields • Examine the following snippet: • <xsl:call-template name="display-gen"> • <xsl:with-param name="label" select="'Doc Number:'"/> • <xsl:with-param name="value" select="./z68-doc-number"/> • </xsl:call-template> • <xsl:call-template name="display-gen"> • <xsl:with-param name="label" select="'Sequence:'"/> • <xsl:with-param name="value" select="./z68-sequence"/> • </xsl:call-template> • To remove a field, e.g z68-doc-number, simply delete the lines from ‘<xsl:call-template name="display-gen">’ to ‘</xsl:call-template>’ that contain it (= The blue lines) ALEPH XSL Templates
Adding Fields • To add a field, “cut and paste” the same range of lines, then change “label” and “value” accordingly. For example: • <xsl:call-template name="display-gen"> • <xsl:with-param name="label" select="‘Auto Claim:'"/> • <xsl:with-param name="value" select="./z68-auto-claim"/> • </xsl:call-template> ALEPH XSL Templates
Changing Relative Position • The data will be displayed in the order it appears in the XSL file. So, to change the order in print, simply change the order in the XSL. ALEPH XSL Templates
Common Functions - 1 <xsl:template name="sublib-address"> <TABLE WIDTH="100%" STYLE="font-size: 9pt; font-family: Arial"> <tr><td width="70%"></td><td><xsl:value-of select="//sub-library-address-1-occ1"/></td></tr> <tr><td width="70%"></td><td><xsl:value-of select="//sub-library-address-1-occ2"/></td></tr> <tr><td width="70%"></td><td><xsl:value-of select="//sub-library-address-1-occ3"/></td></tr> <tr><td width="70%"></td><td><xsl:value-of select="//sub-library-address-1-occ4"/></td></tr> <tr><td width="70%"></td><td><xsl:value-of select="//sub-library-address-1-occ5"/></td></tr> <tr><td width="70%"></td><td><xsl:value-of select="//sub-library-address-1-occ6"/></td></tr> <tr><td width="70%"></td><td><xsl:value-of select="//sub-library-address-1-occ7"/></td></tr> </TABLE> </xsl:template> ALEPH XSL Templates
Common Functions: Comment • The function ‘display-gen’ is responsible for displaying most of the data in non-grid format. • There are, however several options for displaying: • Display the label only if there is data attached to it (default) • Display the label even without data • Display the data right justified (numbers) • Display barcode with special barcode font • And combinations of the above • In order to implement all options, display-gen can be invoked using arguments. • Since most of the time the default is used, it is usually called with just the 2 basic arguments, namely ‘label’ and ‘value’. ALEPH XSL Templates
ALEPH Reports Environment • Server • All XSL templates are stored in the server in /usm01/form_LNG. • After any change you have to run Util /I/ 6. This prepares a package to be downloaded when the clients start running. • To tell ALEPH to use XSL for printing, edit: • aleph/a50_5/usm50/tab/form_print_method • Client • All XSL templates are downloaded to: • alephcom\files\USM50\Print Templates\LNG • The XSL parser (saxon) is in alephcom\bin ALEPH XSL Templates