I'm working with DSpace 4.2 xmlui Mirage theme. I want to hide the Communities and Collections from the search results page.
By inspecting the DRI document of the page I found that the Communities and Collections results are added as:
<list id="aspect.discovery.SimpleSearch.list.comm-coll-result-list" n="comm-coll-result-list">
So I tried over-riding the template in the xsl file of the theme.
<xsl:template match="dri:list[#id='aspect.discovery.SimpleSearch.list.comm-coll-result-list']">
<!-- Over ride / remove the recent submissions box-->
</xsl:template>
But no change is reflected in the page. Am I doing something wrong here? I was able to hide the default search box in a similar manner by over-riding the template generating it's corresponding div.I noticed that the list item I want to hide is contained within another div. Is is not possible to over-ride a DRI element unless its tag is div?
You can also add a default filter query in your [dspace]/config/spring/api/discovery.xml.
Default filter queries are applied on all search operations & sidebarfacet clicks. One useful application of default filter queries is ensuring that all returned results are items. As a result, subcommunities and collections that are returned as results of the search operation, are filtered out.
Relevant lines here, note that this is disabled by default. Uncomment to make this work.
<property name="defaultFilterQueries">
<list>
<value>search.resourcetype:2</value>
</list>
Hope this help.
UPDATE
Copy the:
<property name="defaultFilterQueries">
<list>
<value>search.resourcetype:2</value>
</list>
<property>
in the <bean id="homepageConfiguration" class="org.dspace.discovery.configuration.DiscoveryConfiguration" scope="prototype"> because it overrides the defaultConfiguration as stated in this comment.
The collection and community list results are displayed by the following XSLT: https://github.com/DSpace/DSpace/blob/master/dspace-xmlui/src/main/webapp/themes/dri2xhtml/structural.xsl#L3616-L3635
To change the display via XSLT, try constructing your own template code.
<xsl:template name="collectionSummaryList">
<xsl:param name="handle"/>
<xsl:param name="externalMetadataUrl"/>
<xsl:variable name="metsDoc" select="document($externalMetadataUrl)"/>
...
</xsl:template>
If you completely suppress these results from your display, it will likely make your pagination counts unreliable. It might make more sense to suppress the community/collection results from the SOLR search results.
Related
This may be somewhat naive but I am quite struck on the issue
There is a specific <result> element in DataPower and when calling through xslt we have somewhat following format(which I discovered in some forums)--
<results mode="require-all" multiple-outputs="true" transactional="true" retry-interval="100" asynchronous="false">
<url input="var://the_request_SOAP_Format"asynchronous="true">https://XXXXXXX</url>
now in this (url input) is the request which needs to be send and (https://XXXXXXX) is the specified backend where it needs to be sent
Now I have some authentication headers(httpHeaders) also which I need to send without which I will get Authorization error
<xsl:variable name="httpHeaders">
<header name="Content-Type">application/json</header>
<header name="Authorization">
<xsl:value-of select="concat('Bearer ',$some_sessionID)"/>
</header>
</xsl:variable>
Is this possible to add these 'httpHeaders' in the result mode element/Tab property
Thanks
I am not exactly sure what you are trying to achieve but adding http headers for the response (backside) you do with:
<dp:set-http-response-header name="'HeaderName'" value="$httpHeaders"/>
or
<dp:set-http-request-header name="'HeaderName'" value="$httpHeaders"/>
The <results> is the collection of data that the Processing Policy will output as Payload for the Request/Response and won't contain headers. You shouldn't try to alter the <results> object!
The "results-doc" method of calling backends is quite powerful, but I'm not sure from your question if you fully understand it. The url/#input attribute needs to be a DataPower context:
<url input="var://context/mycontext" ...
To associate headers with that context, you should do something like this for each header you need:
<dp:set-variable
name="'var://context/mycontext/_extension/header/Content-Type'"
value="'application/json'"/>
(This would be done in your XSLT code, separate from creating the "results" document, but before you use a Results Action to execute.)
I have to trasform the raw response of any OData feed (ATOM) in the form of a tree with expandable/collapsable nodes. For this purpose I am converting the raw response into HTML using XSLT transformation.
The problem is that response from some services have the feed element with namespace declarations as attributes. (eg: feed xmlns:d= ..., xmlns:m= ...).In my final output these namespace declarations are not displayed.
The XSLT processor ignores them while processing the attributes.(I am using the XPath expression "#*".) Is there a way to extract them using XSLT and display the namespace declaration content as-is in the trasformed output ?
Note that I get to know about these namespace declaration attributes at runtime in the OData response. I have no information before the query executes.
UPDATE:
Input : (RAW XML Entry)
<?xml version="1.0" encoding="utf-8"?><entry xml:base="http://services.odata.org/Northwind/Northwind.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><id>http://services.odata.org/Northwind/Northwind.svc/Regions(1)</id><category term="NorthwindModel.Region" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" title="Region" href="Regions(1)" /><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Territories" type="application/atom+xml;type=feed" title="Territories" href="Regions(1)/Territories" /><title /><updated>2014-03-17T10:24:14Z</updated><author><name /></author><content type="application/xml"><m:properties><d:RegionID m:type="Edm.Int32">1</d:RegionID><d:RegionDescription xml:space="preserve">Eastern </d:RegionDescription></m:properties></content></entry>
Desired Output: (The same ATOM entry,as a XML tree, pretty printed with expandable/collapsable nodes)
-<entry xml:base="http://services.odata.org/Northwind/Northwind.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
-<id>
http://services.odata.org/Northwind/Northwind.svc/Regions(1)
</id>
<category term="NorthwindModel.Region" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link rel="edit" title="Region" href= "Regions(1)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Territories" type="application/atom+xml;type=feed" title="Territories" href= "Regions(1)/Territories" />
<title/>
<updated>2014-03-17T10:06:25Z</updated>
-<author>
<name/>
</author>
-<content type="application/xml">
-<m:properties>
<d:RegionID m:type="Edm.Int32">1</d:RegionID>
<d:RegionDescription xml:space="preserve">Eastern </d:RegionDescription>
</m:properties>
</content>
</entry>
Output which I am getting.
-<entry xml:base="http://services.odata.org/Northwind/Northwind.svc/">
-<id>
http://services.odata.org/Northwind/Northwind.svc/Regions(1)
</id>
<category term="NorthwindModel.Region" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link rel="edit" title="Region" href= "Regions(1)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Territories" type="application/atom+xml;type=feed" title="Territories" href= "Regions(1)/Territories" />
<title/>
<updated>2014-03-17T10:06:25Z</updated>
-<author>
<name/>
</author>
-<content type="application/xml">
-<m:properties>
<d:RegionID m:type="Edm.Int32">1</d:RegionID>
<d:RegionDescription xml:space="preserve">Eastern </d:RegionDescription>
</m:properties>
</content>
</entry>
Please note the missing name space declarations in the output's "entry" root element.
The output is a HTML which displays pretty-printed xml, with expandable/collapsable nodes and since it should display the data as-is, namespace declarations are required to be displayed in the output HTML.
Clicking on the "-" symbols collapses the nodes.
If a declaration is already in scope (remember, namespace bindings are inherited to children), it will not need to be redeclared and most XML serializers will not generate it. You haven't shown us an example yet, but I'd bet your output is fine as it is.
Namespace declarations in your source XML appear in the XPath data model as namespace nodes (not attribute nodes).
You need to make clear what you want to do with the namespaces. You're saying that you are generating HTML, but you also say you want to copy the namespaces to the output. That seems inconsistent. Show us you input and desired output.
I haven't managed to spot the difference between your actual output and your desired output (never was very good at "spot the ball" competitions), but from your revised description of the problem it sounds as if you should be using the namespace axis to find the in-scope namespaces for an element (in the same way as you are currently using the attribute axis).
The only tricky part is that the namespace axis will give you all the namespaces for an element and you probably only want to show those that are different from the namespaces of the parent element.
The details depend on whether you are using XSLT 1.0 or 2.0 - you need to tell us!
I am working with XML files that are generated by a digital video camera. The camera allows the user to save all of the camera's settngs to an SD card so that the settings can be recalled or loaded into another camera. The XSL stylesheet I am writing will allow users to view the camera's settings, as saved to the SD card in a web browser.
While most of the values in the XML file -- as formatted by my stylesheet -- make sense to humans, some do not. What I would like to do is have the stylesheet display text that is based on the value in the XML file but more easily understood by humans.
My sample XML file may be viewed here: http://josephthomas.info/Alexa/Setup_120511_140322.xml
A few lines down the page you will see:
Color GAMMA-SxS Rec_Log
While "Rec_Log" is a value that the cameras understand, it is not a value that the camera's users will understand. What I would like for the stylesheet to do is to display "LogC" instead.
In the XML file this value is defined thusly:
<DteLut lowerLimit="0" upperLimit="2">Rec_Log</DteLut>
The XSL formatting the sample page for this value is:
<tr>
<td class="title_column">Color GAMMA-SxS</td><td><xsl:value-of select="Settings/Groups/Recording/DteLut"/>
</td>
</tr>
So what I hope to do is have "LogC" displayed on the page rather than Rec_Log.
It seems to me that the "when" conditional statement is the correct approach, but I am not familiar enough with the syntax to cause this to happen. There are other values in the XML file that want replacing but the above is a good example of my mission.
What you could do is make use of make use of template matching, to match the exceptions to what you want to change. Firstly, add the following template to your XSL
<xsl:template match="DteLut[. = 'Rec_Log']">
<xsl:text>LogC</xsl:text>
</xsl:template>
Then, instead of the following line
<xsl:value-of select="Settings/Groups/Recording/DteLut"/>
Do the following line
<xsl:apply-templates select="Settings/Groups/Recording/DteLut"/>
When the value of*DteLut* is "Rec_Log", then the custom template will be matched to output "LogC" instead. When there is not a match, the default behaviour will kick in which will be to just output the text value as-is.
I would use a data-driven approach. Have a mapping file that gives all the translations:
<translations>
<translate from="Rec_log" to="LogC"/>
<translate .../>
</translations>
then define a key:
<xsl:key name="trans" match="translate" use="#from"/>
and then change
<xsl:value-of select="Settings/Groups/Recording/DteLut"/>
to
<xsl:value-of select="key('trans', Settings/Groups/Recording/DteLut,
doc('translations.xml'))/#to"/>
if using XSLT 2.0, or
<xsl:variable name="val" select="Settings/Groups/Recording/DteLut"/>
<xsl:for-each select="document('translations.xml')">
<xsl:value-of select="key('trans', $val)/#to"/>
</xsl:for-each>
if you're stuck with 1.0.
I'm trying to get the value of iWantToGetThis.jpg and put it into an <img> during my XSL transformation. This is how my xml is structures:
<article>
<info>
<mediaobject>
<imageobject>
<imagedata fileref='iWantToGetThis.jpg'>
Here's what I've come up with for the XSL:
<xsl:template name="user.header.content">
<xsl:stylesheet xmlns:d='http://docbook.org/ns/docbook'>
<img><xsl:attribute name="src">../icons/<xsl:value-of select='ancestor-or-self::d:article/info/mediaobject/imageobject/imagedata/#fileref' /></xsl:attribute></img>
</xsl:stylesheet>
</xsl:template>
The image is being added to the output, but the src attribute is set to "../icons/", so I'm assuming it's not finding the fileref attribute in the XML. This looks perfectly valid to me, so I'm not sure what I'm missing.
I am not sure how you can get anything back at all, because that does not look like a valid XSLT document (I would expect the error "Keyword xsl:stylesheet may not contain img.").
However, it may be you are just showing a fragment of the code. If this is the case, your issue may be that you have only specified the namespace for the article element, when you really need to specify it for all elements in your xpath. Try this
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:mediaobject/d:imageobject/d:imagedata/#fileref"/>
Another possible problem may be because you are using the 'ancestor-or-self' xpath axis to find the attribute. This would only work if your current context was already on the article element, or one of its descendants.
As a side note, you can simplify the code by making use of Attribute Value Templates here
<img src="../icons/{ancestor-or-self::d:article/d:info/d:mediaobject/d:imageobject/d:imagedata/#fileref}" />
I have a database with an xml document in it, and I want to display a transformed xml on my xforms page, when the submission is sent (I'm using orbeon forms).
My solution is, that on the submission my servlet gets the xml from the database, writes it into a file, xslt transforms the xml tree (when and how should I do the transformation?), but I don't know, how to display this file on the xforms page. Maybe the replace="instance" attribute in can help, but i don't know how.
Thanks!
Now, after Alessandro's advice, Im trying to use this xpl thing, but it doesn't work.
In the model:
<xforms:insert nodeset="instance('inst2')"
origin="xxforms:call-xpl('oxf:/resources/pipeline.xpl', 'data',
instance('inst1'), 'data')"/>
in pipeline.xpl:
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:oxf="http://www.orbeon.com/oxf/processors">
<p:param type="input" name="data"/>
<p:param type="output" name="data"/>
<p:processor name="oxf:xslt">
<p:input name="data" href="#data"/>
<p:input name="config" href="transform.xsl"/>
<p:output name="data" ref="data"/>
</p:processor>
My instance, that I want to transform is "complaint-instance", the transformed instance called "trf-instance", the pipeline.xpl file is in the same directory with my xforms page. My styesheet called customerToOperator.xsl. What's wrong in my code?
I just noticed, the note: "If you are using separate deployment, the service and XSLT transformation must be present in the Orbeon WAR file, instead of within your application."
Ehm... Where should I put these files?
my app in details:
a) an xforms page, with 2 instances:
<instance id='inst1'>
<name>
<lastname/>
<firstname/>
</name>
</instance>
<instance id='inst2'>
<fname>
<fullname/>
</fname>
</instance>
I got 2 input fields, referenced on name/lastname and name/firstname.
I have an xforms:insert node, described above, and an xforms:submission node:
<xforms:submission
id="save-submission"
ref="instance('inst2')"
action="/my-servlet"
method="post"
replace="none">
I added 2 files to orbeon/WEB-INF/resources, the pipeline.xpl, (described above) and transform.xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<fname>
<fullname>
<xsl:value-of select="name/firstname"/>
<xsl:value-of select="name/lastname"/>
</fullname>
</fname>
</xsl:template>
</xsl:stylesheet>
And I have a servlet, which writes the posted instance on the console (now it writes inst2 on the console, but without the user input data, only the nodes...)
A really need to fix this...
Thanks again!
To get the XML from a database (relational or not) and apply a transformation, instead of writing my own servlet, I would use an XPL pipeline, and map this pipeline to a URL through the page flow. Now you have a service that answers to an HTTP request and returns XML. To call the service from XForms, you use an <xforms:submission replace="instance">. You end up with the XML in an instance, and you can display it with something like: <xforms:output value="saxon:serialize(instance(), 'xml')"/>.
In all cases (including separate deployment), the pipeline and XSLT file must be in the "resources". Usually, this means the WEB-INF/resources of the Orbeon's web app. But you can also do more fancy things by setting up the Orbeon resource manager to also use other directories on disk.