@Override public int allocate(String prefix, short uriCode, String localName) { CacheKey key = new CacheKey(prefix, uriCode, localName); Integer code = nameCodes.get(key); if(code == null) { code = super.allocate(prefix, uriCode, localName); nameCodes.putIfAbsent(key, code); } return code; }
public void endSpan(Emitter rtf) throws TransformerException { if (!foStylesheet && namePool != null) { if (xhStylesheet) { uri = xhURI; } int spanName = namePool.allocate("", uri, "span"); rtf.endElement(spanName); } }
public void startSpan(Emitter rtf, String id) throws TransformerException { if (!foStylesheet && namePool != null) { if(xhStylesheet) { uri = xhURI; } int spanName = namePool.allocate("", uri, "span"); AttributeCollection spanAttr = new AttributeCollection(namePool); int namespaces[] = new int[1]; spanAttr.addAttribute("", uri, "class", "CDATA", "co"); spanAttr.addAttribute("", uri, "id", "CDATA", id); rtf.startElement(spanName, spanAttr, namespaces, 0); } }
private static void blockToSaxon6Node(Block b, Builder builder, NamePool pool, Config config) throws Exception { if (b.isStyled()) { AttributeCollection emptyAtts = new AttributeCollection(pool); int elemId = pool.allocate(config.prefix, config.uri, ((StyledBlock) b).getStyle()); builder.startElement(elemId, emptyAtts, new int[0], 0); builder.characters(b.getText().toCharArray(), 0, b.getText() .length()); builder.endElement(elemId); } else { builder.characters(b.getText().toCharArray(), 0, b.getText() .length()); } }
public static NodeEnumeration tokenize(Context context, String str, String pattern) throws XPathException { try { Builder builder = context.getController().makeBuilder(); NamePool pool = context.getController().getNamePool(); builder.setNamePool(pool); builder.startDocument(); int name = pool.allocate("", "", "token"); AttributeCollection emptyAtts = new AttributeCollection(pool); String[] tokens = str.split(pattern); for(String token: tokens) { builder.startElement(name, emptyAtts, new int[0], 0); builder.characters(token.toCharArray(), 0, token.length()); builder.endElement(name); } builder.endDocument(); DocumentInfo doc = builder.getCurrentDocument(); return doc.getEnumeration(Axis.CHILD, AnyNodeTest.getInstance()); } catch (Exception err) { ExtensionFunctionUtils.setExtensionFunctionError(err); throw new XPathException(err); } }