RESOLVED - issue BATCH-1377: StaxEventItemWriter: Handle namespace for the root tag

This commit is contained in:
dsyer
2010-01-05 09:40:02 +00:00
parent 81d96cd63a
commit f56ee74729
2 changed files with 52 additions and 53 deletions

View File

@@ -232,7 +232,15 @@ public class StaxEventItemWriter<T> extends ExecutionContextUserSupport implemen
/**
* Set the tag name of the root element. If not set, default name is used
* ("root").
* ("root"). Namespace URI and prefix can also be set optionally using the
* notation:
*
* <pre>
* {uri}prefix:root
* </pre>
*
* The prefix is optional (defaults to empty), but if it is specified then the
* uri must be provided.
*
* @param rootTagName the tag name to be used for the root element
*/
@@ -249,16 +257,6 @@ public class StaxEventItemWriter<T> extends ExecutionContextUserSupport implemen
return rootTagNamespacePrefix;
}
/**
* Set the namespace prefix of the root element. If not set, the namespace
* prefix "xmlns" is used.
*
* @param rootTagNamespacePrefix the rootTagNamespacePrefix to set
*/
public void setRootTagNamespacePrefix(String rootTagNamespacePrefix) {
this.rootTagNamespacePrefix = rootTagNamespacePrefix;
}
/**
* Get the namespace of the root element.
*
@@ -268,15 +266,6 @@ public class StaxEventItemWriter<T> extends ExecutionContextUserSupport implemen
return rootTagNamespace;
}
/**
* Set the namespace of the root element. If not set, no namespace is used.
*
* @param rootTagNamespace the rootTagNamespace to set
*/
public void setRootTagNamespace(String rootTagNamespace) {
this.rootTagNamespace = rootTagNamespace;
}
/**
* Get attributes of the root element.
*
@@ -315,6 +304,15 @@ public class StaxEventItemWriter<T> extends ExecutionContextUserSupport implemen
*/
public void afterPropertiesSet() throws Exception {
Assert.notNull(marshaller);
if (rootTagName.contains("{")) {
rootTagNamespace = rootTagName.replaceAll("\\{(.*)\\}.*", "$1");
rootTagName = rootTagName.replaceAll("\\{.*\\}(.*)", "$1");
if (rootTagName.contains(":"))
{
rootTagNamespacePrefix = rootTagName.replaceAll("(.*):.*", "$1");
rootTagName = rootTagName.replaceAll(".*:(.*)", "$1");
}
}
}
/**