Page numbers not getting displayed for the Table of contents in the downloaded document - document

I need to show the page numbers for the Table of Contents in the word document(rtf). Below is the piece of snippet code which is not working. The left hand title are displayed properly and when we click on that it takes to the appropriate page but the page numbers are not getting displayed. Just for debugging purpose I tried generate-id() but it doesnt do anything.Any inputs on making this work would be appreciated.Thanks
<xsl:template match="html:td[contains(#class,'blabla')]">
<xsl:variable name="refId" select="substring-after(parent::html:tr/#id,'toc_')" />
<fo:table-cell border="none">
<fo:block text-align-last="justify">
<fo:basic-link internal-destination="{$refId}">
<xsl:apply-templates />
</fo:basic-link>
<xsl:text> </xsl:text>
<fo:leader leader-pattern="dots" leader-pattern-width="3pt" leader-length="20cm" />
<fo:page-number-citation ref-id="{$refId}"/>
</fo:block>
</fo:table-cell>
</xsl:template>

Related

How to keep my topics printing consecutively, without an empty page after each topic

DITA 3.6
Oxygen XML Editor 23.1
The "DITA for Print" book nor any other source, so far, has helped me produce a pdf where the topics are consecutive rather than having a blank page after them. To each topicref in the ditamap, I added outputclass="page-break-avoid". To each topic element in each file, I added outputclass="page-break-avoid".
Should I add something in an xsl file? Can you point me to the answer?
The blank page is generated from the definition fo:page-sequence/#force-page-number property.
To change not to generate blank-page, you can override org.dita.pdf2/cfg/fo/attrs/commons-attr.xsl.
<xsl:attribute-set name="__force__page__count">
<xsl:attribute name="force-page-count">
<xsl:choose>
<xsl:when test="/*[contains(#class, ' bookmap/bookmap ')]">
<xsl:value-of select="'even'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'auto'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:attribute-set>
Change the value even to auto will satisfy your needs.
Steps to customize
I'm not familiar with PDF2 plug-in. So this may not the standard way. But I could customize it by following steps.
Make customization XSL file
[DITA-OT]/plugins/org.dita.pdf2/Customization/fo/attrs/commons-attr.xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:rx="http://www.renderx.com/XSL/Extensions"
version="2.0">
<xsl:attribute-set name="__force__page__count">
<xsl:attribute name="force-page-count">
<xsl:choose>
<xsl:when test="/*[contains(#class, ' bookmap/bookmap ')]">
<xsl:value-of select="'auto'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'auto'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:attribute-set>
</xsl:stylesheet>
Include it into [DITA-OT]/plugins/org.dita.pdf2/Customization/fo/attrs/custom.xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<xsl:include href="commons-attr.xsl"/>
</xsl:stylesheet>
Customize [DITA-OT]/plugins/org.dita.pdf2/Customization/catalog.xml
<?xml version="1.0" encoding="utf-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<!-- Custom attributes entry -->
<uri name="cfg:fo/attrs/custom.xsl" uri="fo/attrs/custom.xsl"/>
</catalog>
Specify customization.dir property with [DITA-OT]\plugins\org.dita.pdf2\Customization in Oxygen transformation scenario.
Apply transformation scenario from Oxygen.
I've got the following temp/topic.fo. The fo:page-sequence/#force-page-count became auto and in the result PDF, the redundant blank pages are removed.

Sharepoint - CQWP and Announcements Body

I', trying to display the Body property of an Announcements List in my CQWP, but it is always blank.
In CommonViewFields I've tried to set Body type to Text, RichHTML, Note... all with no result. Also, as suggested elsewhere. I've tried disable-output-escaping="yes" in the xsl. Nothing changed.
Printing out the passed key / values reveals that Body is empty. It should be not.
<xsl:for-each select="#*">
Key:<xsl:value-of select="name()" />
Value:<xsl:value-of select="."/>
</xsl:for-each>
Any help?
Generally when you need to output HTML that exists in your data source (or any kind of "result tree"), try invoking the xsl:copy-of element.
To use your example, it would look like:
<xsl:for-each select="#*">
Key:<xsl:value-of select="name()" />
Value:<xsl:copy-of select="." />
<xsl:for-each select="#*">

Document Library Name in xsl

I need to grab the document library name in a webpartpages:dataformwebpart
I see the document library names in several places. Which one should I grab?
HeaderTitle="DocLib_23"
DetailLink="/sites/SiteCollection/Project_ABC/SubSite1/DocLib_23/Forms/AllItems.aspx"
Title="DocLib_23"
How do I create a param in xsl to grab the doc lib name from any one of the above?
i.e. Title or HeaderTitle
Some good Links.
http://msdn.microsoft.com/en-us/library/dd583143(office.11).aspx
Add these two line
<xsl:variable name="DocLibName" select="substring-before(substring-after($PageUrl, '/Forms/'), '/')" />
<xsl:param name="PageUrl"/>
set VIEWFLAG=1 (it should be in the properties windows)
Find this line and modify if you want Filter the webpart list
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
Change it to following
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[(#CustomerNo=$DocLibName)]"/>
You can use this to display
<xsl:value-of select="$DocLibName"> <br/>
<xsl:value-of select="$PageUrl"/><br/>

Truncating HTML attribute value in SharePoint DataFormWebPart

I'm using DataFormWebPart to display all announcements in the SharePoint site collections. It uses SPDataSouce with DataSourceMode set to CrossList and it works OK. The text of the announcement comes from the XML attribute:
<xsl:value-of disable-output-escaping="yes" select="#Body" />
Now I need to limit this text to, say, 250 characters. Of course, I cannot truncate it as a simple string as it could produce invalid HTML. I needed something like ddwrt:Limit but HTML aware.
Any ideas, please?
I think you want to display 250 characters in the page, please use this script
<xsl:if test="string-length(#Body) <= 250">
<xsl:value-of select="#Body"/>
</xsl:if>
<xsl:if test="string-length(#Body) > 250">
<xsl:value-of select="substring(#Body,0,250)"/>....
</xsl:if>
I found a very simple solution for this,try this instead!
<xsl:value-of select="substring(#Body, 1, 250 + string-length(substring-before(substring(#Body, 250),' ')))" />

xslt hyperlink, separate the url and descption

I have a list in sharepoint with a hyperlink column.
I'm putting this list into xml and applying xslt to it.
the xml is producing output in the form of:
<link>http://www.foo.com, http://www.foo.com</link>
how can i display this link using xslt?
thanks
How about:
<xsl:template match="link">
<a href="{substring-before(.,',')}">
<xsl:value-of select="substring-after(.,',')"/>
</a>
</xsl:template>
For XSLT 2.0
<xsl:template match="link">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="substring-before(.,',')"/>
</xsl:attribute>
<xsl:value-of select="substring-after(.,',')"/>
</xsl:element>
</xsl:template>
Although it makes it slightly less readable, the extended syntax is considered good practice when stylesheets become large. Literal Result Elements are not as easy to manipulate via XPath as xsl:element/xsl:attribute

Resources