You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Gertjan Assies <ge...@assies.nu> on 2005/01/04 16:35:17 UTC

Disappearing namespace definition when xml is generated through a cocoon:// psuedoprotocol

hi,

I'm having some problems with a disappearing namespace
both seem related to when the xml is generated through a 
cocoon://something in the sitemap
Anyone else have had this problem, and perhaps know how to fix this?

The system that fails:
FreeBSD 4.10-STABLE
cocoon-2.1.5.1 running in Tomcat 4.1
xalan-2.6.0

On my laptop I dont have this problem. (winXP, Tomcat 5.0 or 
Jetty/4.2.19, Cocoon 2.1.5.1, xalan 2.6.0)

Here below are 2 seperate manifestations

1) I have a custom Transformer to create a FreeChart picture, 
(chart-jpeg serializer is JFCSerializer 
http://www.sidimar.ipzs.it/fins010/serializer-ref.html)

sitemap snippet :

                        <map:match pattern="**/enquete-report-chart-data/*">
                                <map:generate 
src="cocoon:/{1}/enquete-definition" />
                                <map:transform type="report">
                                        <map:parameter name="question" 
value="{2}" />
                                </map:transform>
                                <map:serialize type="xml" />
                        </map:match>
                        <map:match pattern="**/enquete-report-chart/*">
                                <map:generate 
src="cocoon:/{1}/enquete-definition" />
                                <map:transform type="report">
                                        <map:parameter name="question" 
value="{2}" />
                                </map:transform>
                                <map:serialize type="chart-jpeg" />
                        </map:match>

code snippet :

public class ReportTransformer extends AbstractDOMTransformer implements 
Composable {

    protected Document transform(Document doc) {
            this.getLogger().error(doc.getNamespaceURI());
//the line above returns null for the namespace

        Document newdoc = null;
        Connection connection = null;

        try {
            connection = datasource.getConnection();

            Node qnode = XPathAPI.selectSingleNode(doc, 
"q:enquete/q:questions/q:question[@id = '" + question + "']", doc);
// the line above gives the following error : Prefix must resolve to a 
namespace
...
 

2) In a custom generator which generates a  cform selection-list xml
the resulting xml lacks the namespace definition.
I could work around this one by explicity adding the namespace attribute 
to the starting element

sitemap snippet :

            <map:match pattern="form/lookup/*">
                <map:generate type="lookup">
                    <map:parameter name="type" value="{1}" />
                </map:generate>
                <map:serialize type="xml" />
            </map:match>

code snippet :

public class LookupGenerator extends AbstractComposableGenerator {

private static final String NAMESPACE_URI_FORMDEFINITION = 
"http://apache.org/cocoon/forms/1.0#definition";

public generate()
      
...

        contentHandler.startDocument();
        AttributesImpl attributes = new AttributesImpl();
//WORKAROUND: explicitly added namespace attribute
        attributes.addAttribute(NAMESPACE_URI_FORMDEFINITION, 
"xmlns:fd", "xmlns:fd", "CDATA", NAMESPACE_URI_FORMDEFINITION);
        // the following adds <fd:selection-list 
xmlns:fs="http://apache.org/cocoon/forms/1.0#definition">
        contentHandler.startElement(NAMESPACE_URI_FORMDEFINITION, 
"selection-list", "fd:selection-list", attributes);

...

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