XSL Transformer - XSLT. This XSL Transformer (XSLT) let's you transform an XML file using an XSL (EXtensible Stylesheet Language) file. You can also chose your indentation level if the result is an XML file. Thanks a million to Bram Ruttens aka 'skeltavik' for identifying security issues in this tool and having the integrity to report them. Graphical transformation tool XSLT_TOOL makes it easy to create XML serialization and deserialization programs in SAP. Example is a step by step guide on how to convert internal table data to XML format. After creating the transformation logic, it can be called by an ABAP program using CALL TRANSACTION.
Easily and rapidly convert XML data to HTML and PDF
Storing data, for example as part of an XForms/REST/XQuery [XRX] architecture (see Related topics), is commonplace today. You can query, retrieve, and serialize data stored in this manner to the desired format. For web applications, developers might want to allow users to retrieve data in HTML format (to be viewed in their web browser) or as a PDF file (to be downloaded for later use).
This article shows how you can convert XML data to HTML, to XSL-FO from that HTML, and to PDF from the XSL-FO with the help of an XQuery extension function based on the CSSToXSLFO tool (see Related topics).
Converting XML data to other formatsConvert Xml To Xslt Online
Typically, you need two XSL stylesheets to transform data from XML to HTML and XSL-FO: one to transform XML to HTML and one XSL-FO stylesheet to transform the HTML to an XSL-FO document, which you then convert to PDF using an XSL-FO processor. This process means that in an environment such as a web application that generates reports in HTML and PDF, you must write a new XSLT stylesheet that transforms data to HTML, and then write, debug, and maintain the corresponding XSL-FO stylesheet. Keeping up with these stylesheets can be difficult, and XSL-FO isn't easy to work with. Fortunately, because the reports don't have to be sophisticated, you can easily express the layout in a CSS file. Then, you can further process the CSS file using the
CSSToXSLFO utility, which can generate the XSL-FO document with just a bit of coding.
This process and other, similar situations are perfect use cases for the approach that this article presents—namely, writing an XSLT stylesheet that transforms XML to HTML, then adding a few extra CSS instructions to it so that it can transform the HTML to XSL-FO and then to PDF.
The CSSToXSLFO utility
The
CSSToXSLFO utility allows conversion of an XML document, together with a CSS version 2 (CSS2) stylesheet, into an XSL-FO document. To use this utility, I developed an XQuery extension function to the eXist XML database as part of the XQuery extension module for digital publishing.
Xml To Csv Using Xslt
This utility processes most of the CSS2 specifications. For dealing with specific XSL-FO features, it provides several CSS extension instructions that browsers typically ignore. Use these properties in the
@page rule of the @media print section in the CSS stylesheet. The properties are related to page regions, numbering, references, leaders, named strings, hyphenation, footnotes, external graphics, and foreign elements. Be sure to look at the manual for the CSSToXSLFO utility (see Related topics) for more information on the tool and tips for refining the XSLT stylesheets that you design.
The eXist XML database
eXist-db is an open source database management system built completely with XML technology. It supports, among other standards, XQuery, XPath, and XSLT. eXist stores data according to the XML data model and is highly compliant with the XQuery standard. The stored data is processed with XQuery in an index-based manner. The database also has a full-text index based on Apache Lucene.
The XQuery engine of eXist is extensible, so eXist has various XQuery extension modules. These modules provide XQuery extension functions, such as those for:
Both eXist and
CSSToXSLFO https://ubhigh-power.weebly.com/download-driver-laptop-sony-vaio-core-i3.html. are written in the Java language. At the time of writing, eXist allows you to use the Apache Formatting Objects Processor (FOP) or RenderHouse XEP as the XSL-FO processor. Check the eXist website for instructions on installing the database so you can run the examples for this article.
The eXist module for digital publishing
The eXist module for digital publishing is currently under development and will comprise more functions in the future. Disha suchak software download. For now, it has the
html-to-xslfo() function, which helps with the approach provided in this article.
The intention behind this module is to provide a single source for all the XQuery extension functions needed for digital publishing, including conversion between various formats, such as DocBook, Open XML, DOC, DOCX, .html, PDF, TXT, RTF, PPT, PPTX, and CSV. To install this module within eXist:
Examples![]()
This section analyzes the use of
CSSToXSLFO as it is implemented in the XQuery extension module of eXist for digital publishing. For this task, use the XML data presented in Listing 1, along with the XSLT stylesheet (xml-to-html.xsl) included in the code example available for download.
Note: To make this article easier to read, I didn't include the complete contents of the XSLT stylesheet used. Instead, I present only those elements that make the stylesheet suitable for converting XML to HTML and PDF.
Pc service software tools. The examples will be uploaded to an eXist XML database in a collection called html-and-pdf-single-stylesheet located in the root collection of eXist, so you can view each example in your browser. For example, to see example 1, type this URL in your browser's address bar (assuming that eXist is installed locally):
To use much more of the functionality in the
CSSToXSLFO tool, you don't need any other XQuery code beyond that provided in Listing 2 and Listing 3, which render XML data in HTML format and PDF, respectively. To obtain increasingly refined PDF documents, you must add CSS instructions to the CSS section of the XSLT stylesheet.
Listing 1. An XML document representing a summary of issued invoices (file xml-data.xml in the example code)![]()
The first example, in Listing 2, is an XQuery script that transforms the XML data presented in Listing 1 to HTML. The script uses the
transform:transform() function of eXist, which in turn transforms XML data using an XSLT stylesheet and (optionally) parameters for transformation. You can write the XSLT stylesheet in XSLT 1.0 (based on Apache Xalan) or XSLT 2.0 (optional with Saxon).
Listing 2. XQuery script that transforms XML data to HTML (file example-01.xql in the example code)
Figure 1 shows the rendering of the resulting HTML document in my browser. The HTML document displays a summary of details for three invoices in a non-serif font. (View a text version of the formatted content found in Figures 1 and 2.)
Figure 1. The result of the transformation to HTMLTool To Convert Xml To Html Using Xslt
First, the XML data is converted to HTML, as in the previous example. The resulting HTML document contains all the CSS instructions needed for rendering the HTML document as intended, along with the CSS extension instructions specific to
CSSToXSLFO that will help in using more sophisticated features of XSL-FO.
For a simple use case such as the one presented in this article, you do not need such extension instructions. The
CSSToXSLFO https://ubhigh-power.weebly.com/empire-total-war-skidrow-crack-password-s.html. utility transforms the HTML document into an XSL-FO document that in turn generates a PDF document that will closely resemble the HTML document.
Next, you convert the resulting HTML document to an XSL-FO document using the
html-to-xslfo() function, then generate a PDF document as in Listing 3. To create the PDF, use the render() function of the xslfo eXist module.
Listing 3. XQuery script that transforms XML data to PDF format (file example-02.xql in the example code)Convert Xml To Text
Figure 2 shows the rendered resulting PDF document in my browser. The PDF document displays a summary of details for three invoices in a serif font. (View a text version of the formatted content found in Figures 1 and 2.)
Figure 2. The result of the transformation to PDF format
Listing 4 contains the CSS instructions needed to render XML data in both HTML and PDF. To obtain a similar PDF file, I added only one CSS instruction—to make the table headers bold.
How To Convert Xml To JsonListing 4. CSS instructions to render XML to both HTML and PDF with a similar appearanceConclusion
In this article, you used a simple function to convert XML data to both HTML and PDF formats using just the power and simplicity of CSS syntax and some extension instructions to deal with more complex XSL-FO features. This approach is particularly useful in situations where you have reports or documents with simple styling.
Downloadable resources
How To Convert Xml To PdfRelated topics
Comments
Sign in or register to add and subscribe to comments.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |