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

Method element

basex-core/src/main/java/org/basex/query/func/unit/Unit.java:259–275  ·  view source on GitHub ↗

Creates a new element. @param item item @param name name (expected/returned) @param count item count (ignore it -1) @return element

(final Item item, final QNm name, final int count)

Source from the content-addressed store, hash-verified

257 * @return element
258 */
259 private static FBuilder element(final Item item, final QNm name, final int count) {
260 final FBuilder elem = FElem.build(name);
261 if(item != null) {
262 if(item instanceof final XNode node) {
263 elem.node(node);
264 } else {
265 try {
266 elem.text(item.string(null));
267 } catch(final QueryException ex) {
268 Util.debug(ex);
269 elem.text(item);
270 }
271 }
272 if(count != -1) elem.attr(Q_ITEM, count).attr(Q_TYPE, item.type);
273 }
274 return elem;
275 }
276
277 /**
278 * Evaluates a function.

Callers 1

addErrorMethod · 0.95

Calls 6

buildMethod · 0.95
nodeMethod · 0.95
textMethod · 0.95
debugMethod · 0.95
attrMethod · 0.95
stringMethod · 0.45

Tested by

no test coverage detected