Home
TeamSite
Alt tag in Image metadata
Enthu
We have a requirement in which i need to display image Alt tag in xslt output file. I customized metadata in mediabin and added new "Alt" metadata. Now when I import images in TS forms, I get value of Alt in MediaBin/Metadata xml.
How can I get this value of Alt metadata in dcr also. I am getting value of label in dialog tag in dcr but I am not sure how I can retrieve value of Alt metadata in the same way.
Version - TS 6.7.1 sp1 on Solaris 10/ MB 4.6
Find more posts tagged with
Comments
cliff1
The answer will depend on what technology you are using to generate your HTML file. You mentioned XSLT, but more details are needed since XSLT can be invoked multiple way to generate HTML. Are you using:
1) The tag from the legacy perl based presentation templating?
2) Direct XSLT Presentation Template -- the new style presentation templates that replaced the legacy perl based presentation template?
3) SitePublisher component XSLT?
In any of the above, you probably don't want to insert the alt-text into the DCR. Rather, you want to use two sources of information during the XSLT transformation (1: DCR 2: extended attribute). The trick is opening the XML extended attribute and grabbing the alt text while the XSLT is processing -- the specifics depend on how your XSLT is being executing.
-Cliff
Enthu
Cliff, Thanks for reply. I am using XSLT presentation template for html generation. I need Alt value in dcr because we need to send this value along with other dcr value as part of our integration with portal, its something which can not be changed. Right now, I am using server callout on dcr saving and populating Alt tag field.
My questions are
1) Can I auto populate value of Alt metadata in dcr when I click on browse button in my dcr? Its working for image label.
2) You told me that two sources of information during the XSLT transformation (1: DCR 2: extended attribute) can be used to get Alt value in html. Can you explain it little bit more. I mean in earlier perl presentation we could you iwextattr cmd to get value of extended attribute but how can I get the same value in my xslt presentation.
cliff1
Enthu,
Sorry for the delay; I don't recall getting an e-mail message that you had updated this thread.
1. There is no way to auto-populate the DCR field when you click the browse button. There are a couple of predefined fields like label, path, etc. that can be used in the
tags, but not a generic mechanism to fetch any metadata.
2. I recently learned that the programming model for extending XSLT PTs with custom code (like reading extended attributes) needs more documentation, so I filed a bug. The product does ship with an example of how to use java within your XSLT to do any arbitrary programming. The extension gives you access to a bunch of convince objects like a CSClient handle for the current user.
I had a recent e-mail exchange with one our course developers in the education department on this topic and I've pasted the relevant information below. In addition to using java, the guy from education (Bob) fired back an example where he used rhino to provide a javascript interface for people that prefer javascript. This is everything I have -- I hope it helps!
Java based example shipping with product:
XSLT PT: /examples/Templating/templatedata/xslt/tasklist/presentation/tasklist.xsl
Java Source: /local/config/lib/content_center/customer_samples_src/src/com/corp/custom/xslt/XSLTCustomExtension.java
Context Object:
If you look in the source code for XSLTCustomeExtention.java, you will see a line like the following:
CSClient client = XSLTExtensionContext.getContext().getCSClient();
The com.interwoven.cssdk.transform.XSLTExtensionContext object has a bunch of getters (bean pattern) that provide access to the most needed stuff for PT programs. The above example shows getting the CSClient object, but there are many others. Unfortunately, the javadoc for CSSDK does not seem to list this class (I filed a bug). Here are the gettters that you can use:
/**
* Get CSClient object.
*/
public CSClient getCSClient() {
return this.client;
}
/**
* Get input data vpath.
*/
public CSVPath getDcr()
{
return this.dcr;
}
/**
* Get presentation template vpath.
*/
public CSVPath getPt()
{
return this.pt;
}
/**
* Get output directory vpath.
*/
public CSVPath getOutputDirectory()
{
return this.outputDir;
}
/**
* Get output filename.
*/
public String getOutputFileName()
{
return this.outputFileName;
}
/**
* Get the umask configured in iw.cfg.
*/
public String getUmask()
{
return this.umask;
}
/**
* Get the operation sysytem encoding on iwserver.
*/
public String getOsEncoding()
{
return this.osEncoding;
}
=======================================================
javascript example (I have not tested this). Need to include rhino.jar by putting it in customer toolkit WEB-INF/lib directory (see UI Customization Guide).
=======================================================
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="
http://xml.apache.org/xalan"
xmlns:iw="Interwoven-XSLT-Extentions"
extension-element-prefixes="iw"
exclude-result-prefixes="iw">
<br /> <br> function getUser() {<br> var xslContext = Packages.com.interwoven.cssdk.transform.XSLTExtensionContext.getContext();<br> return xslContext.getCSClient().getCurrentUser().getShortName();<br> }<br> <br> function getDcr() {<br> var xslContext = Packages.com.interwoven.cssdk.transform.XSLTExtensionContext.getContext();<br> return xslContext.getDcr();<br> }<br> <br> function getPt() {<br> var xslContext = Packages.com.interwoven.cssdk.transform.XSLTExtensionContext.getContext();<br> return xslContext.getPt();<br> }<br> <br> function getOutputDirectory() {<br> var xslContext = Packages.com.interwoven.cssdk.transform.XSLTExtensionContext.getContext();<br> return xslContext.getOutputDirectory();<br> }<br> <br> function getOutputFileName() {<br> var xslContext = Packages.com.interwoven.cssdk.transform.XSLTExtensionContext.getContext();<br> return xslContext.getOutputFileName();<br> }<br> <br> function showProps() {<br> var retval;<br> var prop = java.lang.System.getProperties();<br> var keyset = prop.keySet();<br> var varName = keyset.toArray();<br> for (var i=0;i<varName.length;i++) {<br> retval += "<tr><td>" + i + "</td><td>" + varName<i> + " </td><td> " + prop.get(varName<i&gt
+ "</td></tr>";<br> }<br> return retval;<br> }<br> <br> function showEnv() {<br> var retval;<br> var env = java.lang.System.getenv();<br> var keyset = env.keySet();<br> var varName = keyset.toArray();<br> for (var i=0;i<varName.length;i++) {<br> retval += "<tr><td>" + i + "</td><td>" + varName<i> + " </td><td> " + env.get(varName<i&gt
+ "</td></tr>";<br> }<br> return retval;<br> }<br> <br />
Property
Value
User Name
DCR Path
PT Path
Output Dir
Output File