Hi,
I've get an error working with json extension. I've noticed that json
extension doesn't show the entry extension texts. I include an example:
"extensions":[{
"name":"app:edited",
"attributes":{
"xmlns:app":"http://www.w3.org/2007/app"
},
"children":[//EDITED DATE MISSED
]
},{
"name":"georss:where",
"attributes":{
"xmlns:georss":"http://www.georss.org/georss/10"
},
"children":[{
"name":"gml:Point",
"attributes":{
"xmlns:gml":"http://www.opengis.net/gml"
},
"children":[{
"name":"gml:pos",
"attributes":{
},
"children":[//POINT MISSED
]
}
]
}
]
}
I send you a patch that fixes that. Despite this, the
openSearch element texts still aren't shown, xpath parser always
return 0 children for these elements. It will be great if anyone could
take a look.
Regards
--
David Calavera
http://www.thinkincode.net
Index:
/home/david/workspace/devspace/abdera/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java
===================================================================
---
/home/david/workspace/devspace/abdera/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java
(revision 596254)
+++
/home/david/workspace/devspace/abdera/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java
(working copy)
@@ -52,6 +52,7 @@
import org.apache.abdera.model.TextValue;
import org.apache.abdera.model.Workspace;
import org.apache.abdera.xpath.XPath;
+import org.apache.axiom.om.OMText;
@SuppressWarnings("unchecked")
public class JSONUtil {
@@ -430,9 +431,8 @@
if (child instanceof Element) {
writeElement((Element)child, parentqname, jstream);
if (n < children.length-2) jstream.writeSeparator();
- } else if (child instanceof TextValue) {
- TextValue textvalue = (TextValue) child;
- String value = textvalue.getText();
+ } else if ((child instanceof TextValue) || (child instanceof OMText)) {
+ String value = child instanceof TextValue?((TextValue)
child).getText():((OMText) child).getText();
if (!element.getMustPreserveWhitespace()) {
if (!value.matches("\\s*")) {
jstream.writeQuoted(value.trim());
@@ -585,8 +585,9 @@
private static Object[] getChildren(
Element element) {
Abdera abdera = element.getFactory().getAbdera();
- XPath xpath = abdera.getXPath();
- List<Object> nodes = xpath.selectNodes("node()", element);
+ XPath xpath = abdera.getXPath();
+ List<Object> nodes = xpath.selectNodes("node()", element,
element.getNamespaces());
+
return nodes.toArray(new Object[nodes.size()]);
}