Beispiel #1
0
 public void resolve(Mod.Builder modBuilder) throws TransformException {
   for (Node node :
       modBuilder.dependOnNearest(NodeTarget.class).unverified().get().targets().nodes()) {
     modBuilder.dependOn(node.document());
     modBuilder.order(node);
     resolveOrder(modBuilder, node);
   }
   modBuilder.dependOn(requiredVariables);
   modBuilder.commit();
 }
Beispiel #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");
 }
Beispiel #3
0
 @Override
 void resolveOrder(Mod.Builder modBuilder, Node node) throws TransformException {
   ItemList items = query.runOn(modBuilder.customScope(node.query()));
   if (items.size() != 1)
     throw new TransformException(
         "sort by value must select one value per target, but instead selected "
             + items.size()
             + ": "
             + items);
   modBuilder
       .supplement()
       .elem("sort-value")
       .attr("refid", node.query().single("@xml:id").value())
       .text(items.get(0).value())
       .end("sort-value");
 }
Beispiel #4
0
 @Override
 void resolveOrder(Mod.Builder modBuilder, Node node) throws TransformException {
   // TODO: see if we can resolve /id in global scope while keeping node context
   ItemList items = query.runOn(modBuilder.customScope(node.query()));
   if (items.size() != 1)
     throw new TransformException(
         "sort by corresponding node must select one node per target, but instead selected "
             + items.size()
             + ": "
             + items);
   Node proxy = items.get(0).node();
   modBuilder.reference(proxy);
   modBuilder
       .supplement()
       .elem("sort-proxy")
       .attr(
           "position", proxy.query().single("count(preceding::*) + count(ancestor::*)").value())
       .end("sort-proxy");
 }