Hi Roger
I can certainly offer suggestions, but I feel like I'm running blind and don't
have an environment for easily testing this right now. Further, I haven't
really got my hands dirty with XSLT for a year or so now.
Also it's your source XML that I needed. I found a sample at [1] which is
probably close, and possibly being an intermediary format you never see this
yourself anyway.
There's an error in the attached XSLT file. It is invalid XML in at least one
spot where the HTML div element is closed at line 233 below the close of the
xsl:template element in which it started. XML elements can be nested, but
mustn't interleave like that. Any transformation should choke before it starts
at XML that is not well-formed. I am surprised you don't see an error message.
By rights you probably should.
I am going to suggest a different way to do this that might be easier to
troubleshoot. It's better, more robust and readable XSLT in my opinion.
Replace your xsl:if element with this:
<xsl:apply-templates select="dim:field[@element='type'][text()='Citation']" />
(I am pretty sure that two adjacent square-bracketed predicates are equivalent
to one with "and" in between them (as in line 234 of item-list.xsl), but play
with that as an option.)
So we are going to invoke another template based on the same conditions.
Now put this new template somewhere at the same level as other xsl:template
elements.
<xsl:template match="dim:field[@element='type'][text()='Citation']">
<strong>CITATION ONLY</strong>
</xsl:template>
This will match anything matching those criteria (the same ones) and do what's
inside (output that stuff).
You don't strictly need the square-bracketed conditions on both the template
and its call. When you invoke or create a template, you have to decide how
tightly to specify its matching depending on expected contexts. (You might even
decide that <xsl:apply-templates/> is safe enough for the call. You don't need
the @select attribute if there are no conditions, and it will match what it can
from the calling context.)
If this doesn't work, I would try eliminating components until you find the
culprit condition. For example, start by removing the second predicate
("[text()='Citation']") from both the call and the template and see if the
template fires. It's possible that whitespace around the text content
"Citation" is stopping that match, for example. (If that's the case, there's a
function called normalize-space that you could use to strip space off the text
value e.g. "normalize-space(text())" in your matching condition.)
Good luck, it's home time for me, will leave you in the hands of the working
timezones :)
Cheers
[1]
https://wiki.duraspace.org/display/DSPACE/DSpaceIntermediateMetadata#DSpaceIntermediateMetadata-Elements
From: Roger Gillis [mailto:[email protected]]
Sent: Tuesday, 5 November 2013 2:11 p.m.
To: Barnes, Hugh
Cc: [email protected]
Subject: Re: [Dspace-tech] Displaying text based on dc.type value
Hi Hugh,
Thanks for your response. I tried correcting the syntax errors you pointed out
and used <xsl:if> instead, but it still doesn't appear to have worked. I'm not
seeing any errors - it's just not showing up, like I had hoped. I've attached
the .xsl file, which includes this code that I'm trying to edit.
Any suggestions you might have are much appreciated!
Thanks!
On Mon, Nov 4, 2013 at 8:33 PM, Barnes, Hugh
<[email protected]<mailto:[email protected]>> wrote:
Hi Roger
Firstly, what results are you seeing exactly? Error-like or blank?
I can't give you a definitive answer because I am not familiar with the XML
source you are processing, but I can see a couple of problems with syntax:
* The square bracket in your XPath predicate starting with "@element" is not
closed. I suspect you want to say something more like
"dim:field[@element='type']/text()='Citation'" but again I can't see your
source XML.
* <xsl:if/> is better suited if you are just testing one condition with no
alternative conditions or fallback. <xsl:when/> elements must be surrounded by
<xsl:choose/> if you haven't done that.
If that doesn't fix it and no-one else replies, I can probably help you if you
provide the snippet of XML you are processing here.
Cheers
Hugh Barnes
Digital Access Coordinator
Library, Teaching and Learning
Lincoln University
Christchurch
New Zealand
p +64 3 423 0357<tel:%2B64%203%20423%200357>
From: Roger Gillis
[mailto:[email protected]<mailto:[email protected]>]
Sent: Tuesday, 5 November 2013 11:46 a.m.
To: [email protected]<mailto:[email protected]>
Subject: [Dspace-tech] Displaying text based on dc.type value
Hi everyone,
I'm hoping someone might be able to help me out with this issue: I'm looking to
display a bit of text to indicate items that are citations only, as opposed to
those might contain actual digital items. I'm doing this by submitting an item
and indicating the value of dc.type as "Citation." I was hoping then to edit
item-list.xsl (I'm using the Mirage theme in Dspace 3.1) to display a bit of
text in order to distinguish items that are citations. So far I've got this:
<xsl:when test="dim:field[@element = 'type'/node()='Citation'">
<strong>
CITATION ONLY
</strong>
</xsl:when>
However, I'm not really seeing any results. Perhaps my use of the <xsl:when> to
specify the value of the node is off?
Any help would be appreciated.
Thanks!
-Roger
Roger Gillis
Archives & Scholarly Communication Librarian
Mount Saint Vincent University Library
________________________________
P Please consider the environment before you print this email.
"The contents of this e-mail (including any attachments) may be confidential
and/or subject to copyright. Any unauthorised use, distribution, or copying of
the contents is expressly prohibited. If you have received this e-mail in
error, please advise the sender by return e-mail or telephone and then delete
this e-mail together with all attachments from your system."
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
DSpace-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-tech
List Etiquette: https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette