cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luigi Bai <>
Subject Trouble with XMLDBTransformer
Date Wed, 01 Sep 2004 14:40:07 GMT
I'm having a problem with XMLDBTransformer sending an xupdate to an 
XMLDB database. I'm pretty sure others are using this successfully, so 
I'm not sure what I'm doing wrong.

I'm using a generator to output a document that looks like this 
(confirmed with ?cocoon-view=content):

<?xml version="1.0" encoding="ISO-8859-1"?>
<ax:query type="update" oid="setings.xml" 
    <xu:modifications version="1.0" xmlns:xu="">
       <xu:append select="/auth/login">
          <user name="user" uid="7" password="pickle" home="">
       <xu:update select="/auth/login/@last-uid">7</xu:update>

XMLDBTransformer correctly identifies the outer element and creates its 
ContentHandler for the inner one, a 
transformer(org.apache.xalan.transformer.TransformerIdentityImpl from 
Xalan 2.6.0) with a new StreamResult around a StringWriter. Once the 
endElement is seen for ax:query, the inner ContentHandler is sent an 
endDocument(), and the StringWriter is asked to produce its string to be 
sent to the target XUpdateQueryService. However, the string (serialized 
XML) lackes any xmlns Attributes, which causes at least eXist's SAX 
parser to throw an Exception.

<xu:modifications version="1.0">
<xu:append select="/auth/login">
<user name="user" uid="7" password="pickle" home="">
<xu:update select="/auth/login/@last-uid">7</xu:update>

[Fatal Error] :1:33: The prefix "xu" for element "xu:modifications" is 
not bound.

I've tried, in my cocoon.xconf, to do the following for namespaces; I 
turned "namespace-prefixes" on:

   <xml-parser class="org.apache.excalibur.xml.impl.JaxpParser" 
logger="core.xml-parser" pool-grow="4" pool-max="32" pool-min="8">
     <parameter name="validate" value="false"/>
     <parameter name="namespace-prefixes" value="true"/>
     <parameter name="stop-on-warning" value="true"/>
     <parameter name="stop-on-recoverable-error" value="true"/>
     <parameter name="reuse-parsers" value="true"/>
     <parameter name="drop-dtd-comments" value="true"/>

Also, I modified XMLDBTransformer() to explicitly set the Output.METHOD 
to "xml":

     public XMLDBTransformer() {
         format.put(OutputKeys.ENCODING, "utf-8");
         format.put(OutputKeys.INDENT, "yes");
         format.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
         format.put(OutputKeys.METHOD, "xml");

I have a feeling it's not the Transformer nor the XMLParser which are 
the problem, for two reasons. One, the cocoon-view=content properly 
shows the namespaces, so the xml serializer there seems to work fine. 
Second, in XMLDBTransformer.startElement() I traced the arguments, and saw:
Putting prefix ax as URI
Putting prefix xu as URI
Queryhandler is getting #, 
loc#modifications#, raw#xu:modifications#, 1 attributes.

Queryhandler is getting #, loc#append#, 
raw#xu:append#, 1 attributes.

Queryhandler is getting ##, loc#user#, raw#user#, 4 attributes.

Queryhandler is getting ##, loc#group#, raw#group#, 0 attributes.

Queryhandler is getting #, loc#update#, 
raw#xu:update#, 1 attributes.

By looking at the count of attributes on each element, I don't see an 
explicit "xmlns" attribute being passed through - but I do see the 
startPrefixMapping happening, so I'm fine with that.

Any suggestions? After all that, it's probably something pretty simple 
I'm missing. :-(

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message