Esempio n. 1
0
 @Override
 public void restore() throws TransformException {
   ItemList targets = mod.nearest(NodeTarget.class).targets();
   values = new ArrayList<Pair<String, Item>>(targets.size());
   for (Node node : targets.nodes()) {
     ItemList items = query.runOn(mod.scope(node.query()));
     if (items.size() != 1)
       throw new TransformException(
           "sort by value query did not select exactly one item: " + items);
     values.add(Pair.of(node.query().single("@xml:id").value(), items.get(0).toAtomicItem()));
   }
 }
Esempio n. 2
0
 @Override
 void resolveOrder(Mod.Builder modBuilder, Node node) throws TransformException {
   ItemList siblings = query.runOn(modBuilder.customScope(node.query().single("..").query()));
   for (Node sibling : siblings.nodes()) {
     if (!node.query().single(".. is $_1/..", sibling).booleanValue())
       throw new TransformException("query selected non-sibling node: " + sibling);
     modBuilder.reference(sibling);
   }
   modBuilder
       .supplement()
       .elem("sort-siblings")
       .attr("run-length", siblings.size())
       .end("sort-siblings");
 }