emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Baoqiu Cui <cbaoqiu@yahoo.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Re: Custom docbook stylesheets.
Date: Fri, 14 May 2010 13:39:44 +0200	[thread overview]
Message-ID: <4A4601B5-415C-4320-824D-D790D7154F32@gmail.com> (raw)
In-Reply-To: <byc39xvz93u.fsf_-_@muchbodyking-lm.corp.yahoo.com>

Dear Baoqiu,

thanks for the patch, I applied it.  Can you please also make a patch  
for the documentation - I think #+XSLT must be mentioned in the export  
chapter....

And an entry for the Changes.org file would indeed be nice, can you  
write that as well?

Thanks!

- Carsten

On May 14, 2010, at 1:15 AM, Baoqiu Cui wrote:

> dsmith@vtiinstruments.com (Dale P. Smith) writes:
>
>> Baoqiu Cui <cbaoqiu@yahoo.com> writes:
>>
>>> Before I change the document for variable
>>> `org-export-docbook-xslt-proc-command', let's finalize the design of
>>> this first. :-)
>>>
>>> Currently `org-export-docbook-xslt-proc-command' contains two
>>> format-like specs: "%i" (for the input DocBook XML file) and  
>>> "%o" (for
>>> the output FO file).  Values of these two specs will be generated  
>>> based
>>> on the Org file name to be exported.
>>>
>>> We should add a 3rd spec, "%s", to this variable for the XSLT  
>>> stylesheet
>>> that users would like to use for exporting the Org file.  As Dale
>>> pointed earlier, users would like to use different stylesheets for
>>> different Org files.  By default, the value of the stylesheet is set
>>> based on a new customizable variable called
>>> `org-export-docbook-xslt-stylesheet'.  However users can use # 
>>> +XSLT in
>>> each individual Org file to override it.
>>>
>>> Are you OK with this?
>>
>> I am.  It's pretty much exactly what I was thinking.
>
> Great!  I am attaching a patch that does what was described above.
>
> Carsten: This patch introduces a minor "incompatible" change in  
> DocBook
> exporter.  Maybe you want to mention that in the next Org-mode  
> release;
> otherwise users of DocBook exporter will hit exporting failures caused
> by their old invalid customizable variable settings.
>
> BTW, I am not sure if my way of setting/checking the newly added
> property of :xslt is the best one.  You can change it if you see any
> problem.
>
> diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el
> index 768702f..bbd0bed 100644
> --- a/lisp/org-docbook.el
> +++ b/lisp/org-docbook.el
> @@ -184,32 +184,39 @@ default, but users can override them using `# 
> +ATTR_DocBook:'."
>   :group 'org-export-docbook
>   :type 'coding-system)
>
> +(defcustom org-export-docbook-xslt-stylesheet nil
> +  "File name of the XSLT stylesheet used by DocBook exporter.
> +This XSLT stylesheet is used by
> +`org-export-docbook-xslt-proc-command' to generate the Formatting
> +Object (FO) files.  You can use either `fo/docbook.xsl' that
> +comes with DocBook, or any customization layer you may have."
> +  :group 'org-export-docbook
> +  :type 'string)
> +
> (defcustom org-export-docbook-xslt-proc-command nil
> -  "XSLT processor command used by DocBook exporter.
> -This is the command used to process a DocBook XML file to
> -generate the formatting object (FO) file.
> +  "Format of XSLT processor command used by DocBook exporter.
> +This command is used to process a DocBook XML file to generate
> +the Formatting Object (FO) file.
>
> The value of this variable should be a format control string that
> -includes two `%s' arguments: the first one is for the output FO
> -file name, and the second one is for the input DocBook XML file
> -name.
> +includes three arguments: `%i', `%o', and `%s'.  During exporting
> +time, `%i' is replaced by the input DocBook XML file name, `%o'
> +is replaced by the output FO file name, and `%s' is replaced by
> +`org-export-docbook-xslt-stylesheet' (or the #+XSLT option if it
> +is specified in the Org file).
>
> For example, if you use Saxon as the XSLT processor, you may want
> to set the variable to
>
> -  \"java com.icl.saxon.StyleSheet -o %s %s /path/to/docbook.xsl\"
> +  \"java com.icl.saxon.StyleSheet -o %o %i %s\"
>
> If you use Xalan, you can set it to
>
> -  \"java org.apache.xalan.xslt.Process -out %s -in %s -xsl /path/to/ 
> docbook.xsl\"
> +  \"java org.apache.xalan.xslt.Process -out %o -in %i -xsl %s\"
>
> For xsltproc, the following string should work:
>
> -  \"xsltproc --output %s /path/to/docbook.xsl %s\"
> -
> -You need to replace \"/path/to/docbook.xsl\" with the actual path
> -to the DocBook stylesheet file on your machine.  You can also
> -replace it with your own customization layer if you have one.
> +  \"xsltproc --output %o %s %i\"
>
> You can include additional stylesheet parameters in this command.
> Just make sure that they meet the syntax requirement of each
> @@ -218,18 +225,19 @@ processor."
>   :type 'string)
>
> (defcustom org-export-docbook-xsl-fo-proc-command nil
> -  "XSL-FO processor command used by DocBook exporter.
> -This is the command used to process a formatting object (FO) file
> -to generate the PDF file.
> +  "Format of XSL-FO processor command used by DocBook exporter.
> +This command is used to process a Formatting Object (FO) file to
> +generate the PDF file.
>
> The value of this variable should be a format control string that
> -includes two `%s' arguments: the first one is for the input FO
> -file name, and the second one is for the output PDF file name.
> +includes two arguments: `%i' and `%o'.  During exporting time,
> +`%i' is replaced by the input FO file name, and `%o' is replaced
> +by the output PDF file name.
>
> For example, if you use FOP as the XSL-FO processor, you can set
> the variable to
>
> -  \"fop %s %s\""
> +  \"fop %i %o\""
>   :group 'org-export-docbook
>   :type 'string)
>
> @@ -334,13 +342,18 @@ in a window.  A non-interactive call will only  
> return the buffer."
>   "Export as DocBook XML file, and generate PDF file."
>   (interactive "P")
>   (if (or (not org-export-docbook-xslt-proc-command)
> -	  (not (string-match "%[io].+%[io]" org-export-docbook-xslt-proc- 
> command)))
> +	  (not (string-match "%[ios].+%[ios].+%[ios]" org-export-docbook- 
> xslt-proc-command)))
>       (error "XSLT processor command is not set correctly"))
>   (if (or (not org-export-docbook-xsl-fo-proc-command)
> 	  (not (string-match "%[io].+%[io]" org-export-docbook-xsl-fo-proc- 
> command)))
>       (error "XSL-FO processor command is not set correctly"))
>   (message "Exporting to PDF...")
>   (let* ((wconfig (current-window-configuration))
> +	 (opt-plist
> +	  (org-export-process-option-filters
> +	   (org-combine-plists (org-default-export-plist)
> +			       ext-plist
> +			       (org-infile-export-plist))))
> 	 (docbook-buf (org-export-as-docbook hidden ext-plist
> 					     to-buffer body-only pub-dir))
> 	 (filename (buffer-file-name docbook-buf))
> @@ -350,9 +363,16 @@ in a window.  A non-interactive call will only  
> return the buffer."
>     (and (file-exists-p pdffile) (delete-file pdffile))
>     (message "Processing DocBook XML file...")
>     (shell-command (format-spec org-export-docbook-xslt-proc-command
> -				(format-spec-make ?o fofile ?i (shell-quote-argument filename))))
> +				(format-spec-make
> +				 ?i (shell-quote-argument filename)
> +				 ?o (shell-quote-argument fofile)
> +				 ?s (shell-quote-argument
> +				     (or (plist-get opt-plist :xslt)
> +					 org-export-docbook-xslt-stylesheet)))))
>     (shell-command (format-spec org-export-docbook-xsl-fo-proc-command
> -				(format-spec-make ?i fofile ?o pdffile)))
> +				(format-spec-make
> +				 ?i (shell-quote-argument fofile)
> +				 ?o (shell-quote-argument pdffile))))
>     (message "Processing DocBook file...done")
>     (if (not (file-exists-p pdffile))
> 	(error "PDF file was not produced")
> diff --git a/lisp/org-exp.el b/lisp/org-exp.el
> index c32dd2a..147a1f6 100644
> --- a/lisp/org-exp.el
> +++ b/lisp/org-exp.el
> @@ -704,7 +704,7 @@ modified) list.")
> 		    "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE"
> 		    "LATEX_HEADER" "LATEX_CLASS"
> 		    "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS"
> -		    "KEYWORDS" "DESCRIPTION" "MACRO" "BIND")
> +		    "KEYWORDS" "DESCRIPTION" "MACRO" "BIND" "XSLT")
> 		  (mapcar 'car org-export-inbuffer-options-extra))))
> 	    p key val text options a pr style
> 	    latex-header latex-class macros letbind
> @@ -740,6 +740,8 @@ modified) list.")
> 	    (setq options (concat val " " options)))
> 	   ((string-equal key "BIND")
> 	    (push (read (concat "(" val ")")) letbind))
> +	   ((string-equal key "XSLT")
> +	    (setq p (plist-put p :xslt val)))
> 	   ((string-equal key "LINK_UP")
> 	    (setq p (plist-put p :link-up val)))
> 	   ((string-equal key "LINK_HOME")
>
> Thanks,
>
> -- 
> Baoqiu
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

  reply	other threads:[~2010-05-14 11:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-27  0:13 Custom docbook stylesheets Dale Smith
2009-05-27  9:39 ` Carsten Dominik
2009-05-27 18:59   ` Baoqiu Cui
2009-05-28  5:31     ` Carsten Dominik
2009-05-28 14:17       ` Dale Smith
2009-06-23 15:29       ` Dale Smith
2009-06-22 15:25     ` Dale Smith
2009-06-22 19:05       ` Dale Smith
2009-06-23  6:13         ` Baoqiu Cui
2009-06-23 15:10           ` Dale Smith
2010-05-03 19:25           ` Dale P. Smith
2010-05-13  5:39             ` Carsten Dominik
2010-05-13 14:11               ` Dale P. Smith
2010-05-13 18:19                 ` Carsten Dominik
2010-05-13 18:51                   ` Dale P. Smith
2010-05-13 19:45                     ` Baoqiu Cui
2010-05-13 21:09                       ` Dale P. Smith
2010-05-13 23:15                         ` [PATCH] " Baoqiu Cui
2010-05-14 11:39                           ` Carsten Dominik [this message]
2010-05-15  4:01                             ` Baoqiu Cui
2010-05-15  6:13                               ` Carsten Dominik
2010-05-13 19:06               ` Baoqiu Cui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A4601B5-415C-4320-824D-D790D7154F32@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=cbaoqiu@yahoo.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).