Hi Tim,
The problem with just add the section in the xsl is that the field
dc.relation.externalresourse
have internal and external link and I need separate them in class, right?
I'm getting close I guess, I add the field in the item, sorry about the
DCValue, it is a DSpace 3.
private void addExternalURL(Item item) throws WingException {
DCValue[] related = item.getMetadata("dc", "relation",
"externalresource", Item.ANY);
ArrayList<String> links = new ArrayList<String>();
for(DCValue dcValue: related ){
if(!isInternal(dcValue.value)) {
item.addMetadata("iadb", "externalUrl",null, null, dcValue.value);
}
}
}
And in the item-view.xls I have the code below, I'm not sure about the
how to use the for-each.
<xsl:if
test="//mets:dmdSec/mets:mdWrap[@OTHERMDTYPE='DIM']/mets:xmlData/dim:dim/dim:field[@element='externalUrl'
and @mdschema='iadb']">
<div id="externalUrl" class="col-md-3 col-md-height">
<h3 class="related-publications">External Links</h3>
<xsl:for-each
select="//mets:dmdSec/mets:mdWrap[@OTHERMDTYPE='DIM']/mets:xmlData/dim:dim/dim:field[@element='externalUrl'
and @mdschema='iadb']">
<div>
<a>
<xsl:attribute name="href">
<xsl:value-of
select="//mets:dmdSec/mets:mdWrap[@OTHERMDTYPE='DIM']/mets:xmlData/dim:dim/dim:field[@element='externalUrl'
and @mdschema='iadb']"/>
</xsl:attribute>
</a>
</div>
</xsl:for-each>
</div>
</xsl:if>
Best regards
Luiz
On Wed, Feb 24, 2016 at 2:54 PM, Tim Donohue <[email protected]> wrote:
> Hi Luiz,
>
> (I'm only answering this on dspace-tech, as that's the most appropriate
> list for this question)
>
> It might be easier to add simple HTML into the *Theme* itself (i.e. the
> XSLTs that make up the theme) rather than the Aspect layer. The Aspect
> layer is only exports valid DRI (XML), which is then processed by the
> Theme's XSLTs and turned into the final HTML. More on the DRI XML format:
> https://wiki.duraspace.org/display/DSDOC5x/DRI+Schema+Reference
>
> So, if you just want to add a simple link, it'd probably be easier to do
> that in the XSLT of your theme.
>
> If you still want to do it at the Aspect layer, you probably need to be
> sure the HTML is actually "well formed" (and valid XML as well). It looks
> like your HTML is not, as it has an ending "<\a>" tag, instead of the
> "</a>" tag that is expected in HTML/XML.
>
> Additionally, the "SimpleHTMLFragment" only supports some *very basic*
> HTML tags/attributes. When you use this option of the API, your HTML
> fragment is actually "translated" into valid DRI XML. From reading the
> "SimpleHTMLFragment.translate()" method, it looks like the <a> tag is
> supported. But, the *class* attribute is not supported..so that may be
> another factor in the problems you are having. Here's the full contents of
> that translate() method:
>
>
> https://github.com/DSpace/DSpace/blob/dspace-5_x/dspace-xmlui/src/main/java/org/dspace/app/xmlui/wing/element/SimpleHTMLFragment.java#L324
>
> Good luck,
>
> Tim
>
>
> On 2/24/2016 12:02 PM, Luiz dos Santos wrote:
>
> Hi,
>
>
> Our repository have two kind of url in the
> dc.relation.externalresourse, internal and external url, so I add the
> method below in the class
> org.dspace.app.xmlui.aspect.artifactbrowser.ItemViewer.java,
> in module folder. I'm calling the method in the addBody. The problem is
> that I would like to add html to the item page, so I add the code that "
> externalLinks.addSimpleHTMLFragment(*false*, *"<a href=**\"**" *+ value +
> *"**\"** class=**\"**extternal-link**\"**> External Link <**\\**a>"*);"
> but it is printing the string as a literal in item page html, I mean, the
> browser is not render the html code. My question, how can I add something
> in the html using a aspect class?
>
>
> Thanks in advance
>
> Luiz
>
>
> *private void *addExternalItems(Division division, Item item) *throws
> *WingException
> {
>
> DCValue[] related = item.getMetadata(*"dc"*, *"relation"*,
> *"externalresource"*, Item.*ANY*);
>
>
> ArrayList<String> links = *new *ArrayList<String>();
>
>
> *for*(DCValue dcValue: related ){
>
> *if*(!isInternal(dcValue.*value*)) {
>
> links.add(dcValue.*value*);
>
> }
>
> }
>
>
>
> *if*(!links.isEmpty()) {
>
> Division externalLinks = division.addDivision(*"externalLinks"*);
>
> *for*(String value: links) {
>
> externalLinks.addSimpleHTMLFragment(*false*, *"<a href=**\"**"
> *+ value + *"**\"** class=**\"**extternal-link**\"**> External Link <**\\*
> *a>"*);
>
> }
>
> }
>
>
>
> }
> --
> You received this message because you are subscribed to the Google Groups
> "DSpace Technical Support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/dspace-tech.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Tim Donohue
> Technical Lead for DSpace & DSpaceDirect
> DuraSpace.org | DSpace.org | DSpaceDirect.org
>
> --
> You received this message because you are subscribed to the Google Groups
> "DSpace Technical Support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/dspace-tech.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/dspace-tech.
For more options, visit https://groups.google.com/d/optout.