MCPcopy Create free account
hub / github.com/BaseXdb/basex / mixed

Method mixed

basex-core/src/main/java/org/basex/query/func/fn/PlanFn.java:479–504  ·  view source on GitHub ↗

Returns a mixed-layout item. @param node node @param parent parent (can be null @param plan plan @param qc query context @param ignoreEmpty ignore empty text nodes @return array @throws QueryException query exception

(final GNode node, final GNode parent, final Plan plan,
      final QueryContext qc, final boolean ignoreEmpty)

Source from the content-addressed store, hash-verified

477 * @throws QueryException query exception
478 */
479 private XQArray mixed(final GNode node, final GNode parent, final Plan plan,
480 final QueryContext qc, final boolean ignoreEmpty) throws QueryException {
481
482 final ArrayBuilder ab = new ArrayBuilder(qc);
483 for(final GNode attr : children(Kind.ATTRIBUTE, node)) {
484 ab.add(new MapBuilder().put(nodeName(attr, node, plan, qc), attr.string()).map());
485 }
486 for(final GNode child : node.childIter()) {
487 final Item item = switch(child.kind()) {
488 case COMMENT ->
489 new MapBuilder().put(COMMENT, child.string()).map();
490 case ELEMENT ->
491 new MapBuilder().put(nodeName(child, parent, plan, qc),
492 entry(child, plan).apply(child, node, plan, qc)).map();
493 case PROCESSING_INSTRUCTION ->
494 new MapBuilder().put(PI, child.name()).put(DATA, child.string()).map();
495 case TEXT -> {
496 final byte[] text = child.string();
497 yield ignoreEmpty && Token.normalize(text).length == 0 ? null : Str.get(text);
498 }
499 default -> null;
500 };
501 if(item != null) ab.add(item);
502 }
503 return ab.array();
504 }
505
506 /**
507 * Returns an XML item.

Callers 1

createMethod · 0.45

Calls 14

childrenMethod · 0.95
addMethod · 0.95
nodeNameMethod · 0.95
entryMethod · 0.95
normalizeMethod · 0.95
getMethod · 0.95
arrayMethod · 0.95
kindMethod · 0.65
applyMethod · 0.65
nameMethod · 0.65
mapMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected