You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by th...@apache.org on 2006/09/11 13:27:09 UTC
svn commit: r442176 - in /lenya/trunk/src:
java/org/apache/lenya/cms/cocoon/transformation/MetaDataTransformer.java
pubs/default/sitemap.xmap webapp/lenya/config/sitemap/transformers.xmap
Author: thorsten
Date: Mon Sep 11 04:27:08 2006
New Revision: 442176
URL: http://svn.apache.org/viewvc?view=rev&rev=442176
Log:
http://issues.apache.org/bugzilla/show_bug.cgi?id=39891
Finishing transformer and adding an example in the default pub.
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/MetaDataTransformer.java
lenya/trunk/src/pubs/default/sitemap.xmap
lenya/trunk/src/webapp/lenya/config/sitemap/transformers.xmap
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/MetaDataTransformer.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/MetaDataTransformer.java?view=diff&rev=442176&r1=442175&r2=442176
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/MetaDataTransformer.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/transformation/MetaDataTransformer.java Mon Sep 11 04:27:08 2006
@@ -19,6 +19,7 @@
import org.apache.lenya.cms.publication.PublicationException;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.DefaultHandler;;
public class MetaDataTransformer extends AbstractSAXTransformer implements
@@ -26,7 +27,7 @@
/**
* The namespace for the meta data is http://apache.org/lenya/meta/1.0
*/
- static public final String NAMESPACE_URI = "http://apache.org/lenya/meta/1.0";
+ static public final String NAMESPACE_URI = "http://apache.org/lenya/meta/1.0/";
/**
* The namespace prefix for this namespace.
@@ -112,7 +113,7 @@
if (ELEMENT_ATT.equals(localName))
key = value;
else if (NS_ATT.equals(localName))
- ns = key;
+ ns = value;
else if (UUID_ATT.equals(localName))
uuid = value;
else if (LANG_ATT.equals(localName))
@@ -126,6 +127,17 @@
Document document = pub.getArea(area).getDocument(uuid, lang);
MetaData metaData = document.getMetaData(ns);
String [] returnValue=metaData.getValues(key);
+ if (returnValue.length>1){
+ for (int i = 0; i < returnValue.length; i++) {
+ AttributesImpl attributes = new AttributesImpl();
+ attributes.addAttribute("", VALUE_ELEMENT, VALUE_ELEMENT, "CDATA", returnValue[i]);
+ attributes.addAttribute("", ELEMENT_ATT, ELEMENT_ATT, "CDATA", key);
+ this.contentHandler.startElement(ns, VALUE_ELEMENT, PREFIX+":"+VALUE_ELEMENT, attributes);
+ this.contentHandler.endElement(ns, VALUE_ELEMENT, PREFIX+":"+VALUE_ELEMENT);
+ }
+ }else if (returnValue.length==1){
+ this.contentHandler.characters(returnValue[0].toCharArray(), 0, returnValue[0].toCharArray().length);
+ }
} catch (PublicationException e) {
throw new SAXException("Error by getting document for [ "+lang+"/"+uuid+" ]");
} catch (MetaDataException e) {
Modified: lenya/trunk/src/pubs/default/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/sitemap.xmap?view=diff&rev=442176&r1=442175&r2=442176
==============================================================================
--- lenya/trunk/src/pubs/default/sitemap.xmap (original)
+++ lenya/trunk/src/pubs/default/sitemap.xmap Mon Sep 11 04:27:08 2006
@@ -15,11 +15,14 @@
limitations under the License.
-->
-<!-- $Id$ -->
+<!-- $Id: sitemap.xmap 439259 2006-09-01 10:06:39Z andreas $ -->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
+ <map:transformers default="xslt">
+ <map:transformer name="metaData" logger="lenya.sitemap.transformer.metaData" src="org.apache.lenya.cms.cocoon.transformation.MetaDataTransformer"/>
+ </map:transformers>
<map:serializers default="xhtml">
<map:serializer logger="sitemap.serializer.links" name="links" src="org.apache.lenya.cms.cocoon.serialization.LinkSerializer"/>
</map:serializers>
@@ -184,6 +187,24 @@
</map:otherwise>
</map:select>
+ <!-- This is a demonstration of the generic meta data transformer
+ described in bug 39891.
+
+ 1) define the ns: xmlns:meta="http://apache.org/lenya/meta/1.0/"
+ 2) use it in above xsl like e.g.
+ <meta:value ns="http://purl.org/dc/elements/1.1/" element="date" uuid="{@uuid}"/>
+
+ Where @ns is the namespace for which you want to retrieve the @element for.
+ If there is more then one element registered then the transformer returns:
+ <value xmlns="http://apache.org/lenya/meta/1.0/" value="2005-09-11 12:44:05" element="date" />
+ <value xmlns="http://apache.org/lenya/meta/1.0/" value="2006-09-11 12:44:05" element="date" />
+
+ Otherwise it will return the value as characters.
+ -->
+ <map:transform type="metaData">
+ <map:parameter name='pubid' value='{page-envelope:publication-id}'/>
+ <map:parameter name='area' value='{page-envelope:area}'/>
+ </map:transform>
<map:transform type="i18n">
<map:parameter name="locale" value="{page-envelope:document-language}"/>
</map:transform>
Modified: lenya/trunk/src/webapp/lenya/config/sitemap/transformers.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/config/sitemap/transformers.xmap?view=diff&rev=442176&r1=442175&r2=442176
==============================================================================
--- lenya/trunk/src/webapp/lenya/config/sitemap/transformers.xmap (original)
+++ lenya/trunk/src/webapp/lenya/config/sitemap/transformers.xmap Mon Sep 11 04:27:08 2006
@@ -20,6 +20,7 @@
xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:transformer name="link-rewrite" logger="lenya.sitemap.transformer.link-rewrite" src="org.apache.lenya.cms.cocoon.transformation.LinkRewritingTransformer"/>
+ <map:transformer name="metaData" logger="lenya.sitemap.transformer.metaData" src="org.apache.lenya.cms.cocoon.transformation.MetaDataTransformer"/>
<map:transformer name="i18n" logger="sitemap.transformer.i18n" src="org.apache.cocoon.transformation.I18nTransformer">
<catalogues default="cmsui">
<catalogue id="cmsui" name="cmsui" location="cocoon://i18n-catalogue/"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org