Sorry for yet another follow-up.

I thought it was worth mentioning that the java.net.URLEncoder is used in
the following files:

 

Dri2xhtml/DIM-Handler.xsl

Dri2xhtml-alt/aspect/artefact/browser/COinS.xsl

 

Although they use the following:

 

<xsl:value-of select="encoder:encode(string(.), 'UTF-8')"/>

 

Not 100% sure if it's necessary to include the UTF-8 flag or not. According
to the docs
(http://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html), "if an
encoding is not specified, then the default encoding of the platform is
used".

Suppose it can't hurt to include it.

 

-David

 

From: David Cook [mailto:[email protected]] 
Sent: Thursday, 27 February 2014 12:10 PM
To: 'dspace-tech'
Subject: RE: EncodeURLTransformer in XMLUI

 

Belay that last message! I figured it out!

 

In hindsight, I'm not sure how I thought the "EncodeURLTransformer" could
possibly do what I wanted it to do. After all, if it got something like:

 

a href="/browse?type=subject&amp;value=buildings &amp; structures"

It would be hooped. There's no way for it to know that "structures" is part
of "value" and not the beginning of its own key.

 

Of course, I don't think that "EncodeURLTransformer" was working anyway, or
at least wasn't working the way that the documentation makes it seem that it
would work. But whatever.

 

I did find a solution!

I noticed this line in one of my XSLTs:
xmlns:encoder="xalan://java.net.URLEncoder"

 

So I did a bit of research into Xalan and using Java functions in XSLTs
(I've only done it a bit with Perl and PHP in the past), and voila! 

<xsl:value-of select="encoder:encode(string(.))"/>

 

Instead of <xsl:value-of select="."/> or <xsl:copy-of select="."/>.

 

The value that I'm adding into the URL is now URL encoded ^_^

 

Of course, using XSLT 2.0 would be preferable (as helix84 and other folks
have mentioned), but I don't want to deviate too much from the mainstream at
the moment.

 

Links regarding XSLT 2.0 and Saxon v. Xalan

https://jira.duraspace.org/browse/DS-995

http://dspace.2283337.n4.nabble.com/Why-does-DSpace-use-XSLT-1-0-td3750179.h
tml


-David

 

References on Xalan and using Java in XSLTs:

http://www17.homepage.villanova.edu/william.pohlhaus/xsl/java/

http://xml.apache.org/xalan-j/extensions.html


Xalan looks quite powerful although I'm sure a person wouldn't want to go
overboard with using it to provide non-standard functions in a XSLT in the
event that we were to switch to Saxon or some other processor.

 

From: David Cook [mailto:[email protected]] 
Sent: Wednesday, 26 February 2014 5:53 PM
To: 'dspace-tech'
Subject: EncodeURLTransformer in XMLUI

 

Hi all:

 

Has anyone actually got the EncodeURLTransformer to work in the XMLUI?

 

I've created a custom theme based on Mirage. I've added the following into
my theme's map:components:

 

<map:transformers default="xslt">

            <map:transformer name="encodeURL"
src="org.apache.cocoon.transformation.EncodeURLTransformer"/>

        </map:transformers>

 

And I've added <map:transform type="encodeURL"/> before the final serialize
to xhtml.

 

There are still spaces in the URL and ampersand entities that should've been
URL encoded instead of HTML encoded.

I should mention that I'm trying to create "browse" links for specific
metadata values in the simple item record view.

 

I see that the Discovery browses are URL encoded, but it looks like that
happens at the Java level.

 

Any ideas, folks?

 

 

 

-David

 

Related links: 

 

https://wiki.duraspace.org/pages/viewpage.action?pageId=19006367

 

http://sourceforge.net/p/dspace/mailman/message/13584834/

 

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&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

Reply via email to