|
18 | 18 | import java.util.regex.Pattern;
|
19 | 19 |
|
20 | 20 | import org.metafacture.framework.FluxCommand;
|
21 |
| -import org.metafacture.framework.MetafactureException; |
22 | 21 | import org.metafacture.framework.StreamReceiver;
|
23 | 22 | import org.metafacture.framework.XmlReceiver;
|
24 | 23 | import org.metafacture.framework.annotations.Description;
|
@@ -49,6 +48,8 @@ public final class GenericXmlHandler extends DefaultXmlPipe<StreamReceiver> {
|
49 | 48 | private boolean inRecord;
|
50 | 49 | private StringBuilder valueBuffer = new StringBuilder();
|
51 | 50 |
|
| 51 | + private boolean emitNamespace = false; |
| 52 | + |
52 | 53 | public GenericXmlHandler() {
|
53 | 54 | super();
|
54 | 55 | final String recordTagNameProperty = System.getProperty(
|
@@ -91,13 +92,32 @@ public String getRecordTagName() {
|
91 | 92 | return recordTagName;
|
92 | 93 | }
|
93 | 94 |
|
| 95 | + /** |
| 96 | + * On entity level namespaces can be emitted, e.g.: "foo:bar". The default is to |
| 97 | + * ignore the namespace so that only "bar" is emitted. |
| 98 | + * |
| 99 | + * @param emitNamespace set to "true" if namespace should be emitted. Defaults |
| 100 | + * to "false". |
| 101 | + */ |
| 102 | + public void setEmitNamespace(boolean emitNamespace) { |
| 103 | + this.emitNamespace = emitNamespace; |
| 104 | + } |
| 105 | + |
| 106 | + public boolean getEmitNamespace() { |
| 107 | + return this.emitNamespace; |
| 108 | + } |
| 109 | + |
94 | 110 | @Override
|
95 | 111 | public void startElement(final String uri, final String localName,
|
96 | 112 | final String qName, final Attributes attributes) {
|
97 | 113 |
|
98 | 114 | if (inRecord) {
|
99 | 115 | writeValue();
|
100 |
| - getReceiver().startEntity(localName); |
| 116 | + if (emitNamespace) { |
| 117 | + getReceiver().startEntity(qName); |
| 118 | + } else { |
| 119 | + getReceiver().startEntity(localName); |
| 120 | + } |
101 | 121 | writeAttributes(attributes);
|
102 | 122 | } else if (localName.equals(recordTagName)) {
|
103 | 123 | final String identifier = attributes.getValue("id");
|
|
0 commit comments