The stax implementation has a lot to do with it. Based on the
classpath, it would appear that you're using the stax impl that ships
with JDK 1.6? If so, please note that Abdera has not been tested on
1.6. I've tried both the IBM and Sun 1.5 JDK's and have not been able
to duplicate your results.
- James
Christoph Bauer wrote:
Hi,
thanks for the immediate response.
I was testing inside Eclipse Europe with a sun jdk.1.6.0_03 64bit Java
(linux-64)
The testing routine contained only the main method.
following libs in classpath
abdera.0.3.0-incubating/abdera.client.0.3.0-incubating.jar
abdera.0.3.0-incubating/abdera.core.0.3.0-incubating.jar
abdera.0.3.0-incubating/abdera.parser.0.3.0-incubating.jar
abdera.0.3.0-incubating/abdera.protocol.0.3.0-incubating.jar
abdera.0.3.0-incubating/lib/axiom-api-1.2.5.jar
abdera.0.3.0-incubating/lib/axiom-impl-1.2.5.jar
abdera.0.3.0-incubating/lib/commons-codec-1.3.jar
abdera.0.3.0-incubating/lib/commons-httpclient-3.1-rc1.jar
abdera.0.3.0-incubating/lib/commons-logging-1.0.4.jar
abdera.0.3.0-incubating/lib/jaxen-1.1.1.jar
abdera.0.3.0-incubating/lib/abdera-i18n-0.3.0-incubating.jar
abdera.0.3.0-incubating/lib/stax-api-1.0.1.jar
also tried the retro libs with a 32bit 1.4 jdk (same result)
Initially i found the problem with a self-generate feed so i tried
others and found the same problem.
Concerning stax: see classpath, but looking at the code i don't see how
that should matter when abdera generates
<>
<h3>Header</h3>
<p>some text here</p>
</>
and then goes ahead and throws the first two characters away.
James M Snell schrieb:
I am unable to duplicate the issue. What stax implementation are you
using? What platform? Does this happen with every entry or just one
specific entry? Are you seeing this problem with more than one feed
or several?
- James
Christoph Bauer wrote:
Hi Everyone,
i haven't found a bug report for this so i thought i ask here
please considered the following snippet:
public static void main(String[] args) {
Abdera abdera = new Abdera();
AbderaClient client = new AbderaClient(abdera);
ClientResponse resp =
client.get("http://mail-archives.apache.org/mod_mbox/incubator-abdera-dev/?format=atom");
if (resp.getType() == ResponseType.SUCCESS) {
Document<Feed> doc = resp.getDocument();
System.out.println(doc.getRoot().getEntries().iterator().next().getContent());
} else {
}
}
Right at the end of the content i get an empty </> xml tag.
Something like this:
<pre>My content</pre> </>
I dived through the code and found the
<org.apache.abdera.parser.stax.FOMDiv>.getInternalValue() Class which
I think is supposed to handle this:
protected String getInternalValue() {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLStreamWriter writer =
XMLOutputFactory.newInstance().createXMLStreamWriter(out);
writer.writeStartElement("");
for (Iterator nodes = this.getChildren(); nodes.hasNext();) {
OMNode node = (OMNode) nodes.next();
node.serialize(writer);
}
writer.writeEndElement();
return out.toString().substring(2);
} catch (Exception e) {}
return "";
}
If I understand that right abdera is trying to remove the surrounding
"div" tag. Unfortunately the output from this method cannot be used
if you need valid xhtml or at least valid xml because of the empty
element tag.
I shudder when i see
out.toString().substring(2);
For now i decided to stick with abdera, but handle the xhtml myself:
Element c =
doc.getRoot().getEntries().iterator().next().getContentElement().getFirstChild();
try {
StringWriter out = new StringWriter();
Element e = c.getFirstChild();
while (e != null) {
e.writeTo(out);
e = e.getNextSibling();
}
System.out.println(out.toString());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Would be nice to know whether this is some kind of bug, or whether i
got something wrong.
g
christoph bauer