IIRC there was some similar problem quite some time ago and
the attached patch might help, but I might be way off.

HTH

Michi


Marc-André GROSY wrote:

Hi,
I use getElementsByTagNameNS method in assets.xsp file. Like that :
try{ ...
subject = 
metaDoc.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/","subject";).item(0).getChildNodes().item(0).getNodeValue();
} catch ....

But if <dc:subject/> element in .meta file is empty (like <dc:subject></dc:subject>) I obtain this error :
ServerPagesGenerator.generate()
cause: java.lang.NullPointerException

Original Exception: java.lang.NullPointerException
        at 
org.apache.cocoon.www.lenya.content.info.assets_xsp.generate(org.apache.cocoon.www.lenya.content.info.assets_xsp:306)
        at 
org.apache.cocoon.generation.ServerPagesGenerator.generate(ServerPagesGenerator.java:263)
        at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.processXMLPipeline(AbstractProcessingPipeline.java:581)
        at 
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processXMLPipeline(AbstractCachingProcessingPipeline.java:196)
        at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:525)

Anyone can explain me how solve this problem ?

Thanks a lot

Marc

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Michael Wechner
Wyona      -   Open Source Content Management   -    Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
[EMAIL PROTECTED]                        [EMAIL PROTECTED]

Index: src/webapp/lenya/content/info/assets.xsp
===================================================================
--- src/webapp/lenya/content/info/assets.xsp    (revision 307383)
+++ src/webapp/lenya/content/info/assets.xsp    (working copy)
@@ -58,32 +58,43 @@
       <lenya-info:creator><input:get-attribute module="access-control" 
name="user-name"/></lenya-info:creator>
       <lenya-info:language><input:get-attribute module="page-envelope" 
name="document-language"/></lenya-info:language>
       <xsp:logic>
-       if (resources != null) {
-         for(int i = 0; i &lt; resources.length; i++) {    
-      <!-- The follwoing code should be moved into a more generic dc class 
library
-           i.e. to o.a.l.xml.dc or o.a.l.dc
-           We also should consolidate the *.publication.DublinCore  * classes 
to use the newer lib.
-           But this would be to heavy for 1.2.1, so I do this hack here, sorry 
:) /roku
-      -->
-      File metaFile;
-      String title = "";
-      String format = "";
-      org.w3c.dom.Document metaDoc;
-      try {
-        metaDoc = 
DocumentHelper.readDocument(resourceMgr.getMetaFile(resources[i]));
-                               title = 
metaDoc.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/";, 
"title").item(0).getChildNodes().item(0).getNodeValue();
-                               format = 
metaDoc.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/";, 
"format").item(0).getChildNodes().item(0).getNodeValue();
-      } catch(Exception e) { continue; } 
+        if (resources != null) {
+          for(int i = 0; i &lt; resources.length; i++) {    
+            <!--
+               The follwoing code should be moved into a more generic dc class 
library
+               i.e. to o.a.l.xml.dc or o.a.l.dc
+               We also should consolidate the *.publication.DublinCore  * 
classes to use the newer lib.
+               But this would be to heavy for 1.2.1, so I do this hack here, 
sorry :) /roku
+            -->
+            File metaFile;
+            String title = "";
+            String format = "";
+            org.w3c.dom.Document metaDoc;
+            try {
+              metaDoc = 
DocumentHelper.readDocument(resourceMgr.getMetaFile(resources[i]));
+           } catch (Exception e) {
+              continue;
+            }
+           try {
+              title = 
metaDoc.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/";, 
"title").item(0).getChildNodes().item(0).getNodeValue();
+            } catch (Exception e) { 
+              title = "";   
+            }
+            try {
+              format = 
metaDoc.getElementsByTagNameNS("http://purl.org/dc/elements/1.1/";, 
"format").item(0).getChildNodes().item(0).getNodeValue();
+            } catch (Exception e) {
+              format = "";
+            }
 
-         <xsp:content>
-           <lenya-info:asset>   
-             <dc:source><xsp:expr>resources[i].getName()</xsp:expr></dc:source>
-        <dc:title><xsp:expr>title</xsp:expr></dc:title>
-             <dc:date><xsp:expr>SimpleDateFormat.getDateInstance().format(new 
Date(resources[i].lastModified()))</xsp:expr></dc:date>
-        <dc:format><xsp:expr>format</xsp:expr></dc:format>
-             
<dc:extent><xsp:expr>resources[i].length()/1024</xsp:expr></dc:extent>
-           </lenya-info:asset>
-         </xsp:content>
+            <xsp:content>
+              <lenya-info:asset>   
+               
<dc:source><xsp:expr>resources[i].getName()</xsp:expr></dc:source>
+                <dc:title><xsp:expr>title</xsp:expr></dc:title>
+                
<dc:date><xsp:expr>SimpleDateFormat.getDateInstance().format(new 
Date(resources[i].lastModified()))</xsp:expr></dc:date>
+                <dc:format><xsp:expr>format</xsp:expr></dc:format>
+                
<dc:extent><xsp:expr>resources[i].length()/1024</xsp:expr></dc:extent>
+              </lenya-info:asset>
+            </xsp:content>
          } 
        }
       </xsp:logic>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to