Re: fo:table-row is missing child elements Exception

On Wed, Aug 13 2008 21:00:09 +0100, cool_sameer_for_u@yahoo.com wrote:
> I have a piece of code defined in my xslt file in order to format some info
> for the printing purposes.
> But sometimes, the object which I am transforming against this xslt, doesn't
> have the myAccountInfo 
> tag's child elements and I get the exception . But I want something like
> this : 
>                      if the elements exists then print the info otherwise
> just print "not available" or "Unknown" 
> So if firstName element is not available then put "unknown" in place.
...
> Here is a piece of code I am using:
>
> <xsl:template match="myAccountInfo">
>         <fo:table xmlns:fo="http://www.w3.org/1999/XSL/Format"
> table-layout="fixed" font-size="10pt"
>             font-family="Arial, Helvetica, sans-serif">
>             <fo:table-column column-number="1" column-width="1.75in"/>
>             <fo:table-column column-number="2" column-width="1.75in"/>
>             <fo:table-column column-number="3" column-width="1.75in"/>
>             <fo:table-column column-number="4" column-width="1.75in"/>
>             <fo:table-body>
>                 <fo:table-row>
>                     <fo:table-cell
> xmlns:fo="http://www.w3.org/1999/XSL/Format">
>                         <fo:block
> xmlns:fo="http://www.w3.org/1999/XSL/Format" text-align="center"
>                             color="#0000FF" padding-before="2pt"
> padding-bottom="3pt">
>                             <xsl:value-of select="firstName"/>
>                         </fo:block>
>                     </fo:table-cell>
...
>                 </fo:table-row>
>             </fo:table-body>
>         </fo:table>
>     </xsl:template>
>
> and the error I am getting is : 
>
>
> com.user.infra.CustomeException: xml transform error --
> org.apache.fop.fo.ValidationException: :823:-1: Error(823/-1): fo:table-row
> is missing child elements. 
> Required Content Model: (table-cell+)
> 	at com.user.infra.prt.printInit(PrtUtil.java:271)

I don't see how your example causes your error message, since the
fo:table-row does contain fo:table-cell.

Also, it's not necessary to repeat the FO namespace declaration so
often.  Once at the top of your XSLT stylesheet should be sufficient
unless you are overriding the prefix elsewhere in your stylesheet.

Since you have fo:table-cell and and you have repeated namespace
declarations, if this really is the code causing the error message,
there's a very faint possibility that there's a bug in FOP such that
it's checking for equality of objects corresponding to namespace
declarations rather than checking for equality of namespace name URIs.

Regards,


Tony Graham                         Tony.Graham@MenteithConsulting.com
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

Received on Tuesday, 19 August 2008 10:34:44 UTC