[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Problem with tables
Hi, This error: xsl:attribute: Cannot add attributes to an element if children have been already added to the element. is caused by your template named "say", specificially the <xsl:comment> output. Many of the templates open a start tag for an output element, then do several steps to generate appropriate attributes. Nothing must appear in the output before those attributes are completed. When it uses <xsl:comment>, it has inserted something into the output, and then any additional attributes cannot be added. If you remove the xsl:comment from "say", then that error goes away, and the fo file is generated. The other errors about overlapped table rows are caused by the way rows are processed in DocBook. They are processed by handling the first row, and then recursively applying the row template to handle the next row to take into account any spans. On each recursion, a span value is passed as a parameter from one apply-templates to the next. When you insert your template with match="*" in your customization, you are intercepting the apply-templates to the next row. When your template does xsl:apply-imports to use the original row template, the span param is lost. The missing span param causes the error messages. If your match avoided rows: <xsl:template match="*[not(self::d:row)]"> then it works. I can't say offhand if there are templates for other elements that work this way, so in general I would say that using match="*" with xsl:apply-imports is not a safe practice with DocBook XSL. In XSLT 1.0, it is not possible to use xsl:param with xsl:apply-imports. With XSLT 2.0, it is possible to do so, but it does not automatically pass along any params it receives. Bob Stayton Sagehill Enterprises bobs@sagehill.net ----- Original Message ----- From: "William R. (Bill) Greene" <wrg@acm.org> To: "DocBook Apps" <docbook-apps@lists.oasis-open.org> Sent: Wednesday, September 03, 2008 7:26 PM Subject: Re: [docbook-apps] Problem with tables > I've recreated my problem in a greatly simplified but complete set of > files, which I have appended. I have also located the problem, but I do > not understand it. > > The command that I use is as follows: > > xsltproc --xinclude --nonet --catalogs --output test.fo test.xsl > test.docbook > > If the template indicated by the comment in test.xsl below is commented > out, the following output is seen, and test.fo is generated: > > Making portrait pages on USletter paper (8.5inx11in) > Catalogs cleanup > Free catalog entry > > If the template is not commented out, the following output is seen, and > test.fo is not generated: > > Making portrait pages on USletter paper (8.5inx11in) > Processing book > Processing chapter > Processing table > Processing tgroup > runtime error: file ../../resumatic/trunk/vendor/docbook-xsl- > ns-1.74.0/fo/table.xsl line 478 element attribute > xsl:attribute: Cannot add attributes to an element if children have > been already added to the element. > Processing thead > Processing row > Warning: overlapped row contains content! > Finished processing row > Finished processing thead > Processing tfoot > Processing row > Warning: overlapped row contains content! > Finished processing row > Finished processing tfoot > Processing tbody > Processing row > Warning: overlapped row contains content! > Processing row > Warning: overlapped row contains content! > Processing row > Warning: overlapped row contains content! > Finished processing row > Finished processing row > Finished processing row > Finished processing tbody > Finished processing tgroup > Finished processing table > Finished processing chapter > Finished processing book > error: file test.docbook > xsltRunStylesheet : run failed > Catalogs cleanup > Free catalog entry > make: *** [try] Error 11 > > ****************************************************************************** > * test .docbook: > * > ****************************************************************************** > <?xml version="1.0" encoding="utf-8"?> > <book > version ="5.0" > xml:lang ="en" > xmlns ="http://docbook.org/ns/docbook" > xmlns:xlink="http://www.w3.org/1999/xlink" > xmlns:xi ="http://www.w3.org/2001/XInclude"> > > <xi:include href="test-separate.docbook" > xmlns:xi="http://www.w3.org/2001/XInclude"/> > </book> > ****************************************************************************** > * test- separate.docbook: > * > ****************************************************************************** > <?xml version="1.0" encoding="utf-8"?> > <chapter > xml:id ="separate" > version ="5.0" > xml:lang ="en" > xmlns ="http://docbook.org/ns/docbook" > xmlns:xlink="http://www.w3.org/1999/xlink" > xmlns:xi ="http://www.w3.org/2001/XInclude"> > > <!-- From Walsh (http://docbook.org/tdg5/en/html/cals.table.html): --> > <table xml:id="ex.calstable" frame='all'> > <title>Sample CALS Table</title> > <tgroup cols='5' align='left' colsep='1' rowsep='1'> > <colspec colname='c1'/> > <colspec colname='c2'/> > <colspec colname='c3'/> > <colspec colnum='5' colname='c5'/> > <thead> > <row> > <entry namest="c1" nameend="c2" align="center">Horizontal > Span</entry> > <entry>a3</entry> > <entry>a4</entry> > <entry>a5</entry> > </row> > </thead> > <tfoot> > <row> > <entry>f1</entry> > <entry>f2</entry> > <entry>f3</entry> > <entry>f4</entry> > <entry>f5</entry> > </row> > </tfoot> > <tbody> > <row> > <entry>b1</entry> > <entry>b2</entry> > <entry>b3</entry> > <entry>b4</entry> > <entry morerows='1' valign='middle'><para>Vertical Span</ > para></entry> > </row> > <row> > <entry>c1</entry> > <entry namest="c2" nameend="c3" align='center' morerows='1' > valign='bottom'>Span Both</entry> > <entry>c4</entry> > </row> > <row> > <entry>d1</entry> > <entry>d4</entry> > <entry>d5</entry> > </row> > </tbody> > </tgroup> > </table> > </chapter> > ****************************************************************************** > * test .xsl: > * > ****************************************************************************** > <?xml version="1.0" encoding="utf-8"?> > <xsl:stylesheet > version ="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:d ="http://docbook.org/ns/docbook" > xmlns:fo ="http://www.w3.org/1999/XSL/Format" > exclude-result-prefixes="d"> > > <xsl:import href="../../resumatic/trunk/vendor/docbook-xsl- > ns-1.74.0/fo/docbook.xsl"/> > > <xsl:template name="say"> > <xsl:param name="s"></xsl:param> > <xsl:message><xsl:value-of select="$s"/></xsl:message> > <xsl:comment><xsl:value-of select="$s"/></xsl:comment> > </xsl:template> > > <!-- If the following template is uncommented, xsltproc encounters a > run-time error when processing a tgroup: --> > <!-- > <xsl:template match="*"> > <xsl:call-template name="say"> > <xsl:with-param > name="s" > >Processing <xsl:value-of select="name()"/></xsl:with-param> > </xsl:call-template> > <xsl:apply-imports/> > <xsl:call-template name="say"> > <xsl:with-param > name="s" > >Finished processing <xsl:value-of select="name()"/></ > xsl:with-param> > </xsl:call-template> > </xsl:template> > --> > </xsl:stylesheet> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org > > >
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]