You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Luigi Bai <lp...@focalpoint.com> on 2004/09/01 16:40:07 UTC
Trouble with XMLDBTransformer
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"
xmlns:ax="http://apache.org/cocoon/xmldb/1.0">
<xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate">
<xu:append select="/auth/login">
<user name="user" uid="7" password="pickle" home="">
<group>users</group>
</user>
</xu:append>
<xu:update select="/auth/login/@last-uid">7</xu:update>
</xu:modifications>
</ax:query>
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.
String:
<xu:modifications version="1.0">
<xu:append select="/auth/login">
<user name="user" uid="7" password="pickle" home="">
<group>users</group>
</user>
</xu:append>
<xu:update select="/auth/login/@last-uid">7</xu:update>
</xu:modifications>
throws:
[Fatal Error] :1:33: The prefix "xu" for element "xu:modifications" is
not bound.
org.xml.sax.SAXParseException
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"/>
</xml-parser>
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 http://apache.org/cocoon/xmldb/1.0
Putting prefix xu as URI http://www.xmldb.org/xupdate
Queryhandler is getting #http://www.xmldb.org/xupdate#,
loc#modifications#, raw#xu:modifications#, 1 attributes.
Queryhandler is getting #http://www.xmldb.org/xupdate#, 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 #http://www.xmldb.org/xupdate#, 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. :-(
Re: Trouble with XMLDBTransformer
Posted by Luigi Bai <lp...@focalpoint.com>.
Never mind; I fixed it. See
http://issues.apache.org/bugzilla/show_bug.cgi?id=28723 for the patch.
Luigi Bai wrote:
> Any ideas?
>
> Luigi Bai wrote:
>
>> 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"
>> xmlns:ax="http://apache.org/cocoon/xmldb/1.0">
>> <xu:modifications version="1.0"
>> xmlns:xu="http://www.xmldb.org/xupdate">
>> <xu:append select="/auth/login">
>> <user name="user" uid="7" password="pickle" home="">
>> <group>users</group>
>> </user>
>> </xu:append>
>> <xu:update select="/auth/login/@last-uid">7</xu:update>
>> </xu:modifications>
>> </ax:query>
>>
>> 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.
>>
>> String:
>> <xu:modifications version="1.0">
>> <xu:append select="/auth/login">
>> <user name="user" uid="7" password="pickle" home="">
>> <group>users</group>
>> </user>
>> </xu:append>
>> <xu:update select="/auth/login/@last-uid">7</xu:update>
>> </xu:modifications>
>>
>> throws:
>> [Fatal Error] :1:33: The prefix "xu" for element "xu:modifications" is
>> not bound.
>> org.xml.sax.SAXParseException
>>
>> 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"/>
>> </xml-parser>
>>
>> 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 http://apache.org/cocoon/xmldb/1.0
>> Putting prefix xu as URI http://www.xmldb.org/xupdate
>> Queryhandler is getting #http://www.xmldb.org/xupdate#,
>> loc#modifications#, raw#xu:modifications#, 1 attributes.
>>
>> Queryhandler is getting #http://www.xmldb.org/xupdate#, 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 #http://www.xmldb.org/xupdate#, 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. :-(
>>
>>
>
>
--
<A HREF="http://www.focalpoint.com/">Home Page</A>
education is what's left after what is learned is forgotten.
-- b f skinner
Luigi P. Bai Focal Point Software, Inc.
lpb@focalpoint.com 3701 Kirby Drive, Suite 512
turning data into information Houston, TX 77098
(713) 215-1600 x 33#
Re: Trouble with XMLDBTransformer
Posted by Luigi Bai <lp...@focalpoint.com>.
Never mind; I fixed it. See
http://issues.apache.org/bugzilla/show_bug.cgi?id=28723 for the patch.
Luigi Bai wrote:
> Any ideas?
>
> Luigi Bai wrote:
>
>> 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"
>> xmlns:ax="http://apache.org/cocoon/xmldb/1.0">
>> <xu:modifications version="1.0"
>> xmlns:xu="http://www.xmldb.org/xupdate">
>> <xu:append select="/auth/login">
>> <user name="user" uid="7" password="pickle" home="">
>> <group>users</group>
>> </user>
>> </xu:append>
>> <xu:update select="/auth/login/@last-uid">7</xu:update>
>> </xu:modifications>
>> </ax:query>
>>
>> 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.
>>
>> String:
>> <xu:modifications version="1.0">
>> <xu:append select="/auth/login">
>> <user name="user" uid="7" password="pickle" home="">
>> <group>users</group>
>> </user>
>> </xu:append>
>> <xu:update select="/auth/login/@last-uid">7</xu:update>
>> </xu:modifications>
>>
>> throws:
>> [Fatal Error] :1:33: The prefix "xu" for element "xu:modifications" is
>> not bound.
>> org.xml.sax.SAXParseException
>>
>> 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"/>
>> </xml-parser>
>>
>> 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 http://apache.org/cocoon/xmldb/1.0
>> Putting prefix xu as URI http://www.xmldb.org/xupdate
>> Queryhandler is getting #http://www.xmldb.org/xupdate#,
>> loc#modifications#, raw#xu:modifications#, 1 attributes.
>>
>> Queryhandler is getting #http://www.xmldb.org/xupdate#, 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 #http://www.xmldb.org/xupdate#, 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. :-(
>>
>>
>
>
--
<A HREF="http://www.focalpoint.com/">Home Page</A>
education is what's left after what is learned is forgotten.
-- b f skinner
Luigi P. Bai Focal Point Software, Inc.
lpb@focalpoint.com 3701 Kirby Drive, Suite 512
turning data into information Houston, TX 77098
(713) 215-1600 x 33#
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Trouble with XMLDBTransformer
Posted by Luigi Bai <lp...@focalpoint.com>.
Any ideas?
Luigi Bai wrote:
> 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"
> xmlns:ax="http://apache.org/cocoon/xmldb/1.0">
> <xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate">
> <xu:append select="/auth/login">
> <user name="user" uid="7" password="pickle" home="">
> <group>users</group>
> </user>
> </xu:append>
> <xu:update select="/auth/login/@last-uid">7</xu:update>
> </xu:modifications>
> </ax:query>
>
> 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.
>
> String:
> <xu:modifications version="1.0">
> <xu:append select="/auth/login">
> <user name="user" uid="7" password="pickle" home="">
> <group>users</group>
> </user>
> </xu:append>
> <xu:update select="/auth/login/@last-uid">7</xu:update>
> </xu:modifications>
>
> throws:
> [Fatal Error] :1:33: The prefix "xu" for element "xu:modifications" is
> not bound.
> org.xml.sax.SAXParseException
>
> 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"/>
> </xml-parser>
>
> 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 http://apache.org/cocoon/xmldb/1.0
> Putting prefix xu as URI http://www.xmldb.org/xupdate
> Queryhandler is getting #http://www.xmldb.org/xupdate#,
> loc#modifications#, raw#xu:modifications#, 1 attributes.
>
> Queryhandler is getting #http://www.xmldb.org/xupdate#, 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 #http://www.xmldb.org/xupdate#, 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. :-(
>
>
--
<A HREF="http://www.focalpoint.com/">Home Page</A>
education is what's left after what is learned is forgotten.
-- b f skinner
Luigi P. Bai Focal Point Software, Inc.
lpb@focalpoint.com 3701 Kirby Drive, Suite 512
turning data into information Houston, TX 77098
(713) 215-1600 x 33#
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org