"fo: root" отсутствует дочерние элементы - PullRequest
0 голосов
/ 01 июля 2019

Этот xsl: fo, который я использую для генерации pdf, работал нормально в версии fop 0.20.

После того, как я обновил fop до 2.2, я получил эту ошибку:

"fo: root" отсутствует дочерние элементы. Требуемая модель содержимого: (макет-мастер-набор, объявления ?, дерево закладок ?, (последовательность страниц | fox: external-document) +) (контекстная информация недоступна)

tried попытался найти в интернете дочерние элементы для fo: root, но ничего не нашел. Я прилагаю xsl для справки.

Я пропустил какой-либо тег, который нужно добавить? Или последовательность неверна?

  <xsl:template match="Document">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master font-family="Verdana" master-name="simpleA4" page-height="297mm" page-width="210mm" margin-top="10mm" margin-bottom="0mm" margin-left="25mm" margin-right="25mm">
                    <fo:region-body/>
                </fo:simple-page-master>
            </fo:layout-master-set>
            <xsl:apply-templates/>
        </fo:root>
    </xsl:template>

    <xsl:template match="Page">
    <fo:page-sequence master-reference="simpleA4">
      <xsl:if test="(@class) = 'page'">
        <xsl:attribute name="break-after">page</xsl:attribute>
      </xsl:if>
      <fo:flow flow-name="xsl-region-body">
        <xsl:apply-templates/>
      </fo:flow>
    </fo:page-sequence>
  </xsl:template>

  <xsl:template match="Name">
    <fo:block-container height="15cm" width="7cm" top="10mm" left="120mm" position="absolute">
      <fo:block font-family="Verdana, Universe, Arial, Helvetica, sans-serif" font-size="9pt" font-weight="bold">
        <xsl:apply-templates/>
      </fo:block>
    </fo:block-container>
  </xsl:template>
  <xsl:template match="Reference">
    <fo:block-container height="12cm" width="5cm" top="15mm" left="12cm" position="absolute">
      <fo:block font-family="Verdana, Universe, Arial, Helvetica, sans-serif" font-size="8pt">
        <xsl:apply-templates/>
      </fo:block>
    </fo:block-container>
  </xsl:template>


  <xsl:template match="Follow">
    <fo:block-container height="27cm" width="20cm" top="20mm" left="10mm" position="absolute">
        <fo:block font-family="Verdana, Universe, Arial, Helvetica, sans-serif" font-size="9pt" text-align="justify">
            <fo:table table-layout="fixed" width="100%">
                <fo:table-column column-width="45mm" />
                <fo:table-column column-width="5mm" />
                <fo:table-column column-width="proportional-column-width(1)"/>
                <fo:table-body>
                    <xsl:apply-templates/>
                </fo:table-body>
            </fo:table>
        </fo:block>
    </fo:block-container>
  </xsl:template>

  <xsl:template match="img">
    <fo:external-graphic width="34px" height="24px" src="{@src}"/>
  </xsl:template>

  <xsl:template match="Education">
    <fo:table table-layout="fixed" width="100%">
        <fo:table-column column-width="50mm" />
        <fo:table-column column-width="2mm" />
        <fo:table-column column-width="42mm" />
            <fo:table-body>
                <xsl:apply-templates/>
            </fo:table-body>
    </fo:table>
  </xsl:template>

  <xsl:template match="Language">
    <fo:table table-layout="fixed" width="100%">
        <fo:table-column column-width="50mm" />
        <fo:table-column column-width="2mm" />
        <fo:table-column column-width="44mm" />
        <fo:table-column column-width="44mm" />
        <fo:table-body>
            <xsl:apply-templates/>
        </fo:table-body>
    </fo:table>
  </xsl:template>

  <xsl:template match="Job">
    <fo:table table-layout="fixed" width="100%">
        <fo:table-column column-width="50mm" />
        <fo:table-column column-width="44mm" />
        <fo:table-column column-width="44mm" />
        <fo:table-body>
          <xsl:apply-templates/>
        </fo:table-body>
    </fo:table>
  </xsl:template>

  <xsl:template match="top">
    <fo:table-cell>
      <xsl:if test="@colspan>        1">
        <xsl:attribute name="number-columns-spanned">
          <xsl:value-of select="@colspan"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:for-each select="dotted">
        <xsl:attribute name="border-bottom">dashed 1.00pt Red</xsl:attribute>
      </xsl:for-each>


  <xsl:template match="tr">
    <fo:table-row display-align="after">
      <xsl:attribute name="height">2mm</xsl:attribute>
      <xsl:apply-templates/>
    </fo:table-row>
  </xsl:template>
  <xsl:template match="td">
    <fo:table-cell>
      <xsl:if test="@colspan>        1">
        <xsl:attribute name="number-columns-spanned">
          <xsl:value-of select="@colspan"/>
        </xsl:attribute>
      </xsl:if>
      <xsl:for-each select="dotted">
        <xsl:attribute name="border-bottom">dashed 1.00pt Red</xsl:attribute>
      </xsl:for-each>
      <xsl:for-each select="block">
        <xsl:attribute name="display-align">
          <xsl:text>before</xsl:text>
        </xsl:attribute>
        <xsl:attribute name="padding-top">0.60mm</xsl:attribute>
      </xsl:for-each>
      <fo:block>
        <xsl:apply-templates/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>
  <xsl:template match="th">
    <fo:table-cell border="solid 0px black">
      <xsl:if test="@colspan>        1">
        <xsl:attribute name="number-columns-spanned">
          <xsl:value-of select="@colspan"/>
        </xsl:attribute>
      </xsl:if>
      <fo:block font-weight="bold" space-before="8pt" font-size="9pt">
        <xsl:apply-templates/>
      </fo:block>
    </fo:table-cell>
  </xsl:template>


       <xsl:template match="return">
    <fo:block font-family="Verdana, Universe, Arial, Helvetica, sans-serif" font-size="9pt" text-align="justify" space-after="15pt">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
</xsl:stylesheet>

Это сгенерированный xml:

<?xml version="1.0"?>
<Document>
    <Body>
        <AutoPrint base="true">
        </AutoPrint>
        <letter>
            <Page class="pageNoBreak">

                <References>
                    <div class="ref">
                        <lbl></lbl>
                        <div>ABC</div>
                        <lbl>Tel</lbl>
                        <div>662344563</div>
                        <lbl>Date</lbl>
                        <div>03-07-2019</div>
                    </div>
                </References>
                <Branchdetails>
                    <branchName>ABN</branchName>
                    <div>dsfdsfds</div>
                    <div>adres</div>
                    <div>21312434324, </div>
                </Branchdetails>

                <employer>

                        <tr>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                        </tr>
                        <tr>
                            <th>Personalia</th>
                            <th>
                                <empty/>
                            </th>
                            <th>
                                <empty/>
                            </th>
                        </tr>

                        <tr>
                            <td><lbl>Cv-Id</lbl></td>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <strong>20000000034</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                        </tr>

                        <tr>
                            <th>Language
                            </th>
                            <th>
                                <empty/>
                            </th>
                            <td>
                                <Language>
                                    <tr>
                                        <th>Lang</th>
                                        <th>
                                            <empty/>
                                        </th>
                                        <th>Speaking</th>
                                        <th>Written</th>
                                    </tr>
                                    <tr>
                                        <td>English</td>
                                        <td>
                                            <empty/>
                                        </td>
                                        <td>J</td>
                                        <td>J</td>
                                    </tr>
                                </Language>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                        </tr>

                        <tr>
                            <td><lbl>License</lbl></td>
                            <td>
                                <empty/>
                            </td>
                            <td><arialunicode></arialunicode></td>
                        </tr>
                        <tr>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                        </tr>
                        <tr>
                            <th>educationen

                            </th>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                        </tr>


                        <tr>
                            <td><lbl> - </lbl></td>
                            <td>
                                <empty/>
                            </td>
                            <td><arialunicode>Mockeducation</arialunicode></td>
                        </tr>
                        <tr>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                            <td><arialunicode> diploma</arialunicode></td>
                        </tr>



                        <tr>
                            <th>experience
                            </th>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <empty/>
                            </td>
                        </tr>

                        <tr>
                            <td><lbl> - </lbl></td>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <Job>
                                    <tr>
                                        <top>MockJob</top>
                                        <top>--</top>
                                    </tr>
                                    <tr>
                                        <top></top>
                                        <td>
                                            <empty/>
                                        </td>
                                    </tr>
                                </Job>
                            </td>
                        </tr>

                        <tr>
                            <td><lbl> - </lbl></td>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <Job>
                                    <tr>
                                        <top>MockJob</top>
                                        <top>--</top>
                                    </tr>
                                    <tr>
                                        <top></top>
                                        <td>
                                            <empty/>
                                        </td>
                                    </tr>
                                </Job>
                            </td>
                        </tr>

                        <tr>
                            <td><lbl> - </lbl></td>
                            <td>
                                <empty/>
                            </td>
                            <td>
                                <Job>
                                    <tr>
                                        <top>MockJob</top>
                                        <top>--</top>
                                    </tr>
                                    <tr>
                                        <top></top>
                                        <td>
                                            <empty/>
                                        </td>
                                    </tr>
                                </Job>
                            </td>
                        </tr>



                </employer>

            </Page>
        </letter>
    </Body>
</Document>
...