Я работаю над XSL FO для генерации PDF с использованием FOP.NET. У меня есть требование генерировать столбцы динамически на основе XML, который я получаю от БД. Ниже представлен формат XML, который мне нужен, и мне нужно генерировать столбцы динамически, а не жестко кодировать их в таблице стилей xsl fo. Любая помощь была бы весьма признательна.XSL FO генерирует колонки динамики
Edit:
Моя цель состоит в том, чтобы построить 20 типов отчетов и хотите сделать это динамически с 1 XSL Fo. Это возможно? или мне нужно иметь 20 файлов xsl fo для создания отчета? Пожалуйста, предложите оптимальный способ сделать это. Я не хочу использовать itextsharp и другие платные инструменты. (Только XSL FO)
Ниже приведен XML, который я получаю от SQL Server.
<?xml version="1.0" standalone="yes"?>
<Products>
<Product id="1" name="Rendezvous with Rama by Arthur C. Clarke" price="15" quantity="3" description="An all-time science fiction classic, Rendezvous with Rama is also one of Clarke's best novels--it won the Campbell, Hugo, Jupiter, and Nebula Awards." />
<Product id="2" name="Dune Chronicles by Frank Herbert" price="60" quantity="5" description="Dune is one of the most famous science fiction novels ever written, and deservedly so. The setting is elaborate and ornate, the plot labyrinthine, the adventures exciting. Five sequels follow." />
<Product id="3" name="Schindler's List by Thomas Keneally" price="21" quantity="6" description="A mesmerizing novel based on the true story of Oskar Schindler, a German industralist who saved and succored more than 1000 Jews from the Nazis at enormous financial and emotional expense." />
<Product id="4" name="Middle Passage by Charles Johnson" price="17" quantity="4" description="In this savage parable of the African American experience, Rutherford Calhoun, a newly freed slave eking out a living in New Orleans in 1830, hops aboard a square rigger to evade the prim Boston schoolteacher who wants to marry him. But the Republic turns out to be a slave clipper bound for Africa." />
<Product id="5" name="Underworld:A Novel by Don DeLillo" price="14" quantity="3" description="Underworld opens with a breathlessly graceful prologue set during the final game of the Giants-Dodgers pennant race in 1951. Written in what DeLillo calls super-omniscience the sentences sweep from young Cotter Martin as he jumps the gate to the press box, soars over the radio waves, runs out to the diamond, slides in on a fast ball, pops into the stands where J. It's an absolutely thrilling literary moment." />
<Product id="6" name="Stones from the River by Ursula Hegi" price="16" quantity="4" description="Ursula Hegi's Stones from the River clamors for comparisons to Gunter Grass's The Tin Drum; her protagonist Trudi Montag--like the unforgettable Oskar Mazerath--is a dwarf living in Germany during the two World Wars. " />
<Product id="7" name="Empire of the Sun by J. G. Ballard" price="12" quantity="3" description="Ballard's enduring novel of war and deprivation, internment camps and death marches, and starvation and survival is an honest coming-of-age tale set in a world thrown utterly out of joint." />
</Products>
Столбцы идентификатор, наименование, цена, количество, описание должны быть связаны динамически. Любая помощь с примером будет принята с благодарностью.
Моей Запрограммированной таблица стили
<fo:table border-bottom-width="5pt" width="1500pt" border-bottom-color="rgb(0,51,102)" border-collapse="collapse" background-color="rgb(255,255,255)">
<fo:table-column column-width="proportional-column-width(6.77)" column-number="1"/>
<fo:table-column column-width="proportional-column-width(5.09)" column-number="2"/>
<fo:table-column column-width="proportional-column-width(5.63)" column-number="3"/>
<fo:table-column column-width="proportional-column-width(5.94)" column-number="4"/>
<fo:table-column column-width="proportional-column-width(5.79)" column-number="5"/>
<fo:table-header>
<fo:table-row height="20.81pt" display-align="center" overflow="hidden">
<fo:table-cell text-align="center" border-left-color="rgb(0, 0, 0)" border-left-style="solid" border-left-width="1pt" border-right-color="rgb(0, 0, 0)" border-right-style="solid" border-right-width="1pt" border-top-color="rgb(0, 0, 0)" border-top-style="solid" border-top-width="1pt" border-bottom-color="rgb(0, 0, 0)" border-bottom-style="solid" border-bottom-width="1pt" padding-left="2pt" padding-right="2pt" padding-top="2pt" padding-bottom="2pt">
<fo:block color="rgb(0,0,0)" text-align="center" font-weight="normal" font-family="{$columnFontType}" font-size="{$columnFontSize}">Transaction</fo:block>
<fo:block color="rgb(0,0,0)" text-align="center" font-weight="normal" font-family="{$columnFontType}" font-size="{$columnFontSize}">Date</fo:block>
</fo:table-cell>
<fo:table-cell text-align="center" border-left-color="rgb(0, 0, 0)" border-left-style="solid" border-left-width="1pt" border-right-color="rgb(0, 0, 0)" border-right-style="solid" border-right-width="1pt" border-top-color="rgb(0, 0, 0)" border-top-style="solid" border-top-width="1pt" border-bottom-color="rgb(0, 0, 0)" border-bottom-style="solid" border-bottom-width="1pt" padding-left="2pt" padding-right="2pt" padding-top="2pt" padding-bottom="2pt">
<fo:block color="rgb(0,0,0)" text-align="center" font-weight="normal" font-family="{$columnFontType}" font-size="{$columnFontSize}">Cust ID</fo:block>
</fo:table-cell>
<fo:table-cell text-align="center" border-left-color="rgb(0, 0, 0)" border-left-style="solid" border-left-width="1pt" border-right-color="rgb(0, 0, 0)" border-right-style="solid" border-right-width="1pt" border-top-color="rgb(0, 0, 0)" border-top-style="solid" border-top-width="1pt" border-bottom-color="rgb(0, 0, 0)" border-bottom-style="solid" border-bottom-width="1pt" padding-left="2pt" padding-right="2pt" padding-top="2pt" padding-bottom="2pt">
<fo:block color="rgb(0,0,0)" text-align="center" font-weight="normal" font-family="{$columnFontType}" font-size="{$columnFontSize}">Cust No</fo:block>
</fo:table-cell>
<fo:table-cell text-align="center" border-left-color="rgb(0, 0, 0)" border-left-style="solid" border-left-width="1pt" border-right-color="rgb(0, 0, 0)" border-right-style="solid" border-right-width="1pt" border-top-color="rgb(0, 0, 0)" border-top-style="solid" border-top-width="1pt" border-bottom-color="rgb(0, 0, 0)" border-bottom-style="solid" border-bottom-width="1pt" padding-left="2pt" padding-right="2pt" padding-top="2pt" padding-bottom="2pt">
<fo:block color="rgb(0,0,0)" text-align="center" font-weight="normal" font-family="{$columnFontType}" font-size="{$columnFontSize}">Client Name</fo:block>
</fo:table-cell>
<fo:table-cell text-align="center" border-left-color="rgb(0, 0, 0)" border-left-style="solid" border-left-width="1pt" border-right-color="rgb(0, 0, 0)" border-right-style="solid" border-right-width="1pt" border-top-color="rgb(0, 0, 0)" border-top-style="solid" border-top-width="1pt" border-bottom-color="rgb(0, 0, 0)" border-bottom-style="solid" border-bottom-width="1pt" padding-left="2pt" padding-right="2pt" padding-top="2pt" padding-bottom="2pt">
<fo:block color="rgb(0,0,0)" text-align="center" font-weight="normal" font-family="{$columnFontType}" font-size="{$columnFontSize}">Long ID</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row display-align="before">
<fo:table-cell text-align="center" border-top-color="rgb(0, 0, 0)" border-top-style="solid" border-left-width="1pt" border-right-width="1pt" border-top-width="1pt" border-bottom-width="1pt" padding-left="2pt" padding-right="2pt" padding-top="2pt" padding-bottom="2pt">
<fo:block>
1
</fo:block>
</fo:table-cell>
<fo:table-cell text-align="left" border-top-color="rgb(0, 0, 0)" border-top-style="solid" border-left-width="1pt" border-right-width="1pt" border-top-width="1pt" border-bottom-width="1pt" padding-left="2pt" padding-right="2pt" padding-top="2pt" padding-bottom="2pt">
<fo:block>
Rendezvous with Rama by Arthur C. Clarke
</fo:block>
</fo:table-cell>
<fo:table-cell text-align="right" border-top-color="rgb(0, 0, 0)" border-right-color="rgb(0, 0, 0)" border-top-style="solid" border="1pt " padding="2pt">
<fo:block>
3
</fo:block>
</fo:table-cell>
<fo:table-cell text-align="right" border-top-style="solid" border="1pt rgb(0, 0, 0)" padding="2pt">
<fo:block>
$15.00
</fo:block>
</fo:table-cell>
<fo:table-cell text-align="left" border-top-color="rgb(0, 0, 0)" border-left-color="rgb(0, 0, 0)" border-top-style="solid" border="1pt " padding="2pt">
<fo:block>
An all-time science fiction classic, Rendezvous with Rama is also one of Clarke's best novels--it won the Campbell, Hugo, Jupiter, and Nebula Awards.
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
Спасибо, Паван
Что вы имеете в виду под «генерировании сотрудничества lumns'? Вы форматируете свой источник в виде таблицы? Каковы различия между типами отчетов? Мы не можем сказать вам, можете ли вы что-то сделать, когда мы не знаем, что вы хотите сделать. –
Создание столбцов, я не хочу жестко указывать имена столбцов в таблице в таблице стилей XSL FO, скорее я хотел бы привязать столбцы, возвращаемые с SQL Server. Типы средств отчетов. Имена столбцов могут отличаться от отчета к отчету. Итак, мне нужно динамически печатать имена столбцов из XML. Я застрял с этим в течение последних 2 недель .. Пожалуйста, дайте мне знать, если вам нужны какие-либо входы .. –
Ниже приведена моя таблица стилей с фиксированными именами столбцов. Но, как я уже сказал, имена столбцов должны быть заполнены из XML динамически вместо того, чтобы их жестко кодировать .. Пожалуйста, обратитесь к таблице стилей xsl fo с 5 столбцами и 1 строкой, жестко закодированной в вышеупомянутом исходном сообщении. Теперь мне нужно создать таблицу с динамическим числом столбцов, значит, для 1 отчета я могу получить 10 столбцов, для другого отчета я могу получить 20 таких столбцов. Можете ли вы поделиться образцом xsl fo для достижения этого. –