/**
* Parses pipelined data out of a Document.
*/
Map<PipelinedData, Node> parsePipelinedData(Gadget gadget, Document doc) {
NodeIterator nodeIterator = ((DocumentTraversal) doc)
.createNodeIterator(doc, NodeFilter.SHOW_ELEMENT,
new NodeFilter() {
public short acceptNode(Node n) {
if ("script".equalsIgnoreCase(n.getNodeName()) &&
"text/os-data".equals(((Element) n).getAttribute("type"))) {
return NodeFilter.FILTER_ACCEPT;
}
return NodeFilter.FILTER_REJECT;
}
}, false);
Map<PipelinedData, Node> pipelineNodes = Maps.newHashMap();
for (Node n = nodeIterator.nextNode(); n != null ; n = nodeIterator.nextNode()) {
try {
PipelinedData pipelineData = new PipelinedData((Element) n, gadget.getSpec().getUrl());
pipelineNodes.put(pipelineData, n);
} catch (SpecParserException e) {
// Leave the element to the client