예제 #1
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");
 }
예제 #2
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");
 }
예제 #3
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");
 }