0

I have got a little problem...

But first:

Here is my XML file:

    <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE akweny SYSTEM "akweny.dtd">
<akweny>
    <akwen>
        <nazwa>Atlantycki</nazwa>
        <typ>ocean</typ>
        <powierzchnia>106450</powierzchnia>
        <akweny>
            <akwen>
                <nazwa>Północne</nazwa>
                <typ>morze</typ>
                <powierzchnia>750</powierzchnia>
            </akwen>
            <akwen>
                <nazwa>Batyckie</nazwa>
                <typ>morze</typ>
                <powierzchnia>386</powierzchnia>
                <akweny>
                    <akwen>
                        <nazwa>Botnicka</nazwa>
                        <typ>zatoka</typ>
                        <powierzchnia>117</powierzchnia>
                    </akwen>
                </akweny>
            </akwen>
        </akweny>
    </akwen>
    <akwen>
        <nazwa>Spokojny</nazwa>
        <typ>ocean</typ>
        <powierzchnia>179700</powierzchnia>
    </akwen>
</akweny>

How to generate PDF file using Xquery?

I have got like this:

<table border="1" width="100%">
    <th>Podrzędne</th><th>Nazwa</th><th>Typ</th><th>Powierzchnia</th><th>Edycja</th>
        { 
       let $nodes := doc('/db/Dane/akweny.xml')//akweny[ancestor::*/nazwa="Atlantycki"]
        for $x in $nodes/*
        let $nazwa := $x/nazwa/text()
        let $typ := $x/typ/text()
        let $powierzchnia := $x/powierzchnia/text()
            return 
            <tr>
    <th><img src="/exist/apps/Obrazki/lupa.jpg" alt="Podrzedny" /></a></th>
                <th bgcolor="#F46978">{$nazwa}</th>
                <th>{$typ}</th>
                <th>{$powierzchnia}</th>
<th>Edytuj</th>
            </tr>

And so it was not so good file must be generated after clicking on the PRINT button...

Any sugestion? I'm working on it for over a week and I can not deal with this snap out of it ...

Brieg
  • 63
  • 13

1 Answers1

3

eXist-db can generate PDFs using the XSL-FO module, which by default is configured to use Apache FOP. The idea is that if you can transform your XML into XSL-FO, then you can pass the XSL-FO to the XSL-FO module, which will then generate the PDF for you. The module's functions are documented at http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/xslfo. This module is not enabled by default, so here's what you need to do:

  1. Quit eXist-db if it's running.

  2. Edit $EXIST_HOME/extensions/local.build.properties (or if you do not have this file, duplicate the build.properties file in that directory, and rename the duplicate local.build.properties) to turn the line include.module.xslfo = false to include.module.xslfo = true.

  3. Rebuild eXist-db with build.sh rebuild (or build.bat rebuild on Windows)

  4. Uncomment the XSL-FO module in conf.xml, the block beginning with <module uri="http://exist-db.org/xquery/xslfo" class="org.exist.xquery.modules.xslfo.XSLFOModule">

  5. Restart eXist-db

  6. Now you can use the xslfo:render() function.

Joe Wicentowski
  • 5,159
  • 16
  • 26
  • I know that I have 2 eyes ... but is it a good thing that I see 2 of the same content in the documentation Exist-db? Here:http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/xslfo&location=java:org.exist.xquery.modules.xslfo.XSLFOModule So how can i use this function? In Exist-DB i got this error: error found while executing expression: org.exist.xquery.XPathException: err:XPST0003 expecting closing parenthesis ')', found 'as' [at line 74, column 24] – Brieg Mar 08 '14 at 22:54
  • (1) If you look closely with those 2 eyes ;), you'll see that the first function has 3 parameters and the second has 4 - the 4th being a configuration file. If you don't need to provide a configuration file, use the 1st function. (2) Your sample XQuery is incomplete, and assuming you close it with `}`, you've got an unnecessary `` on the line with the ``. (3) Your sample XQuery produces HTML, not XSL-FO. So you're at least one step away from having XSL-FO to pass to the `xslfo:render()` function. – Joe Wicentowski Mar 09 '14 at 02:23
  • Thx @joewiz i found solutions! THX VERY MUCH AGAIN! U Save my ass ;) – Brieg Mar 09 '14 at 02:30