|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
empty table problemHi all,
I have a XML document like this: ... <documents> <document> ... </document> <document> ... </document> </documents> and a xsl like this: <fo:block space-after="12"> <fo:table table-layout="fixed" width="100%" border="1" border-style="solid" border-color="#55A0dd"> <fo:table-column /> <fo:table-body> <xsl:apply-templates select="documents/document" /> </fo:table-body> </fo:table> </fo:block> .... <xsl:template match="documents/document"> <fo:table-row> <fo:table-cell> <fo:block font-size="8pt"> <xsl:value-of select="name" /> </fo:block> </fo:table-cell> </fo:table-row> </xsl:template> the problem is when the tag <documents> doesn't contain any <document> tag, so the table header is created but no row added. error: fo:table-body is missing child elements. How could I manage this so when no document tag exists inside documents tag nothing would be displayed? thanks! |
|
|
Re: empty table problemOn Thu, Oct 16 2008 13:31:48 +0100, j.delaguila@... wrote: > Hi all, > I have a XML document like this: > > .... > <documents> > <document> > ... > </document> > <document> > ... > </document> > </documents> > > and a xsl like this: > > <fo:block space-after="12"> > <fo:table table-layout="fixed" width="100%" border="1" > border-style="solid" border-color="#55A0dd"> > <fo:table-column /> > <fo:table-body> > <xsl:apply-templates select="documents/document" /> > </fo:table-body> > </fo:table> > > </fo:block> > ..... > the problem is when the tag <documents> doesn't contain any <document> tag, > so the table header is created but no row added. error: > fo:table-body is missing child elements. > > How could I manage this so when no document tag exists inside documents tag > nothing would be displayed? Put the fo:block inside an xsl:if; i.e., put <xsl:if test="documents/document"> before the <fo:block> and put </xsl:if> after the </fo:block>. Also, you can use "space-after" with fo:table, so the fo:block isn't strictly necessary. Regards, Tony Graham Tony.Graham@... Director W3C XSL FO SG Invited Expert Menteith Consulting Ltd XML, XSL and XSLT consulting, programming and training Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland Registered in Ireland - No. 428599 http://www.menteithconsulting.com -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- xmlroff XSL Formatter http://xmlroff.org xslide Emacs mode http://www.menteith.com/wiki/xslide Unicode: A Primer urn:isbn:0-7645-4625-2 |
| Free embeddable forum powered by Nabble | Forum Help |