XSL : want to control the table row display

Following is my xml structure:

<Questions>
       <Question no="1" verbiage="Enter your Name">
           <Answers>
           <Answer> "x"</Answer>
           <Answer> "y"</Answer>
           </Answers>
       </Question>
       <Question no="2" verbiage="Enter your City">
           <Answers>
           <Answer> "cccc"</Answer>
           </Answers>
       </Question>
       <Question no="3" verbiage="Enter your State">
           <Answers>
           <Answer> "NJ"</Answer>
           </Answers>
       </Question>
       <Question no="4" verbiage="Enter your Country">
           <Answers>
           <Answer> "USA"</Answer>
           </Answers>
       </Question>
</Questions>

I am having 500 questions in my xml file.When a question is a 4 line text, part of the question is rendered in first page and another part in second page.I just want to display that particular row in either 1st page or 2nd page. I am using  <fo:table>
not html <TABLE>.

jaffersathickAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

htang_usCommented:
Don't quite understand your question.

What's your expected output? a question.fo file? You want to generate PDF file?

Which part do you want to put in first page and which in second page?
0
htang_usCommented:
Is this your school homework?
0
htang_usCommented:
which is your "paticular row"? how do you decide it?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

jaffersathickAuthor Commented:
I am generating a pdf thru Apache FOP.My flow of execution is  XML and XSLT are the inputs for XSLT engine and it generates a XSLFO document which is fed to FOP that in turn generates PDF.So basically i have to create the xslt file for this process.

WHICH ROW?
My wish is no single row should partially appear in two pages.It should be a complete row either in page'X' or page'Y'.

example
<Questions>
       <Question no="1" verbiage=""If person1 does not administer the mental/nervous benefit, has the customer
                                                   agrees to provide eligibility to the non-person mental health benefit administrator.">
           <Answers>
           <Answer> "x"</Answer>
           <Answer> "y"</Answer>
           </Answers>
       </Question>
</Question>.

In my pdf the above Question Verbiage appears as

page X:
1            If person1 does not administer                 x,y
              the mental/nervous              

page Y:(Remaining part)
             benefit, has the customer agrees
             to provide eligibility to the non-person
             mental health benefit administrator.">
 
I just want the above not to split up in two pages.
Hope you understand this time.
0
htang_usCommented:
Here you go

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
      
      <xsl:template match="/input">
            <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
                  <fo:layout-master-set>
                        <fo:simple-page-master master-name="first" page-height="11in" page-width="8.5in" margin-top="1in" margin-bottom="1in" margin-left="1in" margin-right="1in">
                              <fo:region-body margin-top="0.5in"></fo:region-body>
                              <fo:region-before extent="0.5in"/>
                        </fo:simple-page-master>
                  </fo:layout-master-set>
      
                  <fo:page-sequence master-reference="first">
                        <fo:static-content flow-name="xsl-region-before">
                              <fo:block font-size="15pt" font-weight="bold" text-align="center">Questions</fo:block>
                        </fo:static-content>
                              
                        <fo:flow flow-name="xsl-region-body">
                              <fo:block font-size="10pt" line-height="12pt" id="define-toc">
                                    <fo:table table-layout="fixed">
                                          <fo:table-column column-width="3in"/><!-- Question -->
                                          <fo:table-column column-width="3in"/><!-- Answer -->
                                          
                                          <fo:table-header>
                                                <fo:table-row font-size="12pt" font-weight="bold"  line-height="15pt">
                                                      <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid" background-color="#dddddd">
                                                            <fo:block>Question</fo:block>
                                                      </fo:table-cell>
                                                      <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid" background-color="#dddddd">
                                                            <fo:block>Answer</fo:block>
                                                      </fo:table-cell>
                                                </fo:table-row>
                                          </fo:table-header>
                                          
                                          <fo:table-body font-size="10pt" line-height="12pt">
                                                <xsl:for-each select="Questions">
                                                      <fo:table-row keep-with-next="always">
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                  <fo:block><xsl:value-of select="Question[@no=1]/@verbiage"/></fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                  <fo:block><xsl:value-of select="Question[@no=1]/Answers/Answer[1]"/></fo:block>
                                                            </fo:table-cell>
                                                      </fo:table-row>
                                                      <fo:table-row keep-with-next="always">
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                  <fo:block><xsl:value-of select="Question[@no=2]/@verbiage"/></fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                  <fo:block><xsl:value-of select="Question[@no=2]/Answers/Answer[1]"/></fo:block>
                                                            </fo:table-cell>
                                                      </fo:table-row>
                                                      <fo:table-row keep-with-next="always">
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                  <fo:block><xsl:value-of select="Question[@no=3]/@verbiage"/></fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                  <fo:block><xsl:value-of select="Question[@no=3]/Answers/Answer[1]"/></fo:block>
                                                            </fo:table-cell>
                                                      </fo:table-row>
                                                      <fo:table-row>
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                  <fo:block><xsl:value-of select="Question[@no=4]/@verbiage"/></fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                  <fo:block><xsl:value-of select="Question[@no=4]/Answers/Answer[1]"/></fo:block>
                                                            </fo:table-cell>
                                                      </fo:table-row>
                                                      <fo:table-row keep-with-previous="always">
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid" background-color="#d0d0d0">
                                                                  <fo:block>----</fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid"  background-color="#d0d0d0">
                                                                  <fo:block>----</fo:block>
                                                            </fo:table-cell>
                                                      </fo:table-row>
                                                </xsl:for-each>
                                          </fo:table-body>
                                    </fo:table>
                              </fo:block>
                        </fo:flow>
                  </fo:page-sequence>
            </fo:root>
      </xsl:template>
</xsl:stylesheet>
0
htang_usCommented:
Forget to put your source files, I make a little change

<input>
      <Questions>
            <Question no="1" verbiage="Enter your Name">
                  <Answers>
                        <Answer> "x"</Answer>
                        <Answer> "y"</Answer>
                  </Answers>
            </Question>
            <Question no="2" verbiage="Enter your City">
                  <Answers>
                        <Answer> "cccc"</Answer>
                  </Answers>
            </Question>
            <Question no="3" verbiage="Enter your State">
                  <Answers>
                        <Answer> "NJ"</Answer>
                  </Answers>
            </Question>
            <Question no="4" verbiage="Enter your Country">
                  <Answers>
                        <Answer> "USA"</Answer>
                  </Answers>
            </Question>
      </Questions>

... here repeat questions element multiple times, so we can get multiple page output ...
</input>
0
htang_usCommented:
If your input contains <Questions> as root element and all <Question> elements with "no" attribute running from 1 to 500. You just need to modify the original stylesheet for fo:table-body. It will somehow like this

<xsl:for-each select="Question">
  <xsl:if test="@no % 4 = 1">
                                                      <fo:table-row keep-with-next="always">
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                  <fo:block><xsl:value-of select="@verbiage"/></fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                  <fo:block><xsl:value-of select="Answers/Answer[1]"/></fo:block>
                                                            </fo:table-cell>
                                                      </fo:table-row>

  </xsl:if>

... then repeat this for 2, 3, and 4's situations ...

</xsl:for-each>
0
htang_usCommented:
Here is the solution for your original source file

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
      
      <xsl:template match="/Questions">
            <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
                  <fo:layout-master-set>
                        <fo:simple-page-master master-name="first" page-height="11in" page-width="8.5in" margin-top="1in" margin-bottom="1in" margin-left="1in" margin-right="1in">
                              <fo:region-body margin-top="0.5in"></fo:region-body>
                              <fo:region-before extent="0.5in"/>
                        </fo:simple-page-master>
                  </fo:layout-master-set>
      
                  <fo:page-sequence master-reference="first">
                        <fo:static-content flow-name="xsl-region-before">
                              <fo:block font-size="15pt" font-weight="bold" text-align="center">Questions</fo:block>
                        </fo:static-content>
                              
                        <fo:flow flow-name="xsl-region-body">
                              <fo:block font-size="10pt" line-height="12pt" id="define-toc">
                                    <fo:table table-layout="fixed">
                                          <fo:table-column column-width="3in"/><!-- Question -->
                                          <fo:table-column column-width="3in"/><!-- Answer -->
                                          
                                          <fo:table-header>
                                                <fo:table-row font-size="12pt" font-weight="bold"  line-height="15pt">
                                                      <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid" background-color="#dddddd">
                                                            <fo:block>Question</fo:block>
                                                      </fo:table-cell>
                                                      <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid" background-color="#dddddd">
                                                            <fo:block>Answer</fo:block>
                                                      </fo:table-cell>
                                                </fo:table-row>
                                          </fo:table-header>
                                          
                                          <fo:table-body font-size="10pt" line-height="32pt">
                                                <xsl:for-each select="Question">
                                                      <xsl:choose>
                                                            <xsl:when test="number(@no) mod 4=0">
                                                                  <fo:table-row>
                                                                        <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                              <fo:block><xsl:value-of select="@verbiage"/></fo:block>
                                                                        </fo:table-cell>
                                                                        <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                              <fo:block><xsl:value-of select="Answers/Answer[1]"/></fo:block>
                                                                        </fo:table-cell>
                                                                  </fo:table-row>
                                                                  <fo:table-row keep-with-previous="always">
                                                                        <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid" background-color="#d0d0d0">
                                                                              <fo:block>----</fo:block>
                                                                        </fo:table-cell>
                                                                        <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid"  background-color="#d0d0d0">
                                                                              <fo:block>----</fo:block>
                                                                        </fo:table-cell>
                                                                  </fo:table-row>
                                                            </xsl:when>
                                                            <xsl:otherwise>
                                                                  <fo:table-row keep-with-next="always">
                                                                        <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                              <fo:block><xsl:value-of select="@verbiage"/></fo:block>
                                                                        </fo:table-cell>
                                                                        <fo:table-cell border-color="#cccccc" border-width="0.5pt" border-style="solid">
                                                                              <fo:block><xsl:value-of select="Answers/Answer[1]"/></fo:block>
                                                                        </fo:table-cell>
                                                                  </fo:table-row>
                                                            </xsl:otherwise>
                                                      </xsl:choose>
                                                </xsl:for-each>
                                          </fo:table-body>
                                    </fo:table>
                              </fo:block>
                        </fo:flow>
                  </fo:page-sequence>
            </fo:root>
      </xsl:template>
</xsl:stylesheet>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jaffersathickAuthor Commented:
Thanks a lot for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.