cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mariano Kamp <mk...@codamax.com>
Subject XSLT broken?
Date Wed, 04 Jul 2001 09:34:12 GMT
Hi, 

  I still have the problem, that the XSLT processor invoked from within 
cocoon behaves differently as opposed to be invoked from the command line. 
This happens only when a second namespace is involved. This is the case when 
using the SQLTransformer for example. The nodes are completly omitted when 
using the TRAX Transformer.

  I tried to find a hint in the code with not much of success. Although I 
found that it would work, when there is just one namespace, so I tried to 
patch the SQLTransformer in order to give it a parameter what the output 
namespace should be. Unfortunately even this workaround doesn't work. The 
namespace related to the SQLTransformer is still outputed which breaks the 
TRAX Transformer. 

  Here is what I tried:

   Index: src/org/apache/cocoon/transformation/SQLTransformer.java
===================================================================
RCS file: 
/home/cvspublic/xml-cocoon2/src/org/apache/cocoon/transformation/SQLTransformer.java,v
retrieving revision 1.11
diff -u -r1.11 SQLTransformer.java
--- src/org/apache/cocoon/transformation/SQLTransformer.java    2001/06/30 
02:38:30     1.11
+++ src/org/apache/cocoon/transformation/SQLTransformer.java    2001/07/04 
09:20:00
@@ -73,6 +73,7 @@
     public static final String MAGIC_NR_OF_ROWS = "show-nr-of-rows";
     public static final String MAGIC_QUERY = "query";
     public static final String MAGIC_VALUE = "value";
+    public static final String MAGIC_OUTPUT_NAMESPACE = "output-namespace";
     public static final String MAGIC_DOC_ELEMENT = "doc-element";
     public static final String MAGIC_ROW_ELEMENT = "row-element";
     public static final String MAGIC_IN_PARAMETER = "in-parameter";
@@ -129,6 +130,9 @@
     protected Parameters parameters;
     protected Map objectModel;
 
+    /** output namespace */
+    protected String outputNamespace;
+
     public void compose(ComponentManager manager) {
         try {
             this.manager = manager;
@@ -201,17 +205,27 @@
         }
         showNrOfRows = 
parameters.getParameter(SQLTransformer.MAGIC_NR_OF_ROWS,null);
 
-        // Check for row-element and doc-element
+        // Check for row-element, doc-element and the associated namespace 
         parameter = 
parameters.getParameter(SQLTransformer.MAGIC_DOC_ELEMENT, null);
         if (parameter != null) {
             getLogger().debug("DOC-ELEMENT: " + parameter);
           default_properties.setProperty(SQLTransformer.MAGIC_DOC_ELEMENT, 
parameter);
         }
+
         parameter = 
parameters.getParameter(SQLTransformer.MAGIC_ROW_ELEMENT, null);
         if (parameter != null) {
             getLogger().debug("ROW-ELEMENT: " + parameter);
             default_properties.setProperty(SQLTransformer.MAGIC_ROW_ELEMENT, 
parameter);
         }
+
+        parameter = 
parameters.getParameter(SQLTransformer.MAGIC_OUTPUT_NAMESPACE, null);
+        if (parameter != null) {
+            getLogger().debug("OUTPUT-NAMESPACE: " + parameter);
+            outputNamespace = parameter;
+        }
+       else {
+           outputNamespace = my_uri;
+       }
     }
     
     /** END SitemapComponent methods **/
@@ -223,6 +237,9 @@
      */
     protected void executeQuery(int index) throws SAXException {
 //        this.contentHandler.startPrefixMapping("",my_uri);
+        if (!outputNamespace.equals(my_uri)) {
+           this.contentHandler.startPrefixMapping("", outputNamespace);
+       }
         getLogger().debug("SQLTransformer executing query nr " + index);
         AttributesImpl attr = new AttributesImpl();
         Query query = (Query) queries.elementAt(index);
@@ -230,12 +247,12 @@
             query.execute();
 
             if (showNrOfRows!=null && showNrOfRows.equalsIgnoreCase("true")) 
 {
-              
attr.addAttribute(my_uri,query.nr_of_rows,query.nr_of_rows,"CDATA",
+              
attr.addAttribute(outputNamespace,query.nr_of_rows,query.nr_of_rows,"CDATA",
                                 String.valueOf(query.getNrOfRows()));
             }
             String name = query.getName();
             if (name !=null)  {
-              
attr.addAttribute(my_uri,query.name_attribute,query.name_attribute,"CDATA",
+              
attr.addAttribute(outputNamespace,query.name_attribute,query.name_attribute,"CDATA",
                                 name);
             }
             this.start(query.rowset_name, attr);
@@ -264,6 +281,8 @@
         }
         this.end(query.rowset_name);
 //        this.contentHandler.endPrefixMapping("");
+        if (!outputNamespace.equals(my_uri))
+         this.contentHandler.endPrefixMapping("");
     }
 
     protected static void throwIllegalStateException(String message) {
@@ -596,12 +615,12 @@
 
     private void start(String name,
                        AttributesImpl attr) throws SAXException {
-        super.contentHandler.startElement(my_uri, name, name, attr);
+        super.contentHandler.startElement(outputNamespace, name, name, attr);
         attr.clear();
     }
 
     private void end(String name) throws SAXException {
-        super.contentHandler.endElement(my_uri, name, name);
+        super.contentHandler.endElement(outputNamespace, name, name);
     }
 
     private void data(String data) throws SAXException {


Any clue, why it still outputs the namespace of the SQLTransformer? It 
doesn't output any element from the SQLTransformer, but the namespace?!

Any help is strongly appreciated.

Mariano

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message