emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org export as twiki - Failure to export with error: (wrong-type-argument stringp nil)
@ 2010-03-03  8:48 Mario E. Munich
  2010-03-04  2:26 ` Baoqiu Cui
  0 siblings, 1 reply; 8+ messages in thread
From: Mario E. Munich @ 2010-03-03  8:48 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1146 bytes --]

*What steps will reproduce the problem?*
1. orgmode 0.34c, emacs 23 on Ubuntu 9.10 (this function used to work
in previous
versions of orgmode)
2. Write an org file
3. Use the provided function to export as twiki to find the error message

*What is the expected output? What do you see instead?*
Here is the backtrace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]\\|[
]+\\(:[[:alnum:]_@:]+:\\)[ 	]*$" nil)
  org-docbook-expand(nil)
  byte-code("\b\x13
  org-export-as-docbook()
  (let* ((wconfig ...) (docbook-buf ...) (filename ...) (base ...)
(twiki-file ...)) (and (file-exists-p twiki-file) (delete-file twiki-file))
(message "Processing DocBook XML file...") (shell-command (format "xsltproc
--output %s /home/mariomu/synchronize/site-lisp/docbook2twiki.xsl %s"
twiki-file ...)) (message "Processing DocBook file...done") (if (not ...)
(error "TWiki file was not produced") (set-window-configuration wconfig)
(message "Exporting to TWiki...done") twiki-file))
  org-export-as-twiki()
  call-interactively(org-export-as-twiki nil nil)

[-- Attachment #1.2: Type: text/html, Size: 1292 bytes --]

[-- Attachment #2: backtrace-for-org-export-as-twiki --]
[-- Type: application/octet-stream, Size: 4293 bytes --]

[-- Attachment #3: org-twiki.el --]
[-- Type: text/x-emacs-lisp, Size: 1174 bytes --]

;;
;; File   : org-twiki.el
;; Author : Baoqiu Cui <cbaoqiu AT yahoo DOT com>
;;
;; This is a sample Emacs Lisp function that converts an Org file to
;; TWiki format.  It first converts the Org file into DocBook format,
;; and then use ``xsltproc'' and docbook2twiki.xsl to convert the
;; DocBook XML file into TWiki format.
;;
;; $Id$
;;

(defun org-export-as-twiki ()
  "Export Org file to TWiki."
  (interactive)
  (message "Exporting to TWiki...")
  (let* ((wconfig (current-window-configuration))
	 (docbook-buf (org-export-as-docbook))
	 (filename (buffer-file-name docbook-buf))
	 (base (file-name-sans-extension filename))
	 (twiki-file (concat base ".twiki")))
    (and (file-exists-p twiki-file) (delete-file twiki-file))
    (message "Processing DocBook XML file...")
    (shell-command
     (format "xsltproc --output %s /home/mariomu/synchronize/site-lisp/docbook2twiki.xsl %s"
	     twiki-file (shell-quote-argument filename)))
    (message "Processing DocBook file...done")
    (if (not (file-exists-p twiki-file))
	(error "TWiki file was not produced")
      (set-window-configuration wconfig)
      (message "Exporting to TWiki...done")
      twiki-file)))

[-- Attachment #4: docbook2twiki.xsl --]
[-- Type: text/xml, Size: 18375 bytes --]

<?xml version="1.0" encoding="utf-8"?>
<!-- *******************************************************************

     File: docbook2twiki.xsl
     Author: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
   
     Copyright (C) 2009 Baoqiu Cui
   
     This is an XSL stylesheet that converts DocBook documents
     (http://www.docbook.org/) to TWiki (http://www.twiki.org/) format.
   
     docbook2twiki.xsl is free software: you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation, either version 3 of the
     License, or (at your option) any later version.
     
     This stylesheet is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     General Public License for more details.
     
     A copy of the GNU General Public License can be made from
     <http://www.gnu.org/licenses/>.
   
     Because DocBook contains much more features than TWiki does, this
     stylesheet can only (and will always) support a subset of DocBook
     elements.
     
     Currently this stylesheet works best for DocBook files exported
     from Emacs Org-mode files by the DocBook exporter in Org-mode
     (http://orgmode.org/).  Most formatting features supported by Org
     mode are supported.
   
     Some code and ideas are copied from DocBook2Wiki.xsl that is
     included in the contrib/ directory of DocBook 1.74.0.
   
     $Id: docbook2twiki.xsl 5 2009-05-06 00:32:06Z baoqiu $

     *******************************************************************
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:d = "http://docbook.org/ns/docbook"
		xmlns:xlink="http://www.w3.org/1999/xlink"
                version="1.0">

<xsl:output method="text" encoding="utf-8" indent="yes"/>    
<xsl:strip-space elements="*"/>

<xsl:template match="/">
  <xsl:text>---+!! </xsl:text>
  <xsl:value-of select="/d:article/d:title"/>
  <xsl:text>

%TOC%
</xsl:text>
  <xsl:apply-templates/>
  <xsl:variable name="version">1.0</xsl:variable>
  <xsl:text>
&lt;!-- TWiki file originally generated using docbook2twiki.xsl </xsl:text>
  <xsl:value-of select="$version"/>
  <xsl:text> --&gt;
</xsl:text>
</xsl:template>

<!-- imagedata -->

<xsl:template match="d:imagedata">
  <xsl:if test="parent::d:imageobject[@role!='fo' or not(@role)]">
  <xsl:text>&lt;img src="%ATTACHURL%/</xsl:text>
  <xsl:call-template name="getfilename">
    <xsl:with-param name="fileref">
      <xsl:value-of select="@fileref"/>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:text>"&gt;</xsl:text>
  <xsl:call-template name="newline"/>
  </xsl:if>  
</xsl:template>
    
<!-- section title -->

<xsl:template match="d:title[parent::d:section]"> 
  <xsl:variable name="level" select="count(ancestor-or-self::d:section)"/> 
  <xsl:choose>
    <xsl:when test="$level &lt; 7">
      <xsl:text>
---</xsl:text>
      <xsl:value-of select="substring('++++++', 1, $level)"/>
      <xsl:text> </xsl:text>
      <xsl:apply-templates/>
      <xsl:text>

</xsl:text>
    </xsl:when>
    <!-- Treat section title at 7th level or below as bold text. -->
    <xsl:otherwise>
      <xsl:text>*</xsl:text>
      <xsl:call-template name="remove-trailing-ws">
	<xsl:with-param name="lines" select="."/>
      </xsl:call-template>
      <xsl:text>*</xsl:text>
      <xsl:call-template name="newline"/>
      <xsl:call-template name="newline"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- programlisting -->

<xsl:template match="d:programlisting/text()"> 
  <xsl:call-template name="indent"/>
  <xsl:text>&lt;verbatim&gt;
</xsl:text>

  <xsl:variable name="before" select="count(preceding-sibling::*)"/>
  <xsl:variable name="after" select="count(following-sibling::*)"/>
  <xsl:variable name="proglist" select="."/>

  <xsl:variable name="proglist-1">
    <xsl:choose>
      <xsl:when test="$before = 0">
	<xsl:call-template name="remove-leading-newlines">
          <xsl:with-param name="lines" select="$proglist"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
	<xsl:value-of select="$proglist"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="proglist-2">
    <xsl:choose>
      <xsl:when test="$after = 0">
	<xsl:call-template name="remove-trailing-ws">
	  <xsl:with-param name="lines" select="$proglist-1"/>
	</xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
	<xsl:value-of select="$proglist-1"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:value-of select="$proglist-2"/>
  <xsl:text>
&lt;/verbatim&gt;
</xsl:text>
</xsl:template>

<!-- article/title|info -->

<xsl:template match="d:title|d:info[parent::d:article]"/>

<!-- link -->

<xsl:template match="d:link"> 
  <xsl:variable name="link-url" select="@xlink:href"/>
  <xsl:variable name="desc" select="."/>
  <xsl:choose>
    <xsl:when test="starts-with($link-url, $desc) and
		    starts-with($desc, $link-url)">
      <xsl:value-of select="$desc"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>[[</xsl:text>
      <xsl:value-of select="@xlink:href"/>
      <xsl:text>][</xsl:text>
      <xsl:apply-templates/>
      <xsl:text>]]</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
   
<!-- listitem -->

<xsl:template match="d:listitem">
  <xsl:variable name="listlevel" select="count(ancestor-or-self::d:listitem)"/>
  <xsl:if test="not(parent::d:varlistentry)">
    <xsl:value-of select="substring('                              ', 1, $listlevel * 3)"/>
  </xsl:if>
  <xsl:choose>
    <xsl:when test="parent::d:itemizedlist">
      <xsl:text>* </xsl:text>
    </xsl:when>
    <xsl:when test="parent::d:orderedlist">
      <xsl:text>1. </xsl:text>
    </xsl:when>
    <xsl:when test="parent::d:varlistentry">
      <xsl:text>: </xsl:text>
    </xsl:when>
  </xsl:choose>
  <xsl:apply-templates/>
</xsl:template>

<!-- warning -->

<xsl:template match="d:warning">
  <xsl:call-template name="indent"/>
  <xsl:text>%X% *Warning*: </xsl:text>
  <xsl:apply-templates/>    
  <xsl:call-template name="newline"/>
  <xsl:call-template name="newline"/>
</xsl:template>
     
<!-- tip -->

<xsl:template match="d:tip">
  <xsl:call-template name="indent"/>
  <xsl:text>%T% *Tip*: </xsl:text>
  <xsl:apply-templates/>    
  <xsl:call-template name="newline"/>
  <xsl:call-template name="newline"/>
</xsl:template>
     
<!-- caution -->

<xsl:template match="d:caution">
  <xsl:call-template name="indent"/>
  <xsl:text>%X% *Caution*: </xsl:text>
  <xsl:apply-templates/>    
  <xsl:call-template name="newline"/>
  <xsl:call-template name="newline"/>
</xsl:template>

<!-- note -->

<xsl:template match="d:note">
  <xsl:call-template name="indent"/>
  <xsl:text>*Note*: </xsl:text>
  <xsl:apply-templates/>    
  <xsl:call-template name="newline"/>
  <xsl:call-template name="newline"/>
</xsl:template>

<!-- varlistentry/term -->

<xsl:template match="d:varlistentry/d:term">
  <xsl:variable name="listlevel" select="count(ancestor-or-self::d:listitem)+1"/>
  <xsl:value-of select="substring('                              ', 1, $listlevel * 3)"/>
  <xsl:text>$ </xsl:text>
  <xsl:apply-templates/>  
</xsl:template>

<!-- emphasis -->

<xsl:template match="d:emphasis">
  <!-- Make sure there is a space before the emphasis markup when it is
       needed. -->
  <xsl:if test="count(preceding-sibling::*) &gt; 0 and
		not(preceding-sibling::node()[1][self::text()])">
    <xsl:text> </xsl:text>
  </xsl:if>
  <xsl:choose>
    <xsl:when test="@role = 'underline'">
      <xsl:text>&lt;u&gt;</xsl:text>
      <xsl:apply-templates/>
      <xsl:text>&lt;/u&gt;</xsl:text>
    </xsl:when>
    <xsl:when test="@role = 'bold'">
      <xsl:text>*</xsl:text>
      <xsl:apply-templates/>
      <xsl:text>*</xsl:text>
    </xsl:when>
    <xsl:when test="@role = 'strikethrough'">
      <xsl:text>&lt;strike&gt;</xsl:text>
      <xsl:apply-templates/>
      <xsl:text>&lt;/strike&gt;</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>_</xsl:text>
      <xsl:apply-templates/>
      <xsl:text>_</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- footnote -->

<xsl:template match="d:footnote">
  <xsl:text>{{</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>}}</xsl:text>
</xsl:template>

<!-- footnoteref -->

<xsl:template match="d:footnoteref">
  <xsl:variable name="footnote-id" select="@linkend"/>
  <xsl:apply-templates select="//d:footnote[@xml:id = $footnote-id]"/>
</xsl:template>

<!-- literal -->

<xsl:template match="d:literal">
  <xsl:text>=</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>=</xsl:text>
</xsl:template>

<!-- code -->

<xsl:template match="d:code">
  <!-- Make sure there is a space before the `=' markup when it is
       needed. -->
  <xsl:if test="count(preceding-sibling::*) &gt; 0 and
		not(preceding-sibling::node()[1][self::text()])">
    <xsl:text> </xsl:text>
  </xsl:if>
  <xsl:text>=</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>=</xsl:text>
</xsl:template>

<!-- superscript -->

<xsl:template match="d:superscript">
  <xsl:text>&lt;sup&gt;</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>&lt;/sup&gt;</xsl:text>
</xsl:template>

<!-- subscript -->

<xsl:template match="d:subscript">
  <xsl:text>&lt;sub&gt;</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>&lt;/sub&gt;</xsl:text>
</xsl:template>

<!-- variablelist -->

<xsl:template match="d:variablelist">
  <xsl:apply-templates/>    
</xsl:template>

<!-- para -->

<xsl:template match="d:para">
  <xsl:call-template name="indent"/>
  <xsl:apply-templates/>    
  <!-- Add a newline for a para in listitem or section.  This newline is
       always required in these two situations (and we have special
       handling for listitem too). -->
  <xsl:choose>
    <xsl:when test="parent::d:listitem or
		    parent::d:section">
      <xsl:call-template name="newline"/>
    </xsl:when>
  </xsl:choose>
  <!-- Add a second newline if this para is in a section but itself is
       NOT the last para in that section. -->
  <xsl:choose>
    <xsl:when test="parent::d:section and
		    following-sibling::*">
      <xsl:call-template name="newline"/>
    </xsl:when>
  </xsl:choose>
</xsl:template>

<xsl:template match="d:para" mode="centering">
  <xsl:apply-templates/>
  <xsl:call-template name="newline"/>
  <xsl:call-template name="newline"/>
</xsl:template>

<!-- getfilename -->

<xsl:template name="getfilename">
  <xsl:param name="fileref"/>
  <xsl:choose>  
    <xsl:when test="contains($fileref,'\')">
      <xsl:call-template name="getfilename">
        <xsl:with-param name="fileref">
          <xsl:value-of select="substring-after($fileref,'\')"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:when>
    <xsl:when test="contains($fileref,'/')">
      <xsl:call-template name="getfilename">
        <xsl:with-param name="fileref">
          <xsl:value-of select="substring-after($fileref,'/')"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$fileref"/>
    </xsl:otherwise>
  </xsl:choose>  
</xsl:template>


<!-- HTML table -->
<!-- Here, only <tr> needs to worry about indentation. -->

<xsl:template match="d:table/d:caption"/>

<xsl:template match="d:tr">
  <xsl:call-template name="indent"/>
  <xsl:text>| </xsl:text>
  <xsl:apply-templates/>
  <xsl:call-template name="newline"/>
</xsl:template>

<xsl:template match="d:th">
  <xsl:text>*</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>* | </xsl:text>
</xsl:template>

<xsl:template match="d:td">
  <xsl:apply-templates/>
  <xsl:text> | </xsl:text>
</xsl:template>

<!-- CLAS table -->

<xsl:template match="d:table/d:title">
  <xsl:call-template name="indent"/>
  <xsl:apply-templates/>
  <xsl:call-template name="newline"/>
</xsl:template>

<xsl:template match="d:tgroup">
  <xsl:choose>
    <!-- Special informaltable for text centering -->
    <xsl:when test="count(./*) = 1 and
		    @align='center' and
		    @cols='1'">
      <xsl:text>&lt;div style="text-align: center"&gt;
</xsl:text>
      <xsl:apply-templates select="d:tbody/d:row/d:entry" mode="centering"/>
      <xsl:text>&lt;/div&gt;
</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates select="d:thead"/>
      <xsl:apply-templates select="d:tbody"/>
      <xsl:apply-templates select="d:tfoot"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="d:thead/d:row|d:tbody/d:row|d:tfoot/d:row">
  <xsl:call-template name="indent"/>
  <xsl:text>| </xsl:text>
  <xsl:apply-templates/>
  <xsl:call-template name="newline"/>
</xsl:template>

<xsl:template match="d:thead/d:row/d:entry|d:tfoot/d:row/d:entry">
  <xsl:text>*</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>* | </xsl:text>
</xsl:template>

<xsl:template match="d:tbody/d:row/d:entry">
  <xsl:apply-templates/>
  <xsl:text> | </xsl:text>
</xsl:template>

<xsl:template match="d:tbody/d:row/d:entry" mode="centering">
  <xsl:apply-templates mode="centering"/>
</xsl:template>

<xsl:template match="text()|@*">
  <xsl:variable name="oneline">
    <xsl:call-template name="entity-replace">
      <xsl:with-param name="input-str"
		      select="translate(., '&#xA;&#xD;', '  ')"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:choose>
    <!-- Remove leading spaces in a para -->
    <xsl:when test="parent::d:para and count(preceding-sibling::*) = 0">
      <xsl:call-template name="remove-leading-spaces">
	<xsl:with-param name="text" select="$oneline"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$oneline"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="remove-leading-spaces">
  <xsl:param name="text"/>
  <xsl:if test="starts-with($text, ' ')">
    <xsl:call-template name="remove-leading-spaces">
      <xsl:with-param name="text">
	<xsl:value-of select="substring($text, 2)"/>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:if>
  <xsl:if test="not(starts-with($text, ' '))">
    <xsl:value-of select="$text"/>
  </xsl:if>
</xsl:template>

<xsl:template name="indent">
  <xsl:variable name="listlevel" select="count(ancestor-or-self::d:listitem)"/>
  <xsl:variable name="ind" select="substring('                        ', 1, $listlevel * 3)"/>
  <!-- Additional indent for listitem bullet/number -->
  <xsl:variable name="delta-ind">
    <xsl:choose>
      <xsl:when test="$listlevel &gt; 0">
	<xsl:variable name="latest-listitem"
		      select="ancestor-or-self::d:listitem[1]"/>
	<xsl:choose>
	  <xsl:when test="$latest-listitem/parent::d:orderedlist">
	    <xsl:text>   </xsl:text>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:text>  </xsl:text>
	  </xsl:otherwise>
	</xsl:choose>
      </xsl:when>
      <xsl:otherwise>
	<xsl:text></xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:if test="(self::d:para and position() != 1) or
		parent::d:programlisting or
		self::d:tr">
    <xsl:value-of select="$ind"/><xsl:value-of select="$delta-ind"/>
    <xsl:if test="self::d:para and
		  $listlevel &gt; 0 and
		  count(preceding-sibling::*) &gt; 0 and
		  not(preceding-sibling::node()[1][self::d:programlisting])">
      <xsl:text>%BR%%BR%
</xsl:text>
      <xsl:value-of select="$ind"/><xsl:value-of select="$delta-ind"/>
    </xsl:if>
  </xsl:if>
</xsl:template>

<!-- Insert a newline -->

<xsl:template name="newline">
  <xsl:text>
</xsl:text>
</xsl:template>

<!-- Replace characters `&', `<', and `>' with `&amp;', `&lt;' and
     `&gt;' respectively. -->

<xsl:template name="entity-replace">
  <xsl:param name="input-str"/>
  <xsl:call-template name="string-replace">
    <xsl:with-param name="to" select="'&amp;gt;'"/>
    <xsl:with-param name="from" select="'&gt;'"/> 
    <xsl:with-param name="string">
      <xsl:call-template name="string-replace">
	<xsl:with-param name="to" select="'&amp;lt;'"/>
	<xsl:with-param name="from" select="'&lt;'"/> 
	<xsl:with-param name="string">
	  <xsl:call-template name="string-replace">
	    <xsl:with-param name="to" select="'&amp;amp;'"/>
	    <xsl:with-param name="from" select="'&amp;'"/> 
	    <xsl:with-param name="string" select="$input-str"/>
	  </xsl:call-template>
	</xsl:with-param>
      </xsl:call-template>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>

<!-- Replace all occurences of the character(s) `from' in the string
     `string' with the string `to'. -->

<xsl:template name="string-replace">
  <xsl:param name="string"/>
  <xsl:param name="from"/>
  <xsl:param name="to"/>
  <xsl:choose>
    <xsl:when test="contains($string,$from)">
      <xsl:value-of select="substring-before($string,$from)"/>
      <xsl:value-of select="$to"/>
      <xsl:call-template name="string-replace">
	<xsl:with-param name="string" select="substring-after($string,$from)"/>
	<xsl:with-param name="from" select="$from"/>
	<xsl:with-param name="to" select="$to"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$string"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- Remove leading newlines -->

<xsl:template name="remove-leading-newlines">
  <xsl:param name="lines"/>
  <xsl:choose>
    <xsl:when test="starts-with($lines,'&#xA;') or
                    starts-with($lines,'&#xD;')">
      <xsl:call-template name="remove-leading-newlines">
        <xsl:with-param name="lines" select="substring($lines, 2)"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$lines"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- Remove trailing whitespaces -->

<xsl:template name="remove-trailing-ws">
  <xsl:param name="lines"/>
  <xsl:variable name="last-char">
    <xsl:value-of select="substring($lines, string-length($lines), 1)"/>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="($last-char = '&#xA;') or
                    ($last-char = '&#xD;') or
                    ($last-char = '&#x20;') or
                    ($last-char = '&#x9;')">
      <xsl:call-template name="remove-trailing-ws">
	<xsl:with-param name="lines"
			select="substring($lines, 1,
				string-length($lines) - 1)"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$lines"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>

[-- Attachment #5: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: org export as twiki - Failure to export with error: (wrong-type-argument stringp nil)
  2010-03-03  8:48 Mario E. Munich
@ 2010-03-04  2:26 ` Baoqiu Cui
  0 siblings, 0 replies; 8+ messages in thread
From: Baoqiu Cui @ 2010-03-04  2:26 UTC (permalink / raw)
  To: emacs-orgmode

"Mario E. Munich" <mariomu@ieee.org> writes:

> *What steps will reproduce the problem?*
> 1. orgmode 0.34c, emacs 23 on Ubuntu 9.10 (this function used to work
> in previous
> versions of orgmode)
> 2. Write an org file
> 3. Use the provided function to export as twiki to find the error message
>
> *What is the expected output? What do you see instead?*
> Here is the backtrace:
>
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>   string-match("\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]\\|[
> ]+\\(:[[:alnum:]_@:]+:\\)[ 	]*$" nil)
>   org-docbook-expand(nil)
>   byte-code("\b\x13
>   org-export-as-docbook()
>   (let* ((wconfig ...) (docbook-buf ...) (filename ...) (base ...)
> (twiki-file ...)) (and (file-exists-p twiki-file) (delete-file twiki-file))
> (message "Processing DocBook XML file...") (shell-command (format "xsltproc
> --output %s /home/mariomu/synchronize/site-lisp/docbook2twiki.xsl %s"
> twiki-file ...)) (message "Processing DocBook file...done") (if (not ...)
> (error "TWiki file was not produced") (set-window-configuration wconfig)
> (message "Exporting to TWiki...done") twiki-file))
>   org-export-as-twiki()
>   call-interactively(org-export-as-twiki nil nil)

Hi Mario,

I was not able to recreate this problem using my testing Org file.
Could you please send us your Org file?  It would be great if you can
keep the file small.

Thanks,

-- 
Baoqiu

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: org export as twiki - Failure to export with error: (wrong-type-argument stringp nil)
@ 2010-03-04 19:50 Mario E. Munich
  2010-03-05  5:08 ` Baoqiu Cui
  2010-03-05  5:30 ` Baoqiu Cui
  0 siblings, 2 replies; 8+ messages in thread
From: Mario E. Munich @ 2010-03-04 19:50 UTC (permalink / raw)
  To: cbaoqiu, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 323 bytes --]

Dear Baoqiu,

thanks a lot for the reply... I have done some level of debugging (I
should have probably done it before, but I was not sure of what was
going on) and I had realized that the problem is in using  brackets [ ]
in the text.

Please find enclosed a simple file that will depict the issue.

Best regards,

-Mario

[-- Attachment #2: twiki-export-test.org --]
[-- Type: text/plain, Size: 425 bytes --]

#+FILETAGS: personal

* Converting org pages to Twiki
  - use docbook2twiki http://code.google.com/p/docbook2twiki/ 
    - Checkout docbook2twiki: <2009-09-24 Thu>
      svn checkout http://docbook2twiki.googlecode.com/svn/trunk/ docbook2twiki-read-only
      - retrieved r5 from that repository
    - Load org-twiki.el
    - Publish buffer with: M-x org-export-as-twiki
  - double[9] was less efficient that double[3][3],



[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: org export as twiki - Failure to export with error: (wrong-type-argument stringp nil)
  2010-03-04 19:50 org export as twiki - Failure to export with error: (wrong-type-argument stringp nil) Mario E. Munich
@ 2010-03-05  5:08 ` Baoqiu Cui
  2010-03-05  5:30 ` Baoqiu Cui
  1 sibling, 0 replies; 8+ messages in thread
From: Baoqiu Cui @ 2010-03-05  5:08 UTC (permalink / raw)
  To: emacs-orgmode

"Mario E. Munich" <mariomu@ieee.org> writes:

> Dear Baoqiu,
>
> thanks a lot for the reply... I have done some level of debugging (I
> should have probably done it before, but I was not sure of what was
> going on) and I had realized that the problem is in using  brackets [ ]
> in the text.

Hi Mario,

Thanks for posting your example Org file.  Now I am able to reproduce
the problem and know where the bug is.

Just as what you said, the problem is caused by the last line that
contains strings "double[9]" and "double[3][3]".  Here "[9]" and "[3]"
are considered footnote references (and I don't think this is what you
expected), so some code is executed to find the footnote definitions.

The problem happens when the *second* "[3]" is being processed.
Strictly speaking, the second "[3]" is NOT considered as a footnote
reference according to ``org-footnote-re'' (see org-footnote.el), but
some code in org-docbook.el and org-html.el does not use
``org-footnote-re'' and still treats it as a footnote reference.  This
inconsistency causes the error you saw, which is only visible in
org-docbook.el.

Before I try to fix this problem, I would like to get the confirmation
from Carsten on the footnote syntax: whether the second "[3]", which
immediately follows a character "]", should be treated as a footnote
reference.

To get around of the problem, you can try changing the last line to
something like:

  - =double[9]= was less efficient that =double[3][3]=,

Please let me know if you have further questions.

> Please find enclosed a simple file that will depict the issue.
>
> Best regards,
>
> -Mario
> #+FILETAGS: personal
>
> * Converting org pages to Twiki
>   - use docbook2twiki http://code.google.com/p/docbook2twiki/ 
>     - Checkout docbook2twiki: <2009-09-24 Thu>
>       svn checkout http://docbook2twiki.googlecode.com/svn/trunk/ docbook2twiki-read-only
>       - retrieved r5 from that repository
>     - Load org-twiki.el
>     - Publish buffer with: M-x org-export-as-twiki
>   - double[9] was less efficient that double[3][3],

Thanks,

-- 
Baoqiu

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Re: org export as twiki - Failure to export with error: (wrong-type-argument stringp nil)
  2010-03-04 19:50 org export as twiki - Failure to export with error: (wrong-type-argument stringp nil) Mario E. Munich
  2010-03-05  5:08 ` Baoqiu Cui
@ 2010-03-05  5:30 ` Baoqiu Cui
  2010-03-05  7:47   ` Carsten Dominik
  2010-03-05  8:15   ` Mario E. Munich
  1 sibling, 2 replies; 8+ messages in thread
From: Baoqiu Cui @ 2010-03-05  5:30 UTC (permalink / raw)
  To: Mario E. Munich; +Cc: emacs-orgmode, cbaoqiu, Carsten Dominik

"Mario E. Munich" <mariomu@ieee.org> writes:

> Dear Baoqiu,
>
> thanks a lot for the reply... I have done some level of debugging (I
> should have probably done it before, but I was not sure of what was
> going on) and I had realized that the problem is in using  brackets [ ]
> in the text.
>
> Please find enclosed a simple file that will depict the issue.

Hi Mario,

Thanks for posting your example Org file.  Now I am able to reproduce
the problem and know where the bug is.

Just as you said, the problem is caused by the last line that contains
strings "double[9]" and "double[3][3]".  Here "[9]" and "[3]" are
considered footnote references (and I don't think this is what you
wanted), so some code is executed to find the footnote definitions.

The problem happens when the *second* "[3]" is being processed.
Strictly speaking, the second "[3]" is NOT considered as a footnote
reference according to ``org-footnote-re'' (see org-footnote.el), but
some code in org-docbook.el and org-html.el does not use
``org-footnote-re'' and still treats it as a footnote reference.  This
inconsistency caused the problem you saw, and it is only visible in
DocBook exporter.

Before I try to fix the problem, I'd like to get Carsten's confirmation
on the footnote reference syntax: whether the second "[3]", which
immediately follows a character "]", should be treated as a footnote
reference.

To get around this problem, you can try changing the last line to
something like:

  - =double[9]= was less efficient that =double[3][3]=,

Please let me know if you have further questions.

> Best regards,
>
> -Mario
> #+FILETAGS: personal
>
> * Converting org pages to Twiki
>   - use docbook2twiki http://code.google.com/p/docbook2twiki/ 
>     - Checkout docbook2twiki: <2009-09-24 Thu>
>       svn checkout http://docbook2twiki.googlecode.com/svn/trunk/ docbook2twiki-read-only
>       - retrieved r5 from that repository
>     - Load org-twiki.el
>     - Publish buffer with: M-x org-export-as-twiki
>   - double[9] was less efficient that double[3][3],
>
>

Thanks,

-- 
Baoqiu

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Re: org export as twiki - Failure to export with error: (wrong-type-argument stringp nil)
  2010-03-05  5:30 ` Baoqiu Cui
@ 2010-03-05  7:47   ` Carsten Dominik
  2010-03-05 18:51     ` Baoqiu Cui
  2010-03-05  8:15   ` Mario E. Munich
  1 sibling, 1 reply; 8+ messages in thread
From: Carsten Dominik @ 2010-03-05  7:47 UTC (permalink / raw)
  To: Baoqiu Cui; +Cc: Mario E. Munich, emacs-orgmode


On Mar 5, 2010, at 6:30 AM, Baoqiu Cui wrote:

> "Mario E. Munich" <mariomu@ieee.org> writes:
>
>> Dear Baoqiu,
>>
>> thanks a lot for the reply... I have done some level of debugging (I
>> should have probably done it before, but I was not sure of what was
>> going on) and I had realized that the problem is in using  brackets  
>> [ ]
>> in the text.
>>
>> Please find enclosed a simple file that will depict the issue.
>
> Hi Mario,
>
> Thanks for posting your example Org file.  Now I am able to reproduce
> the problem and know where the bug is.
>
> Just as you said, the problem is caused by the last line that contains
> strings "double[9]" and "double[3][3]".  Here "[9]" and "[3]" are
> considered footnote references (and I don't think this is what you
> wanted), so some code is executed to find the footnote definitions.
>
> The problem happens when the *second* "[3]" is being processed.
> Strictly speaking, the second "[3]" is NOT considered as a footnote
> reference according to ``org-footnote-re'' (see org-footnote.el), but
> some code in org-docbook.el and org-html.el does not use
> ``org-footnote-re'' and still treats it as a footnote reference.  This
> inconsistency caused the problem you saw, and it is only visible in
> DocBook exporter.
>
> Before I try to fix the problem, I'd like to get Carsten's  
> confirmation
> on the footnote reference syntax: whether the second "[3]", which
> immediately follows a character "]", should be treated as a footnote
> reference.
>
> To get around this problem, you can try changing the last line to
> something like:
>
>  - =double[9]= was less efficient that =double[3][3]=,


Hi Baoqiu and Mario,

clearly, writing =double[3][3]= is the correct solution to this problem.

As for the behavior of [3][3], this is not clearly defined.  Neither  
the LaTeX
nor the HTML exporter handle this case gracefully, as in producing  
meaningful output.

Maybe the right thing would be to have them both treated as a footnote  
reference, but that would also require changes to org-footnote.el.   
These changes are not entirely
trivial, as far as I can see now.

So uness you are willing to dig into org-footnote.el to changes this,  
the
easy solution would be to simply catch the problem we have now in the  
docbook exporter, so that it does not crash.

- Carsten

>
> Please let me know if you have further questions.
>
>> Best regards,
>>
>> -Mario
>> #+FILETAGS: personal
>>
>> * Converting org pages to Twiki
>>  - use docbook2twiki http://code.google.com/p/docbook2twiki/
>>    - Checkout docbook2twiki: <2009-09-24 Thu>
>>      svn checkout http://docbook2twiki.googlecode.com/svn/trunk/  
>> docbook2twiki-read-only
>>      - retrieved r5 from that repository
>>    - Load org-twiki.el
>>    - Publish buffer with: M-x org-export-as-twiki
>>  - double[9] was less efficient that double[3][3],
>>
>>
>
> Thanks,
>
> -- 
> Baoqiu

- Carsten

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Re: org export as twiki - Failure to export with error: (wrong-type-argument stringp nil)
  2010-03-05  5:30 ` Baoqiu Cui
  2010-03-05  7:47   ` Carsten Dominik
@ 2010-03-05  8:15   ` Mario E. Munich
  1 sibling, 0 replies; 8+ messages in thread
From: Mario E. Munich @ 2010-03-05  8:15 UTC (permalink / raw)
  To: Baoqiu Cui; +Cc: emacs-orgmode, Carsten Dominik


[-- Attachment #1.1: Type: text/plain, Size: 2468 bytes --]

Dear Baoqui,

thanks a lot for the solution to the problem, it works. I learned a little
bit more about org-mode today and I keep learning everyday how to best use
such a great emacs mode.

Best regards,

-Mario

On Thu, Mar 4, 2010 at 9:30 PM, Baoqiu Cui <cbaoqiu@yahoo.com> wrote:

> "Mario E. Munich" <mariomu@ieee.org> writes:
>
> > Dear Baoqiu,
> >
> > thanks a lot for the reply... I have done some level of debugging (I
> > should have probably done it before, but I was not sure of what was
> > going on) and I had realized that the problem is in using  brackets [ ]
> > in the text.
> >
> > Please find enclosed a simple file that will depict the issue.
>
> Hi Mario,
>
> Thanks for posting your example Org file.  Now I am able to reproduce
> the problem and know where the bug is.
>
> Just as you said, the problem is caused by the last line that contains
> strings "double[9]" and "double[3][3]".  Here "[9]" and "[3]" are
> considered footnote references (and I don't think this is what you
> wanted), so some code is executed to find the footnote definitions.
>
> The problem happens when the *second* "[3]" is being processed.
> Strictly speaking, the second "[3]" is NOT considered as a footnote
> reference according to ``org-footnote-re'' (see org-footnote.el), but
> some code in org-docbook.el and org-html.el does not use
> ``org-footnote-re'' and still treats it as a footnote reference.  This
> inconsistency caused the problem you saw, and it is only visible in
> DocBook exporter.
>
> Before I try to fix the problem, I'd like to get Carsten's confirmation
> on the footnote reference syntax: whether the second "[3]", which
> immediately follows a character "]", should be treated as a footnote
> reference.
>
> To get around this problem, you can try changing the last line to
> something like:
>
>  - =double[9]= was less efficient that =double[3][3]=,
>
> Please let me know if you have further questions.
>
> > Best regards,
> >
> > -Mario
> > #+FILETAGS: personal
> >
> > * Converting org pages to Twiki
> >   - use docbook2twiki http://code.google.com/p/docbook2twiki/
> >     - Checkout docbook2twiki: <2009-09-24 Thu>
> >       svn checkout http://docbook2twiki.googlecode.com/svn/trunk/docbook2twiki-read-only
> >       - retrieved r5 from that repository
> >     - Load org-twiki.el
> >     - Publish buffer with: M-x org-export-as-twiki
> >   - double[9] was less efficient that double[3][3],
> >
> >
>
> Thanks,
>
> --
> Baoqiu
>

[-- Attachment #1.2: Type: text/html, Size: 3353 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: org export as twiki - Failure to export with error: (wrong-type-argument stringp nil)
  2010-03-05  7:47   ` Carsten Dominik
@ 2010-03-05 18:51     ` Baoqiu Cui
  0 siblings, 0 replies; 8+ messages in thread
From: Baoqiu Cui @ 2010-03-05 18:51 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1065 bytes --]

Carsten Dominik <carsten.dominik@gmail.com> writes:

> Hi Baoqiu and Mario,
>
> clearly, writing =double[3][3]= is the correct solution to this problem.
>
> As for the behavior of [3][3], this is not clearly defined.  Neither
> the LaTeX
> nor the HTML exporter handle this case gracefully, as in producing
> meaningful output.
>
> Maybe the right thing would be to have them both treated as a footnote
> reference, but that would also require changes to org-footnote.el.
> These changes are not entirely
> trivial, as far as I can see now.
>
> So uness you are willing to dig into org-footnote.el to changes this,
> the
> easy solution would be to simply catch the problem we have now in the
> docbook exporter, so that it does not crash.

Thanks for the suggestion, Carsten.

Attached below please find the patch for the easy solution for the
DocBook exporter (HTML and LaTeX exporters do not report any visible
errors).  Note that this patch also includes another fix that I had in
my local branch to avoid empty "<listitem></listitem>" caused by inline
tasks.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: footnote-fix.diff --]
[-- Type: text/x-patch, Size: 3127 bytes --]

diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el
index ab0a086..492a660 100644
--- a/lisp/org-docbook.el
+++ b/lisp/org-docbook.el
@@ -624,7 +624,7 @@ publishing directory."
 
 	  ;; End of quote section?
 	  (when (and inquote (string-match "^\\*+ " line))
-	    (insert "]]>\n</programlisting>\n")
+	    (insert "]]></programlisting>\n")
 	    (org-export-docbook-open-para)
 	    (setq inquote nil))
 	  ;; Inside a quote section?
@@ -644,7 +644,7 @@ publishing directory."
 		      (not (string-match "^[ \t]*\\(:.*\\)"
 					 (car lines))))
 	      (setq infixed nil)
-	      (insert "]]>\n</programlisting>\n")
+	      (insert "]]></programlisting>\n")
 	      (org-export-docbook-open-para))
 	    (throw 'nextline nil))
 
@@ -912,7 +912,8 @@ publishing directory."
 	    (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
 	      (if (get-text-property (match-beginning 2) 'org-protected line)
 		  (setq start (match-end 2))
-		(let ((num (match-string 2 line)))
+		(let* ((num (match-string 2 line))
+		       (footnote-def (assoc num footnote-list)))
 		  (if (assoc num footref-seen)
 		      (setq line (replace-match
 				  (format "%s<footnoteref linkend=\"%s%s\"/>"
@@ -924,9 +925,10 @@ publishing directory."
 					(match-string 1 line)
 					org-export-docbook-footnote-id-prefix
 					num
-					(save-match-data
-					  (org-docbook-expand
-					   (cdr (assoc num footnote-list)))))
+					(if footnote-def
+					    (save-match-data
+					      (org-docbook-expand (cdr footnote-def)))
+					  (format "FOOTNOTE DEFINITION NOT FOUND: %s" num)))
 				t t line))
 		    (push (cons num 1) footref-seen))))))
 
@@ -1092,7 +1094,7 @@ publishing directory."
 
       ;; Properly close all local lists and other lists
       (when inquote
-	(insert "]]>\n</programlisting>\n")
+	(insert "]]></programlisting>\n")
 	(org-export-docbook-open-para))
       (when in-local-list
 	;; Close any local lists before inserting a new header line
@@ -1121,6 +1123,13 @@ publishing directory."
 	      "[ \r\n\t]*\\(<para>\\)[ \r\n\t]*</para>[ \r\n\t]*" nil t)
 	(when (not (get-text-property (match-beginning 1) 'org-protected))
 	  (replace-match "\n")
+	  ;; Avoid empty <listitem></listitem> caused by inline tasks.
+	  ;; We should add an empty para to make everything valid.
+	  (when (and (looking-at "</listitem>")
+		     (save-excursion
+		       (backward-char (length "<listitem>\n"))
+		       (looking-at "<listitem>")))
+	    (insert "<para></para>"))
 	  (backward-char 1)))
       ;; Fill empty sections with <para></para>.  This is to make sure
       ;; that the DocBook document generated is valid and well-formed.
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index f20b511..91feb3c 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2423,7 +2423,7 @@ INDENT was the original indentation of the block."
 	      (concat "\n#+BEGIN_DOCBOOK\n"
 		      (org-add-props (concat "<programlisting><![CDATA["
 					     rtn
-					     "]]>\n</programlisting>\n")
+					     "]]></programlisting>\n")
 			  '(org-protected t))
 		      "#+END_DOCBOOK\n"))
 	     ((eq backend 'html)

[-- Attachment #3: Type: text/plain, Size: 21 bytes --]


Thanks,

-- 
Baoqiu

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-03-05 18:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-04 19:50 org export as twiki - Failure to export with error: (wrong-type-argument stringp nil) Mario E. Munich
2010-03-05  5:08 ` Baoqiu Cui
2010-03-05  5:30 ` Baoqiu Cui
2010-03-05  7:47   ` Carsten Dominik
2010-03-05 18:51     ` Baoqiu Cui
2010-03-05  8:15   ` Mario E. Munich
  -- strict thread matches above, loose matches on Subject: below --
2010-03-03  8:48 Mario E. Munich
2010-03-04  2:26 ` Baoqiu Cui

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).