Index mapping in XSLT-2.0 - xslt

I have created index page using XSLT code. The contents name are shown to index page correctly but i want to map contents according to page number for specific title.
I am getting title with their description So I have named that block as id="TOC" and given as ref-id=”TOC” but the page number is not reflecting in my title.
Title:- Title names present in Index page.
Summary:- Title content associated with page.
The below is my XSLT-2.0 sample code:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="content_name">
<fo:block space-after="7pt" space-after.conditionality="retain" line-height="1.147" font-family="Calibri" font-size="15pt" font-weight="bold" language="FR">
<fo:inline>
<fo:leader leader-length="0pt" />
<xsl:value-of select="title"/>
<fo:page-number-citation ref-id="TOC"/>
</fo:inline>
</fo:block>
</xsl:template>
<xsl:template match="pro_list">
<fo:block space-after="15pt" space-after.conditionality="retain" line-height="1.147" font-family="Calibri" font-size="15pt" font-weight="bold" text-decoration="underline" language="FR">
<fo:inline>
<fo:leader leader-length="0pt" />
<xsl:value-of select="title" id="TOC"/>
</fo:inline>
</fo:block>
<fo:block space-after="8pt" space-after.conditionality="retain" line-height="1.147" font-family="Calibri" font-size="15pt" language="FR">
<fo:inline>
<fo:leader leader-length="0pt"/>
<xsl:value-of select="summary" disable-output-escaping="yes" />
</fo:inline>
</fo:block>
</xsl:template>
</xsl:stylesheet>
This is the output:
Contents
Title1 page no.
Title2 page no.
Title3 page no.
Suppose title1 content is associated with page2 & similar for title2-3 & title3-4, then output looks like as follows
Contents
Title1 2
Tilte2 3
Title3 4
Is there any syntax or predefined function available to do index mapping?

Related

Need to change the footer value as per the parent and child topic

Now I'm working on creating the footer value for pdf using DITA-OT. I'm having multiple child topics with outputclass attribute
Dita Input:
<topic outputclass="h1">
<title outputclass="CD_Map_Heading-hide">HIDE TOPIC</title>
<topic outputclass="h2">
<title>DEFINITION</title>
</topic>
<topic outputclass="h3">
<title>REVOLUTION</title>
</topic>
</topic>
Static Content XSL:
<xsl:template name="insertBodyOddFooter">
<fo:static-content flow-name="odd-body-footer">
<fo:block> </fo:block>
<fo:block xsl:use-attribute-sets="__body__odd__footer">
<xsl:choose>
<xsl:when test="*[contains(#outputclass, 'h2')]">
<xsl:text>DEF</xsl:text>
</xsl:when>
<xsl:when test="*[contains(#outputclass, 'h3')]">
<xsl:text>REV</xsl:text>
</xsl:when>
<xsl:otherwise>
<fo:block-container position="absolute">
<fo:block padding-top="20pt" text-align="center">
<fo:page-number/>
</fo:block>
</fo:block-container>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:static-content>
</xsl:template>
I'm getting only DEF as footnote for this all the topic. But I need every topic pages should their own footer value, that means for the h3 output class topic should get REF as footer. but I'm getting DEF. So please help me to get the footer value for that corresponding topic pages. Thanks in advance!!!

How to write text diagonally on a image using XSL FO

I have a text written on a certificate document which is an image, but I am trying to write the text diagonally on the image. I am unable to change it even after changing the reference orientation of the container within which the text is present.
<xsl:template match="graphicBack">
<fo:block absolute-position="absolute">
<fo:block-container position="absolute">
<fo:external-graphic xmlns:fo="http://www.w3.org/1999/XSL/Format" scaling="uniform" content-width="210mm" content-height="296.99mm">
<xsl:attribute name="src" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:value-of select="var" />
</xsl:attribute>
</fo:external-graphic>
</fo:block-container>
<fo:block-container absolute-position="absolute" left="20mm" top="200mm">
<fo:block color="#CC6133" font-family="Courier" font-style="normal" display-align="center" font-size="300px">
COPY
</fo:block>
</fo:block-container>
</fo:block>
</xsl:template>
If you are using AH Formatter, then you can use axf:transform and axf:transform-origin (see https://www.antennahouse.com/product/ahf66/ahf-ext.html#transformation) to rotate the block to an arbitrary angle.
See the 'Block transformation' example in the "Comprehensive XSL-FO Tutorials and Samples Collection" at https://www.antennahouse.com/comprehensive-xsl-fo-tutorials-and-samples-collection/.

How to interrupt a page-sequence to insert another page-sequence

Via xsl:for-each-group I group my data with a property pagemaster. For this group I assign the page-sequence in the attribute pagemaster. Then the template is called for each element in this group.
Now to my question: is it somehow possible that I leave the current page-sequence in the for-each loop to insert another page-sequence and then continue with the previous one?
As an example, let's assume that all elements in the group should be rendered on blue pages, but if an element has a certain attribute, a red page will be inserted at this place.
My code section looks like this:
.
<!-- master-set defined here -->
.
</fo:layout-master-set>
<xsl:for-each-group select=".//reportelements/*[pagemaster != '']" group-adjacent="pagemaster">
<fo:page-sequence master-reference="{current-grouping-key()}">
<!-- Static-Content per pagemaster Group -->
<xsl:call-template name="STATIC-CONTENT">
<xsl:with-param name="pageMaster" select="current-grouping-key()" />
</xsl:call-template>
<fo:flow flow-name="xsl-region-body">
<xsl:for-each select="current-group()">
<!-- Here, for example, i would like to check if the current element (.)
is from type "section" and the attribute "hastoc" is true.
If yes the current page sequence should be interrupted and a new page-sequence
should be inserted on which the table of contents is rendered. -->
<xsl:apply-templates select="."/>
</xsl:for-each>
</fo:flow>
</fo:page-sequence>
</xsl:for-each-group>
</fo:root>
</xsl:template>
<xsl:template name="STATIC-CONTENT">
<xsl:param name="pageMaster" />
<xsl:if test="$pageMaster = 'TITLEPAGE'">
<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="right">
<fo:external-graphic src="url(file:C\Logo.pdf)" content-width="6cm" />
</fo:block>
</fo:static-content>
</xsl:if>
</xsl:template>
Xml Code looks like
<?xml version="1.0" encoding="utf-8"?>
<root>
<report>
<layout>report.xsl</layout>
<namecontent>Report</namecontent>
<reportelements>
<section>
<layout>section_normal</layout>
<pagemaster></pagemaster>
<titlecontent>Vorspann</titlecontent>
<hastoc>false</hastoc>
<reportelements>
<picture>
<layout>picture_title</layout>
<pagemaster>TITLEPAGE</pagemaster>
<titlecontent>Titelpicture</titlecontent>
<reportelements />
<path>files\Titelpicture213124.Jpeg</path>
</picture>
<section>
<layout>section_leader.xsl</layout>
<pagemaster>DIN-A4-HEADER-ODD-EVEN</pagemaster>
<titlecontent>Profil</titlecontent>
<hastoc>true</hastoc>
<reportelements>
<paragraph>
<layout>paragraph_leader.xsl</layout>
<pagemaster>DIN-A4-HEADER-ODD-EVEN</pagemaster>
<titlecontent>p1</titlecontent>
<reportelements />
<textcontent>paragraph_leader 1 text</textcontent>
</paragraph>
<paragraph>
<layout>paragraph_leader.xsl</layout>
<pagemaster>DIN-A4-HEADER-ODD-EVEN</pagemaster>
<titlecontent>p2</titlecontent>
<reportelements />
<textcontent>paragraph_leader 2 text</textcontent>
</paragraph>
.
.
.
.
I am using the Apache Formatting Object Processor 2.3

How to use columnspan value from an html/xml to generate pdf using xsl fo.(precisely putting the value into xslt stylesheet)

hi i would like to use the value of column span(i.e 8) from an html into xsl fo stylesheet where the table cell is defined
below is the html code
<tr align="center" style="font-weight: bold">
<td colspan="8">this is the value</td>
</tr>
below is the xslt stylesheet snippet
<fo:table-body>
<xsl:for-each select="table/tr/td/table/tr">
<fo:table-row>
<xsl:for-each select="./*">
<!--I want the variable to contain number datatype and the value 8-->
<xsl:variable name="colspan" data-type="number">
<xsl:value-of select="*/#colspan"/>
</xsl:variable>
<xsl:text/>
<xsl:value-of select="$colspan" />
<fo:table-cell border-width="0.5pt" border-style="solid" padding="0.5pt" text-align="center" number-columns-spanned="{$colspan}">
<!-- I want colspan value to be used for spanning if it exist-->
<fo:block wrap-option="wrap" font-size="6pt">
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
<!-- </xsl:if> -->
</xsl:for-each>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
In short, if a cell spans two columns in HTML, then I want the cell to be spanned in the PDF to be generated using XSL-FO.
Use number-columns-spanned. It is an attribute of fo:table-cell.
For example, test whether the attribute "colspan" is present in the input HTML:
<xsl:if test="td/#colspan">
<fo:table-cell>
<xsl:attribute name="number-columns-spanned">
<xsl:value-of select="td/#colspan"/>
</xsl:attribute>
<!-- Further content-->
</fo:table-cell>
</xsl:if>
See this resource: http://www.schemacentral.com/sc/fo11/e-fo_table-cell.html if you are looking for other attributes of fo:table-cell.
If this approach does not produce the wanted results, then the actual problem lies somewhere else. If I had to make a wild guess I'd say that this selection in your code:
<xsl:value-of select="*/#colspan"/>
Does not retrieve the value of #colspan. In plain English, you are within a for-each, looping through all <td> elements. Therefore, the above instruction means: "for any child element of a <td>, select the value of its colspan attribute". Better:
<xsl:value-of select="#colspan"/>
Note that there might be other issues with your XSLT code.

How to insert line breaks in a PDF generated with XSL-FO

I am generating a PDF using XSL-FO and XML. In a textbox, the user can enter data like "1", then he presses ENTER, then "2", ENTER, "3", etc. But in the XML and hence in the PDF, the output is "1234567". How can I preserve the line breaks? I already tried white-space-collapse, linefeed-treatment and white-space-treatment but that didn't help.
My XSL looks like:
<xsl:template match="AddCmt">
<fo:block keep-together="always"> Additional Comments
<fo:block-container border-style="solid" height="20mm" width="170mm" space-after="5mm">
<fo:block>
<xsl:attribute name="id">
<xsl:value-of select="../CMT_ID"/>
</xsl:attribute>
<xsl:value-of select="../ANS_CMT"/>
</fo:block>
</fo:block-container>
</fo:block>
</xsl:template>
When I enter the following:
hello
medhavi
saraswat
This is the XML I get:
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type='text/xsl' href='e:\tmm-09.3\src\pmod\WorkOrder.xsl'?>
<Root>
<WorkOrders>
<Detail>Id="ANS_436‌​_FLD_1" Label="qq">qq</Detail>
<Ans Checked="0" Id="ANS_436_FLD_2" Label="ww">ww</Ans>
<ID>ANS_436_FLD</ID>
<ANS_FLD>0|0</ANS_FLD>
<CMT_ID>ANS_436_CMT‌​</CMT_ID>
<ANS_CMT>hello medhavi saraswat</ANS_CMT>
<Warning>
<Line>warning 11</Line>
<Line>22</Line>
<Line>33</Line>
<Line>44</Line>
<Line></Line>
<Line>66</Lin‌​e>
<Line>77</Line>
<Line></Line>
</Warning>
It should work with the following xml (you should add all the attributes):
<xsl:template match="AddCmt">
<fo:block keep-together="always"> Additional Comments
<fo:block-container border-style="solid" height="20mm" width="170mm" space-after="5mm">
<fo:block wrap-option="wrap" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve">
<xsl:attribute name="id">
<xsl:value-of select="../CMT_ID"/>
</xsl:attribute>
<xsl:value-of select="../ANS_CMT"/>
</fo:block>
</fo:block-container>
</fo:block>
</xsl:template>
But as I mentioned in the comments, if your XML already has no linebreaks, there's no way your PDF will. You mentioned in your question there are no linebreaks in your XML, hence no linebreaks in the PDF.
Try checking out why there are no linebreaks in the XML. If you can provide any more information (a piece of your XML, the code you use to construct the XML, ...), please edit your answer and add the information.