How to override discovery search results - xslt-1.0

One of the requirements of the repository I'm working on is to have an Advanced Search option from the user interface. Since as of DSpace 4, the Discovery faceted/filtered search & browse is enabled by default as mentioned here, I just put a link in the navigation to point that Advanced Search link to http://myrepository.org/discover. Now my goal is to suppress the search results whenever the user clicked the Advanced Search link.
How can I override the search results such that if there's no query string (eg if the user goes directly to /discover page and no facets were selected), it will only show like in the picture below without the search results and the Now showing items ... and the pagination divs.
I am using DSpace version 5.3 Mirage 2 Theme
This is what I have tried:
<xsl:template match="dri:list[#id='aspect.discovery.SimpleSearch.list.search-results-repository']">
<xsl:variable name="query-string" select="/dri:document/dri:meta/dri:pageMeta/dri:metadata[#element='request'][#qualifier='queryString']"/>
<xsl:if test="$query-string!=''">
<xsl:apply-templates />
</xsl:if>
</xsl:template>
The code above always suppressed the search results whether I have query strings or not.
EDIT
I have a problem with the template match that I used in my answer. The styling of the sort options was removed.
Can someone help me improve my code such that it will not remove the styling of the sort options? The default sort options should look like this:
I wonder why using that template match removed the styling of the sort options. If I use <xsl:apply-templates/>, or <xsl:apply-templates select="."/> instead of <xsl:copy-of select="."/>, it is not returning the result I want to achieve.
Any advice would be greatly appreciated. Thanks in advance.

After many tries of template match, I finally achieved what I want to display. This is the template match that I am using to achieve my goal.
<xsl:template match="dri:div[#id='aspect.discovery.SimpleSearch.div.search-results']">
<xsl:if test="contains(#pageURLMask,'query') or contains(#pageURLMask,'filter')">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>
I don't know and not sure if this is fool proof. I've tested this when going directly to /discover page, no search results displayed and I also tried clicking the search button without entering any values in the search form.
There is a slight problem with this answer. Please see my updated post above.
This is the code that resolved my problems regarding the styling of the sort options.
<xsl:template match="dri:div[#id='aspect.discovery.SimpleSearch.div.search-results']">
<xsl:choose>
<xsl:when test="contains(#pageURLMask,'query') or contains(#pageURLMask,'filter')">
<xsl:apply-templates select="dri:div[#id='aspect.discovery.SimpleSearch.div.masked-page-control']/node()"/>
<xsl:copy>
<xsl:apply-templates select="node()|#*"/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="no-search-results"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="no-search-results" match="dri:div[#id='aspect.discovery.SimpleSearch.div.masked-page-control']"/>

Related

XML-FO : how to re-use graphics?

I'm adding an SVG logo to every page of a document and notice that the logo gets "inlined" on every page, rather than appearing only once in the PDF file and then referenced when used on each page.
This means that the PDF file becomes much bigger than it needs to be.
Here's what I do:
<?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"
xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="A4-portrait"
page-height="29.7cm" page-width="21.0cm"
margin-top="5mm" margin-bottom="5mm"
margin-left="1.0in" margin-right="1.0in">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="10mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4-portrait"
initial-page-number="1"
force-page-count="no-force">
<!-- header -->
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end" >
<fo:external-graphic
src="../mylogo.svg"/>
</fo:block>
</fo:static-content>
<!-- content -->
<fo:flow flow-name="xsl-region-body">
<!-- a simple 2 page document -->
<fo:block page-break-before="always"> X </fo:block>
<fo:block page-break-before="always"> X </fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
As can be seen there's only a single character on each page.
If I from the above generate a 2 page PDF document it will be 13.01 KB and if I generate a 48 page document it will be 206.56 KB. I would have expected the two PDF document to be almost the same size.
How can I achieve that the logo is re-used and referenced instead of inlined ?
Not using vector graphics is not an option for me.
Apache FOP 2.1, Java 8.
Update
I've found this which is somewhat similar. As far as I can tell the problem in that question is that the contents of the header seems to be inlined on every page (thus ballooning the PDF size), somewhat similar to my problem.

collapse bookmarks by default in dita 1.8.4

i have a working customization, but what i cannot figure out is, how to set the bookmarks in my pdf document to 'collapsed' by default.
i tried to paste
<property name="args.bookmark.style" value="COLLAPSED" />
into my build file, as well as into build.xml, build_template.xml and build.properties in the plugin and customization folder.
Nothing seems to have an effect on this.
Am i missing a step?
(I have been wondering if there was something in my customization which would automatically leave the bookmarks expanded, but I do not know where to look for this... I am pretty sure this is not the problem)
Thanks in advance!
If you look in this XSLT stylesheet:
DITA-OT/plugins/org.dita.pdf2/cfg/fo/attrs/basic-settings.xsl
there is a parameter called "bookmarkStyle" which gets its value from the ANT build files.
<xsl:param name="bookmarkStyle">
<xsl:choose>
<xsl:when test="$antArgsBookmarkStyle!=''"><xsl:value-of select="$antArgsBookmarkStyle"/></xsl:when>
<xsl:otherwise>COLLAPSED</xsl:otherwise>
</xsl:choose>
</xsl:param>
As you can see, the default value for that parameter is COLLAPSED so you should do nothing to obtain this default behavior, I tested and the bookmarks area in a generated PDF only shows the top-level topic references.
You can also add an xsl:message in that parameter and see the value it receives from the build files.
Maybe you have another expectation of what args.bookmark.style was intended to be used for.
I finally found out what was the problem.
There was no need to change any ANT properties.
All it needs is to add the following attribute:
<xsl:attribute name="starting-state">hide</xsl:attribute>
in the template:
<xsl:template match="*[contains(#class, ' topic/topic ')]" mode="bookmark">

How do I convert a relative docbook link to a URL?

I am using docbook as a source for HTML and PDF output. In the docbook source, I have a series of links which are relative (pointing to javadoc files), which is fine for the HTML output because the javadoc files are deployed alongside the original document. For the PDF output, I would like to convert these to absolute links by way of prepending a URL prefix. Is this possible? I have added a 'relative' role to these links and have tried adding a fo customization layer:
<xsl:template match="d:link[#role='relative']">
<xsl:copy>
<xsl:attribute name="xlink:href">
<xsl:value-of select="concat('http://prefix/', #xlink:href)"/>
</xsl:attribute>
</xsl:copy>
<xsl:apply-templates select="d:link"/>
</xsl:template>
This seems to half-work in that it does prepend the prefix to the link href, but then it does not convert the link element into FO.
Any ideas, or other ways this could be done?

Using XSLT to make XAML file

I'm trying to create a simple XAMLfile with a Page that contains a Canvas that contains a Rectangle.
I have a template draw-canvas that makes the canvas. In this canvas I want to put a Rectangle, for which I have a template draw-rectangle.
My main currently looks like this:
<xsl:template match="/">
<xsl:element name="Page">
<xsl:call-template name="draw-canvas">
<xsl:with-param name="start-color">red</xsl:with-param>
<xsl:with-param name="end-color">ivory</xsl:with-param>
</xsl:call-template>
</xsl:element>
</xsl:template>
To get the Rectangle in the canvas I call the draw-rectangle method in the draw-canvas template. Is this the only way to do this? I feel like this doesn't really allow for flexibility.

SharePoint Content Query Web Part question

I'm using CQW to display announcement list. Only problem I'm facing to provide "Add new announcement" button like the one having in Announcement list.Here is my CQW ,
I've tried adding custom "Add new Announcement" link from SharePoint designer. But this solution looks ugly. Can we provide exact button and the interface which default "Add new announcement" link provides ? Please not it's on web part page.
Here is my SPD if someone want to see,
Editing the XSLT can be your solution.
If the repeating is the only thing that stops you from modifying the XSLT, we have to solve that.
You can stop the repeating by using a check on the current position. Only add the link when the position is 1.
Define the current position and use it:
<xsl:param name="CurPos" />
<xsl:if test="$CurPos = 1">
<![CDATA[ Here your link can be placed ]]>
</xsl:if>