Adam Ratcliffe wrote:
I have a custom transformer that extends AbstractSaxTransformer for making XML-RPC calls. It extracts a method call element from an input document and sends this to the remote service for processing.
My problem is that when I use the startSerializedXMLRecording() method from AbstractSaxTransformer to collect the method call fragment it records elements only and the namespace attribute on the top-level element is lost.
This isn't a problem with the generator that creates the input document as I can see the attributes if I serialize the document after generation.
Is there a configuration step that I'm missing?
I think you should maintain map of namespace declarations (by processing start/end namespace mapping event) and declare all namespaces when you start recording. Look around for code samples, I think there is something similar in other transformers.
Vadim
public void startElement(String uri, String name, String raw, Attributes
attr)
throws SAXException {
if (name.equals(XMLRPC_REQUEST_ELEMENT)) {
this.stack.push("end");
} else if (name.equals(XMLRPC_SERVICE_ELEMENT)){
this.startTextRecording(); } else if (name.equals(XMLRPC_METHOD_CALL_ELEMENT)) {
this.startSerializedXMLRecording(XMLUtils.defaultSerializeToXMLFormat(tr
ue)); } else {
super.startElement(uri, name, raw, attr);
}
}
